]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/db/output_validator.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / db / output_validator.cc
CommitLineData
20effc67
TL
1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
5//
6#include "db/output_validator.h"
7
1e59de90
TL
8#include "test_util/sync_point.h"
9#include "util/hash.h"
10
20effc67
TL
11namespace ROCKSDB_NAMESPACE {
12Status OutputValidator::Add(const Slice& key, const Slice& value) {
13 if (enable_hash_) {
14 // Generate a rolling 64-bit hash of the key and values
15 paranoid_hash_ = NPHash64(key.data(), key.size(), paranoid_hash_);
16 paranoid_hash_ = NPHash64(value.data(), value.size(), paranoid_hash_);
17 }
18 if (enable_order_check_) {
19 TEST_SYNC_POINT_CALLBACK("OutputValidator::Add:order_check",
20 /*arg=*/nullptr);
21 if (key.size() < kNumInternalBytes) {
22 return Status::Corruption(
23 "Compaction tries to write a key without internal bytes.");
24 }
25 // prev_key_ starts with empty.
26 if (!prev_key_.empty() && icmp_.Compare(key, prev_key_) < 0) {
27 return Status::Corruption("Compaction sees out-of-order keys.");
28 }
29 prev_key_.assign(key.data(), key.size());
30 }
31 return Status::OK();
32}
33} // namespace ROCKSDB_NAMESPACE