d1c510baec
Summary: in PR https://github.com/facebook/rocksdb/issues/7419 , we introduce the new Append and PositionedAppend APIs to WritableFile at File System, which enable RocksDB to pass the data verification information (e.g., checksum of the data) to the lower layer. In this PR, we use the new API in WritableFileWriter, such that the file created via WritableFileWrite can pass the checksum to the storage layer. To control which types file should apply the checksum handoff, we add checksum_handoff_file_types to DBOptions. User can use this option to control which file types (Currently supported file tyes: kLogFile, kTableFile, kDescriptorFile.) should use the new Append and PositionedAppend APIs to handoff the verification information. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7523 Test Plan: add new unit test, pass make check/ make asan_check Reviewed By: pdillinger Differential Revision: D24313271 Pulled By: zhichao-cao fbshipit-source-id: aafd69091ae85c3318e3e17cbb96fe7338da11d0
49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
// Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include <assert.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "rocksdb/rocksdb_namespace.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
// This is a data structure specifically designed as a "Set" for a
|
|
// pretty small scale of Enum structure. For now, it can support up
|
|
// to 64 element, and it is expandable in the future.
|
|
template <typename ENUM_TYPE, ENUM_TYPE MAX_VALUE>
|
|
class SmallEnumSet {
|
|
public:
|
|
SmallEnumSet() : state_(0) {}
|
|
|
|
~SmallEnumSet() {}
|
|
|
|
// Return true if the input enum is included in the "Set" (i.e., changes the
|
|
// internal scalar state successfully), otherwise, it will return false.
|
|
bool Add(const ENUM_TYPE value) {
|
|
static_assert(MAX_VALUE <= 63, "Size currently limited to 64");
|
|
assert(value >= 0 && value <= MAX_VALUE);
|
|
uint64_t old_state = state_;
|
|
uint64_t tmp = 1;
|
|
state_ |= (tmp << value);
|
|
return old_state != state_;
|
|
}
|
|
|
|
// Return true if the input enum is contained in the "Set".
|
|
bool Contains(const ENUM_TYPE value) {
|
|
static_assert(MAX_VALUE <= 63, "Size currently limited to 64");
|
|
assert(value >= 0 && value <= MAX_VALUE);
|
|
uint64_t tmp = 1;
|
|
return state_ & (tmp << value);
|
|
}
|
|
|
|
private:
|
|
uint64_t state_;
|
|
};
|
|
} // namespace ROCKSDB_NAMESPACE
|