Remove unnecessary, confusing 'extern' (#12300)

Summary:
In C++, `extern` is redundant in a number of cases:
* "Global" function declarations and definitions
* "Global" variable definitions when already declared `extern`

For consistency and simplicity, I've removed these in code that *we own*. In a couple of cases, I removed obsolete declarations, and for MagicNumber constants, I have consolidated the declarations into a header file (format.h)
as standard best practice would prescribe.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12300

Test Plan: no functional changes, CI

Reviewed By: ajkr

Differential Revision: D53148629

Pulled By: pdillinger

fbshipit-source-id: fb8d927959892e03af09b0c0d542b0a3b38fd886
This commit is contained in:
Peter Dillinger 2024-01-29 10:38:08 -08:00 committed by Facebook GitHub Bot
parent 36704e9227
commit 4e60663b31
71 changed files with 378 additions and 429 deletions

View file

@ -118,7 +118,7 @@ class ArenaWrappedDBIter : public Iterator {
// Generate the arena wrapped iterator class. // Generate the arena wrapped iterator class.
// `db_impl` and `cfd` are used for reneweal. If left null, renewal will not // `db_impl` and `cfd` are used for reneweal. If left null, renewal will not
// be supported. // be supported.
extern ArenaWrappedDBIter* NewArenaWrappedDbIterator( ArenaWrappedDBIter* NewArenaWrappedDbIterator(
Env* env, const ReadOptions& read_options, const ImmutableOptions& ioptions, Env* env, const ReadOptions& read_options, const ImmutableOptions& ioptions,
const MutableCFOptions& mutable_cf_options, const Version* version, const MutableCFOptions& mutable_cf_options, const Version* version,
const SequenceNumber& sequence, uint64_t max_sequential_skip_in_iterations, const SequenceNumber& sequence, uint64_t max_sequential_skip_in_iterations,

View file

@ -50,7 +50,7 @@ TableBuilder* NewTableBuilder(const TableBuilderOptions& tboptions,
// //
// @param column_family_name Name of the column family that is also identified // @param column_family_name Name of the column family that is also identified
// by column_family_id, or empty string if unknown. // by column_family_id, or empty string if unknown.
extern Status BuildTable( Status BuildTable(
const std::string& dbname, VersionSet* versions, const std::string& dbname, VersionSet* versions,
const ImmutableDBOptions& db_options, const TableBuilderOptions& tboptions, const ImmutableDBOptions& db_options, const TableBuilderOptions& tboptions,
const FileOptions& file_options, TableCache* table_cache, const FileOptions& file_options, TableCache* table_cache,

View file

@ -3144,7 +3144,7 @@ void rocksdb_options_set_enable_blob_files(rocksdb_options_t* opt,
unsigned char val) { unsigned char val) {
opt->rep.enable_blob_files = val; opt->rep.enable_blob_files = val;
} }
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_files( ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_files(
rocksdb_options_t* opt) { rocksdb_options_t* opt) {
return opt->rep.enable_blob_files; return opt->rep.enable_blob_files;
} }
@ -4636,7 +4636,7 @@ void rocksdb_readoptions_set_io_timeout(rocksdb_readoptions_t* opt,
opt->rep.io_timeout = std::chrono::microseconds(microseconds); opt->rep.io_timeout = std::chrono::microseconds(microseconds);
} }
extern ROCKSDB_LIBRARY_API uint64_t ROCKSDB_LIBRARY_API uint64_t
rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t* opt) { rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t* opt) {
return opt->rep.io_timeout.count(); return opt->rep.io_timeout.count();
} }
@ -5469,9 +5469,7 @@ uint64_t rocksdb_livefiles_deletions(const rocksdb_livefiles_t* lf, int index) {
return lf->rep[index].num_deletions; return lf->rep[index].num_deletions;
} }
extern void rocksdb_livefiles_destroy(const rocksdb_livefiles_t* lf) { void rocksdb_livefiles_destroy(const rocksdb_livefiles_t* lf) { delete lf; }
delete lf;
}
void rocksdb_get_options_from_string(const rocksdb_options_t* base_options, void rocksdb_get_options_from_string(const rocksdb_options_t* base_options,
const char* opts_str, const char* opts_str,

View file

@ -251,20 +251,19 @@ struct SuperVersion {
autovector<MemTable*> to_delete; autovector<MemTable*> to_delete;
}; };
extern Status CheckCompressionSupported(const ColumnFamilyOptions& cf_options); Status CheckCompressionSupported(const ColumnFamilyOptions& cf_options);
extern Status CheckConcurrentWritesSupported( Status CheckConcurrentWritesSupported(const ColumnFamilyOptions& cf_options);
Status CheckCFPathsSupported(const DBOptions& db_options,
const ColumnFamilyOptions& cf_options); const ColumnFamilyOptions& cf_options);
extern Status CheckCFPathsSupported(const DBOptions& db_options, ColumnFamilyOptions SanitizeOptions(const ImmutableDBOptions& db_options,
const ColumnFamilyOptions& cf_options);
extern ColumnFamilyOptions SanitizeOptions(const ImmutableDBOptions& db_options,
const ColumnFamilyOptions& src); const ColumnFamilyOptions& src);
// Wrap user defined table properties collector factories `from cf_options` // Wrap user defined table properties collector factories `from cf_options`
// into internal ones in int_tbl_prop_collector_factories. Add a system internal // into internal ones in int_tbl_prop_collector_factories. Add a system internal
// one too. // one too.
extern void GetIntTblPropCollectorFactory( void GetIntTblPropCollectorFactory(
const ImmutableCFOptions& ioptions, const ImmutableCFOptions& ioptions,
IntTblPropCollectorFactories* int_tbl_prop_collector_factories); IntTblPropCollectorFactories* int_tbl_prop_collector_factories);
@ -872,12 +871,11 @@ class ColumnFamilyMemTablesImpl : public ColumnFamilyMemTables {
ColumnFamilyHandleInternal handle_; ColumnFamilyHandleInternal handle_;
}; };
extern uint32_t GetColumnFamilyID(ColumnFamilyHandle* column_family); uint32_t GetColumnFamilyID(ColumnFamilyHandle* column_family);
extern const Comparator* GetColumnFamilyUserComparator( const Comparator* GetColumnFamilyUserComparator(
ColumnFamilyHandle* column_family); ColumnFamilyHandle* column_family);
extern const ImmutableOptions& GetImmutableOptions( const ImmutableOptions& GetImmutableOptions(ColumnFamilyHandle* column_family);
ColumnFamilyHandle* column_family);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -595,6 +595,6 @@ struct PerKeyPlacementContext {
#endif /* !NDEBUG */ #endif /* !NDEBUG */
// Return sum of sizes of all files in `files`. // Return sum of sizes of all files in `files`.
extern uint64_t TotalFileSize(const std::vector<FileMetaData*>& files); uint64_t TotalFileSize(const std::vector<FileMetaData*>& files);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -13,10 +13,6 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern void MarkKeyMayExist(void* arg);
extern bool SaveValue(void* arg, const ParsedInternalKey& parsed_key,
const Slice& v, bool hit_and_return);
CompactedDBImpl::CompactedDBImpl(const DBOptions& options, CompactedDBImpl::CompactedDBImpl(const DBOptions& options,
const std::string& dbname) const std::string& dbname)
: DBImpl(options, dbname, /*seq_per_batch*/ false, +/*batch_per_txn*/ true, : DBImpl(options, dbname, /*seq_per_batch*/ false, +/*batch_per_txn*/ true,

View file

@ -2855,16 +2855,15 @@ class GetWithTimestampReadCallback : public ReadCallback {
} }
}; };
extern Options SanitizeOptions(const std::string& db, const Options& src, Options SanitizeOptions(const std::string& db, const Options& src,
bool read_only = false, bool read_only = false,
Status* logger_creation_s = nullptr); Status* logger_creation_s = nullptr);
extern DBOptions SanitizeOptions(const std::string& db, const DBOptions& src, DBOptions SanitizeOptions(const std::string& db, const DBOptions& src,
bool read_only = false, bool read_only = false,
Status* logger_creation_s = nullptr); Status* logger_creation_s = nullptr);
extern CompressionType GetCompressionFlush( CompressionType GetCompressionFlush(const ImmutableCFOptions& ioptions,
const ImmutableCFOptions& ioptions,
const MutableCFOptions& mutable_cf_options); const MutableCFOptions& mutable_cf_options);
// Return the earliest log file to keep after the memtable flush is // Return the earliest log file to keep after the memtable flush is
@ -2873,13 +2872,13 @@ extern CompressionType GetCompressionFlush(
// `memtables_to_flush`) will be flushed and thus will not depend on any WAL // `memtables_to_flush`) will be flushed and thus will not depend on any WAL
// file. // file.
// The function is only applicable to 2pc mode. // The function is only applicable to 2pc mode.
extern uint64_t PrecomputeMinLogNumberToKeep2PC( uint64_t PrecomputeMinLogNumberToKeep2PC(
VersionSet* vset, const ColumnFamilyData& cfd_to_flush, VersionSet* vset, const ColumnFamilyData& cfd_to_flush,
const autovector<VersionEdit*>& edit_list, const autovector<VersionEdit*>& edit_list,
const autovector<MemTable*>& memtables_to_flush, const autovector<MemTable*>& memtables_to_flush,
LogsWithPrepTracker* prep_tracker); LogsWithPrepTracker* prep_tracker);
// For atomic flush. // For atomic flush.
extern uint64_t PrecomputeMinLogNumberToKeep2PC( uint64_t PrecomputeMinLogNumberToKeep2PC(
VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush, VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush,
const autovector<autovector<VersionEdit*>>& edit_lists, const autovector<autovector<VersionEdit*>>& edit_lists,
const autovector<const autovector<MemTable*>*>& memtables_to_flush, const autovector<const autovector<MemTable*>*>& memtables_to_flush,
@ -2887,21 +2886,21 @@ extern uint64_t PrecomputeMinLogNumberToKeep2PC(
// In non-2PC mode, WALs with log number < the returned number can be // In non-2PC mode, WALs with log number < the returned number can be
// deleted after the cfd_to_flush column family is flushed successfully. // deleted after the cfd_to_flush column family is flushed successfully.
extern uint64_t PrecomputeMinLogNumberToKeepNon2PC( uint64_t PrecomputeMinLogNumberToKeepNon2PC(
VersionSet* vset, const ColumnFamilyData& cfd_to_flush, VersionSet* vset, const ColumnFamilyData& cfd_to_flush,
const autovector<VersionEdit*>& edit_list); const autovector<VersionEdit*>& edit_list);
// For atomic flush. // For atomic flush.
extern uint64_t PrecomputeMinLogNumberToKeepNon2PC( uint64_t PrecomputeMinLogNumberToKeepNon2PC(
VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush, VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush,
const autovector<autovector<VersionEdit*>>& edit_lists); const autovector<autovector<VersionEdit*>>& edit_lists);
// `cfd_to_flush` is the column family whose memtable will be flushed and thus // `cfd_to_flush` is the column family whose memtable will be flushed and thus
// will not depend on any WAL file. nullptr means no memtable is being flushed. // will not depend on any WAL file. nullptr means no memtable is being flushed.
// The function is only applicable to 2pc mode. // The function is only applicable to 2pc mode.
extern uint64_t FindMinPrepLogReferencedByMemTable( uint64_t FindMinPrepLogReferencedByMemTable(
VersionSet* vset, const autovector<MemTable*>& memtables_to_flush); VersionSet* vset, const autovector<MemTable*>& memtables_to_flush);
// For atomic flush. // For atomic flush.
extern uint64_t FindMinPrepLogReferencedByMemTable( uint64_t FindMinPrepLogReferencedByMemTable(
VersionSet* vset, VersionSet* vset,
const autovector<const autovector<MemTable*>*>& memtables_to_flush); const autovector<const autovector<MemTable*>*>& memtables_to_flush);

View file

@ -428,13 +428,15 @@ class DBIter final : public Iterator {
// Return a new iterator that converts internal keys (yielded by // Return a new iterator that converts internal keys (yielded by
// "*internal_iter") that were live at the specified `sequence` number // "*internal_iter") that were live at the specified `sequence` number
// into appropriate user keys. // into appropriate user keys.
extern Iterator* NewDBIterator( Iterator* NewDBIterator(Env* env, const ReadOptions& read_options,
Env* env, const ReadOptions& read_options, const ImmutableOptions& ioptions, const ImmutableOptions& ioptions,
const MutableCFOptions& mutable_cf_options, const MutableCFOptions& mutable_cf_options,
const Comparator* user_key_comparator, InternalIterator* internal_iter, const Comparator* user_key_comparator,
const Version* version, const SequenceNumber& sequence, InternalIterator* internal_iter, const Version* version,
uint64_t max_sequential_skip_in_iterations, ReadCallback* read_callback, const SequenceNumber& sequence,
DBImpl* db_impl = nullptr, ColumnFamilyData* cfd = nullptr, uint64_t max_sequential_skip_in_iterations,
ReadCallback* read_callback, DBImpl* db_impl = nullptr,
ColumnFamilyData* cfd = nullptr,
bool expose_blob_index = false); bool expose_blob_index = false);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -58,7 +58,7 @@ struct DBPropertyInfo {
bool (DBImpl::*handle_string_dbimpl)(std::string* value); bool (DBImpl::*handle_string_dbimpl)(std::string* value);
}; };
extern const DBPropertyInfo* GetPropertyInfo(const Slice& property); const DBPropertyInfo* GetPropertyInfo(const Slice& property);
#undef SCORE #undef SCORE
enum class LevelStatType { enum class LevelStatType {

View file

@ -699,6 +699,6 @@ class MemTable {
void MaybeUpdateNewestUDT(const Slice& user_key); void MaybeUpdateNewestUDT(const Slice& user_key);
}; };
extern const char* EncodeKey(std::string* scratch, const Slice& target); const char* EncodeKey(std::string* scratch, const Slice& target);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -498,7 +498,7 @@ class MemTableList {
// installs flush results for external immutable memtable lists other than the // installs flush results for external immutable memtable lists other than the
// cfds' own immutable memtable lists, e.g. MemTableLIstTest. In this case, // cfds' own immutable memtable lists, e.g. MemTableLIstTest. In this case,
// imm_lists parameter is not nullptr. // imm_lists parameter is not nullptr.
extern Status InstallMemtableAtomicFlushResults( Status InstallMemtableAtomicFlushResults(
const autovector<MemTableList*>* imm_lists, const autovector<MemTableList*>* imm_lists,
const autovector<ColumnFamilyData*>& cfds, const autovector<ColumnFamilyData*>& cfds,
const autovector<const MutableCFOptions*>& mutable_cf_options_list, const autovector<const MutableCFOptions*>& mutable_cf_options_list,

View file

@ -252,8 +252,6 @@ TEST_P(PlainTableDBTest, Empty) {
ASSERT_EQ("NOT_FOUND", Get("0000000000000foo")); ASSERT_EQ("NOT_FOUND", Get("0000000000000foo"));
} }
extern const uint64_t kPlainTableMagicNumber;
class TestPlainTableReader : public PlainTableReader { class TestPlainTableReader : public PlainTableReader {
public: public:
TestPlainTableReader( TestPlainTableReader(
@ -307,7 +305,6 @@ class TestPlainTableReader : public PlainTableReader {
bool* expect_bloom_not_match_; bool* expect_bloom_not_match_;
}; };
extern const uint64_t kPlainTableMagicNumber;
class TestPlainTableFactory : public PlainTableFactory { class TestPlainTableFactory : public PlainTableFactory {
public: public:
explicit TestPlainTableFactory(bool* expect_bloom_not_match, explicit TestPlainTableFactory(bool* expect_bloom_not_match,

View file

@ -242,8 +242,6 @@ class FlushBlockEveryThreePolicyFactory : public FlushBlockPolicyFactory {
} }
}; };
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
namespace { namespace {
void TestCustomizedTablePropertiesCollector( void TestCustomizedTablePropertiesCollector(
bool backward_mode, uint64_t magic_number, bool test_int_tbl_prop_collector, bool backward_mode, uint64_t magic_number, bool test_int_tbl_prop_collector,

View file

@ -113,7 +113,7 @@ constexpr uint64_t kUnknownEpochNumber = 0;
// will be dedicated to files ingested behind. // will be dedicated to files ingested behind.
constexpr uint64_t kReservedEpochNumberForFileIngestedBehind = 1; constexpr uint64_t kReservedEpochNumberForFileIngestedBehind = 1;
extern uint64_t PackFileNumberAndPathId(uint64_t number, uint64_t path_id); uint64_t PackFileNumberAndPathId(uint64_t number, uint64_t path_id);
// A copyable structure contains information needed to read data from an SST // A copyable structure contains information needed to read data from an SST
// file. It can contain a pointer to a table reader opened for the file, or // file. It can contain a pointer to a table reader opened for the file, or

View file

@ -98,7 +98,7 @@ using VersionEditParams = VersionEdit;
// Return file_level.num_files if there is no such file. // Return file_level.num_files if there is no such file.
// REQUIRES: "file_level.files" contains a sorted list of // REQUIRES: "file_level.files" contains a sorted list of
// non-overlapping files. // non-overlapping files.
extern int FindFile(const InternalKeyComparator& icmp, int FindFile(const InternalKeyComparator& icmp,
const LevelFilesBrief& file_level, const Slice& key); const LevelFilesBrief& file_level, const Slice& key);
// Returns true iff some file in "files" overlaps the user key range // Returns true iff some file in "files" overlaps the user key range
@ -107,7 +107,7 @@ extern int FindFile(const InternalKeyComparator& icmp,
// largest==nullptr represents a key largest than all keys in the DB. // largest==nullptr represents a key largest than all keys in the DB.
// REQUIRES: If disjoint_sorted_files, file_level.files[] // REQUIRES: If disjoint_sorted_files, file_level.files[]
// contains disjoint ranges in sorted order. // contains disjoint ranges in sorted order.
extern bool SomeFileOverlapsRange(const InternalKeyComparator& icmp, bool SomeFileOverlapsRange(const InternalKeyComparator& icmp,
bool disjoint_sorted_files, bool disjoint_sorted_files,
const LevelFilesBrief& file_level, const LevelFilesBrief& file_level,
const Slice* smallest_user_key, const Slice* smallest_user_key,
@ -116,7 +116,7 @@ extern bool SomeFileOverlapsRange(const InternalKeyComparator& icmp,
// Generate LevelFilesBrief from vector<FdWithKeyRange*> // Generate LevelFilesBrief from vector<FdWithKeyRange*>
// Would copy smallest_key and largest_key data to sequential memory // Would copy smallest_key and largest_key data to sequential memory
// arena: Arena used to allocate the memory // arena: Arena used to allocate the memory
extern void DoGenerateLevelFilesBrief(LevelFilesBrief* file_level, void DoGenerateLevelFilesBrief(LevelFilesBrief* file_level,
const std::vector<FileMetaData*>& files, const std::vector<FileMetaData*>& files,
Arena* arena); Arena* arena);
enum EpochNumberRequirement { enum EpochNumberRequirement {

View file

@ -11,11 +11,11 @@
#include "rocksdb/types.h" #include "rocksdb/types.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern const std::string& InvalidWriteStallHyphenString(); const std::string& InvalidWriteStallHyphenString();
extern const std::string& WriteStallCauseToHyphenString(WriteStallCause cause); const std::string& WriteStallCauseToHyphenString(WriteStallCause cause);
extern const std::string& WriteStallConditionToHyphenString( const std::string& WriteStallConditionToHyphenString(
WriteStallCondition condition); WriteStallCondition condition);
// REQUIRES: // REQUIRES:
@ -23,7 +23,7 @@ extern const std::string& WriteStallConditionToHyphenString(
// //
// REQUIRES: // REQUIRES:
// `condition` != `WriteStallCondition::kNormal` // `condition` != `WriteStallCondition::kNormal`
extern InternalStats::InternalCFStatsType InternalCFStat( InternalStats::InternalCFStatsType InternalCFStat(
WriteStallCause cause, WriteStallCondition condition); WriteStallCause cause, WriteStallCondition condition);
// REQUIRES: // REQUIRES:
@ -31,11 +31,11 @@ extern InternalStats::InternalCFStatsType InternalCFStat(
// //
// REQUIRES: // REQUIRES:
// `condition` != `WriteStallCondition::kNormal` // `condition` != `WriteStallCondition::kNormal`
extern InternalStats::InternalDBStatsType InternalDBStat( InternalStats::InternalDBStatsType InternalDBStat(
WriteStallCause cause, WriteStallCondition condition); WriteStallCause cause, WriteStallCondition condition);
extern bool isCFScopeWriteStallCause(WriteStallCause cause); bool isCFScopeWriteStallCause(WriteStallCause cause);
extern bool isDBScopeWriteStallCause(WriteStallCause cause); bool isDBScopeWriteStallCause(WriteStallCause cause);
constexpr uint32_t kNumCFScopeWriteStallCauses = constexpr uint32_t kNumCFScopeWriteStallCauses =
static_cast<uint32_t>(WriteStallCause::kCFScopeWriteStallCauseEnumMax) - static_cast<uint32_t>(WriteStallCause::kCFScopeWriteStallCauseEnumMax) -

View file

@ -489,7 +489,7 @@ inline bool GetNextPrefix(const ROCKSDB_NAMESPACE::Slice& src, std::string* v) {
#endif #endif
// Append `val` to `*key` in fixed-width big-endian format // Append `val` to `*key` in fixed-width big-endian format
extern inline void AppendIntToString(uint64_t val, std::string* key) { inline void AppendIntToString(uint64_t val, std::string* key) {
// PutFixed64 uses little endian // PutFixed64 uses little endian
PutFixed64(key, val); PutFixed64(key, val);
// Reverse to get big endian // Reverse to get big endian
@ -518,7 +518,7 @@ extern KeyGenContext key_gen_ctx;
// - {0}...{x-1} // - {0}...{x-1}
// {(x-1),0}..{(x-1),(y-1)},{(x-1),(y-1),0}..{(x-1),(y-1),(z-1)} and so on. // {(x-1),0}..{(x-1),(y-1)},{(x-1),(y-1),0}..{(x-1),(y-1),(z-1)} and so on.
// Additionally, a trailer of 0-7 bytes could be appended. // Additionally, a trailer of 0-7 bytes could be appended.
extern inline std::string Key(int64_t val) { inline std::string Key(int64_t val) {
uint64_t window = key_gen_ctx.window; uint64_t window = key_gen_ctx.window;
size_t levels = key_gen_ctx.weights.size(); size_t levels = key_gen_ctx.weights.size();
std::string key; std::string key;
@ -556,7 +556,7 @@ extern inline std::string Key(int64_t val) {
} }
// Given a string key, map it to an index into the expected values buffer // Given a string key, map it to an index into the expected values buffer
extern inline bool GetIntVal(std::string big_endian_key, uint64_t* key_p) { inline bool GetIntVal(std::string big_endian_key, uint64_t* key_p) {
size_t size_key = big_endian_key.size(); size_t size_key = big_endian_key.size();
std::vector<uint64_t> prefixes; std::vector<uint64_t> prefixes;
@ -611,7 +611,7 @@ inline bool GetFirstIntValInPrefix(std::string big_endian_prefix,
return GetIntVal(std::move(big_endian_prefix), key_p); return GetIntVal(std::move(big_endian_prefix), key_p);
} }
extern inline uint64_t GetPrefixKeyCount(const std::string& prefix, inline uint64_t GetPrefixKeyCount(const std::string& prefix,
const std::string& ub) { const std::string& ub) {
uint64_t start = 0; uint64_t start = 0;
uint64_t end = 0; uint64_t end = 0;
@ -624,7 +624,7 @@ extern inline uint64_t GetPrefixKeyCount(const std::string& prefix,
return end - start; return end - start;
} }
extern inline std::string StringToHex(const std::string& str) { inline std::string StringToHex(const std::string& str) {
std::string result = "0x"; std::string result = "0x";
result.append(Slice(str).ToString(true)); result.append(Slice(str).ToString(true));
return result; return result;
@ -643,49 +643,49 @@ inline std::string WideColumnsToHex(const WideColumns& columns) {
} }
// Unified output format for double parameters // Unified output format for double parameters
extern inline std::string FormatDoubleParam(double param) { inline std::string FormatDoubleParam(double param) {
return std::to_string(param); return std::to_string(param);
} }
// Make sure that double parameter is a value we can reproduce by // Make sure that double parameter is a value we can reproduce by
// re-inputting the value printed. // re-inputting the value printed.
extern inline void SanitizeDoubleParam(double* param) { inline void SanitizeDoubleParam(double* param) {
*param = std::atof(FormatDoubleParam(*param).c_str()); *param = std::atof(FormatDoubleParam(*param).c_str());
} }
extern void PoolSizeChangeThread(void* v); void PoolSizeChangeThread(void* v);
extern void DbVerificationThread(void* v); void DbVerificationThread(void* v);
extern void CompressedCacheSetCapacityThread(void* v); void CompressedCacheSetCapacityThread(void* v);
extern void TimestampedSnapshotsThread(void* v); void TimestampedSnapshotsThread(void* v);
extern void PrintKeyValue(int cf, uint64_t key, const char* value, size_t sz); void PrintKeyValue(int cf, uint64_t key, const char* value, size_t sz);
extern int64_t GenerateOneKey(ThreadState* thread, uint64_t iteration); int64_t GenerateOneKey(ThreadState* thread, uint64_t iteration);
extern std::vector<int64_t> GenerateNKeys(ThreadState* thread, int num_keys, std::vector<int64_t> GenerateNKeys(ThreadState* thread, int num_keys,
uint64_t iteration); uint64_t iteration);
extern size_t GenerateValue(uint32_t rand, char* v, size_t max_sz); size_t GenerateValue(uint32_t rand, char* v, size_t max_sz);
extern uint32_t GetValueBase(Slice s); uint32_t GetValueBase(Slice s);
extern WideColumns GenerateWideColumns(uint32_t value_base, const Slice& slice); WideColumns GenerateWideColumns(uint32_t value_base, const Slice& slice);
extern WideColumns GenerateExpectedWideColumns(uint32_t value_base, WideColumns GenerateExpectedWideColumns(uint32_t value_base,
const Slice& slice); const Slice& slice);
extern bool VerifyWideColumns(const Slice& value, const WideColumns& columns); bool VerifyWideColumns(const Slice& value, const WideColumns& columns);
extern bool VerifyWideColumns(const WideColumns& columns); bool VerifyWideColumns(const WideColumns& columns);
extern StressTest* CreateCfConsistencyStressTest(); StressTest* CreateCfConsistencyStressTest();
extern StressTest* CreateBatchedOpsStressTest(); StressTest* CreateBatchedOpsStressTest();
extern StressTest* CreateNonBatchedOpsStressTest(); StressTest* CreateNonBatchedOpsStressTest();
extern StressTest* CreateMultiOpsTxnsStressTest(); StressTest* CreateMultiOpsTxnsStressTest();
extern void CheckAndSetOptionsForMultiOpsTxnStressTest(); void CheckAndSetOptionsForMultiOpsTxnStressTest();
extern void InitializeHotKeyGenerator(double alpha); void InitializeHotKeyGenerator(double alpha);
extern int64_t GetOneHotKeyID(double rand_seed, int64_t max_key); int64_t GetOneHotKeyID(double rand_seed, int64_t max_key);
extern std::string GetNowNanos(); std::string GetNowNanos();
std::shared_ptr<FileChecksumGenFactory> GetFileChecksumImpl( std::shared_ptr<FileChecksumGenFactory> GetFileChecksumImpl(
const std::string& name); const std::string& name);

View file

@ -12,7 +12,7 @@
#pragma once #pragma once
#include "db_stress_tool/db_stress_test_base.h" #include "db_stress_tool/db_stress_test_base.h"
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern void ThreadBody(void* /*thread_state*/); void ThreadBody(void* /*thread_state*/);
extern bool RunStressTest(SharedState*); bool RunStressTest(SharedState*);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE
#endif // GFLAGS #endif // GFLAGS

View file

@ -291,13 +291,13 @@ class StressTest {
}; };
// Load options from OPTIONS file and populate `options`. // Load options from OPTIONS file and populate `options`.
extern bool InitializeOptionsFromFile(Options& options); bool InitializeOptionsFromFile(Options& options);
// Initialize `options` using command line arguments. // Initialize `options` using command line arguments.
// When this function is called, `cache`, `block_cache_compressed`, // When this function is called, `cache`, `block_cache_compressed`,
// `filter_policy` have all been initialized. Therefore, we just pass them as // `filter_policy` have all been initialized. Therefore, we just pass them as
// input arguments. // input arguments.
extern void InitializeOptionsFromFlags( void InitializeOptionsFromFlags(
const std::shared_ptr<Cache>& cache, const std::shared_ptr<Cache>& cache,
const std::shared_ptr<const FilterPolicy>& filter_policy, Options& options); const std::shared_ptr<const FilterPolicy>& filter_policy, Options& options);
@ -322,7 +322,7 @@ extern void InitializeOptionsFromFlags(
// //
// InitializeOptionsGeneral() must not overwrite fields of `options` loaded // InitializeOptionsGeneral() must not overwrite fields of `options` loaded
// from OPTIONS file. // from OPTIONS file.
extern void InitializeOptionsGeneral( void InitializeOptionsGeneral(
const std::shared_ptr<Cache>& cache, const std::shared_ptr<Cache>& cache,
const std::shared_ptr<const FilterPolicy>& filter_policy, Options& options); const std::shared_ptr<const FilterPolicy>& filter_policy, Options& options);
@ -330,7 +330,7 @@ extern void InitializeOptionsGeneral(
// user-defined timestamp which requires `-user_timestamp_size=8`. // user-defined timestamp which requires `-user_timestamp_size=8`.
// This function also checks for known (currently) incompatible features with // This function also checks for known (currently) incompatible features with
// user-defined timestamp. // user-defined timestamp.
extern void CheckAndSetOptionsForUserTimestamp(Options& options); void CheckAndSetOptionsForUserTimestamp(Options& options);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE
#endif // GFLAGS #endif // GFLAGS

View file

@ -20,14 +20,13 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
// use_fsync maps to options.use_fsync, which determines the way that // use_fsync maps to options.use_fsync, which determines the way that
// the file is synced after copying. // the file is synced after copying.
extern IOStatus CopyFile(FileSystem* fs, const std::string& source, IOStatus CopyFile(FileSystem* fs, const std::string& source,
std::unique_ptr<WritableFileWriter>& dest_writer, std::unique_ptr<WritableFileWriter>& dest_writer,
uint64_t size, bool use_fsync, uint64_t size, bool use_fsync,
const std::shared_ptr<IOTracer>& io_tracer, const std::shared_ptr<IOTracer>& io_tracer,
const Temperature temperature); const Temperature temperature);
extern IOStatus CopyFile(FileSystem* fs, const std::string& source, IOStatus CopyFile(FileSystem* fs, const std::string& source,
const std::string& destination, uint64_t size, const std::string& destination, uint64_t size, bool use_fsync,
bool use_fsync,
const std::shared_ptr<IOTracer>& io_tracer, const std::shared_ptr<IOTracer>& io_tracer,
const Temperature temperature); const Temperature temperature);
inline IOStatus CopyFile(const std::shared_ptr<FileSystem>& fs, inline IOStatus CopyFile(const std::shared_ptr<FileSystem>& fs,
@ -39,7 +38,7 @@ inline IOStatus CopyFile(const std::shared_ptr<FileSystem>& fs,
return CopyFile(fs.get(), source, destination, size, use_fsync, io_tracer, return CopyFile(fs.get(), source, destination, size, use_fsync, io_tracer,
temperature); temperature);
} }
extern IOStatus CreateFile(FileSystem* fs, const std::string& destination, IOStatus CreateFile(FileSystem* fs, const std::string& destination,
const std::string& contents, bool use_fsync); const std::string& contents, bool use_fsync);
inline IOStatus CreateFile(const std::shared_ptr<FileSystem>& fs, inline IOStatus CreateFile(const std::shared_ptr<FileSystem>& fs,
@ -48,13 +47,12 @@ inline IOStatus CreateFile(const std::shared_ptr<FileSystem>& fs,
return CreateFile(fs.get(), destination, contents, use_fsync); return CreateFile(fs.get(), destination, contents, use_fsync);
} }
extern Status DeleteDBFile(const ImmutableDBOptions* db_options, Status DeleteDBFile(const ImmutableDBOptions* db_options,
const std::string& fname, const std::string& fname, const std::string& path_to_sync,
const std::string& path_to_sync, const bool force_bg, const bool force_bg, const bool force_fg);
const bool force_fg);
// TODO(hx235): pass the whole DBOptions intead of its individual fields // TODO(hx235): pass the whole DBOptions intead of its individual fields
extern IOStatus GenerateOneFileChecksum( IOStatus GenerateOneFileChecksum(
FileSystem* fs, const std::string& file_path, FileSystem* fs, const std::string& file_path,
FileChecksumGenFactory* checksum_factory, FileChecksumGenFactory* checksum_factory,
const std::string& requested_checksum_func_name, std::string* file_checksum, const std::string& requested_checksum_func_name, std::string* file_checksum,

View file

@ -40,69 +40,68 @@ constexpr char kFilePathSeparator = '/';
// Return the name of the log file with the specified number // Return the name of the log file with the specified number
// in the db named by "dbname". The result will be prefixed with // in the db named by "dbname". The result will be prefixed with
// "dbname". // "dbname".
extern std::string LogFileName(const std::string& dbname, uint64_t number); std::string LogFileName(const std::string& dbname, uint64_t number);
extern std::string LogFileName(uint64_t number); std::string LogFileName(uint64_t number);
extern std::string BlobFileName(uint64_t number); std::string BlobFileName(uint64_t number);
extern std::string BlobFileName(const std::string& bdirname, uint64_t number); std::string BlobFileName(const std::string& bdirname, uint64_t number);
extern std::string BlobFileName(const std::string& dbname, std::string BlobFileName(const std::string& dbname, const std::string& blob_dir,
const std::string& blob_dir, uint64_t number); uint64_t number);
extern std::string ArchivalDirectory(const std::string& dbname); std::string ArchivalDirectory(const std::string& dbname);
// Return the name of the archived log file with the specified number // Return the name of the archived log file with the specified number
// in the db named by "dbname". The result will be prefixed with "dbname". // in the db named by "dbname". The result will be prefixed with "dbname".
extern std::string ArchivedLogFileName(const std::string& dbname, uint64_t num); std::string ArchivedLogFileName(const std::string& dbname, uint64_t num);
extern std::string MakeTableFileName(const std::string& name, uint64_t number); std::string MakeTableFileName(const std::string& name, uint64_t number);
extern std::string MakeTableFileName(uint64_t number); std::string MakeTableFileName(uint64_t number);
// Return the name of sstable with LevelDB suffix // Return the name of sstable with LevelDB suffix
// created from RocksDB sstable suffixed name // created from RocksDB sstable suffixed name
extern std::string Rocks2LevelTableFileName(const std::string& fullname); std::string Rocks2LevelTableFileName(const std::string& fullname);
// the reverse function of MakeTableFileName // the reverse function of MakeTableFileName
// TODO(yhchiang): could merge this function with ParseFileName() // TODO(yhchiang): could merge this function with ParseFileName()
extern uint64_t TableFileNameToNumber(const std::string& name); uint64_t TableFileNameToNumber(const std::string& name);
// Return the name of the sstable with the specified number // Return the name of the sstable with the specified number
// in the db named by "dbname". The result will be prefixed with // in the db named by "dbname". The result will be prefixed with
// "dbname". // "dbname".
extern std::string TableFileName(const std::vector<DbPath>& db_paths, std::string TableFileName(const std::vector<DbPath>& db_paths, uint64_t number,
uint64_t number, uint32_t path_id); uint32_t path_id);
// Sufficient buffer size for FormatFileNumber. // Sufficient buffer size for FormatFileNumber.
const size_t kFormatFileNumberBufSize = 38; const size_t kFormatFileNumberBufSize = 38;
extern void FormatFileNumber(uint64_t number, uint32_t path_id, char* out_buf, void FormatFileNumber(uint64_t number, uint32_t path_id, char* out_buf,
size_t out_buf_size); size_t out_buf_size);
// Return the name of the descriptor file for the db named by // Return the name of the descriptor file for the db named by
// "dbname" and the specified incarnation number. The result will be // "dbname" and the specified incarnation number. The result will be
// prefixed with "dbname". // prefixed with "dbname".
extern std::string DescriptorFileName(const std::string& dbname, std::string DescriptorFileName(const std::string& dbname, uint64_t number);
uint64_t number);
extern std::string DescriptorFileName(uint64_t number); std::string DescriptorFileName(uint64_t number);
extern const std::string kCurrentFileName; // = "CURRENT" extern const std::string kCurrentFileName; // = "CURRENT"
// Return the name of the current file. This file contains the name // Return the name of the current file. This file contains the name
// of the current manifest file. The result will be prefixed with // of the current manifest file. The result will be prefixed with
// "dbname". // "dbname".
extern std::string CurrentFileName(const std::string& dbname); std::string CurrentFileName(const std::string& dbname);
// Return the name of the lock file for the db named by // Return the name of the lock file for the db named by
// "dbname". The result will be prefixed with "dbname". // "dbname". The result will be prefixed with "dbname".
extern std::string LockFileName(const std::string& dbname); std::string LockFileName(const std::string& dbname);
// Return the name of a temporary file owned by the db named "dbname". // Return the name of a temporary file owned by the db named "dbname".
// The result will be prefixed with "dbname". // The result will be prefixed with "dbname".
extern std::string TempFileName(const std::string& dbname, uint64_t number); std::string TempFileName(const std::string& dbname, uint64_t number);
// A helper structure for prefix of info log names. // A helper structure for prefix of info log names.
struct InfoLogPrefix { struct InfoLogPrefix {
@ -115,12 +114,12 @@ struct InfoLogPrefix {
}; };
// Return the name of the info log file for "dbname". // Return the name of the info log file for "dbname".
extern std::string InfoLogFileName(const std::string& dbname, std::string InfoLogFileName(const std::string& dbname,
const std::string& db_path = "", const std::string& db_path = "",
const std::string& log_dir = ""); const std::string& log_dir = "");
// Return the name of the old info log file for "dbname". // Return the name of the old info log file for "dbname".
extern std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts, std::string OldInfoLogFileName(const std::string& dbname, uint64_t ts,
const std::string& db_path = "", const std::string& db_path = "",
const std::string& log_dir = ""); const std::string& log_dir = "");
@ -129,51 +128,48 @@ extern const std::string kTempFileNameSuffix; // = "dbtmp"
// Return a options file name given the "dbname" and file number. // Return a options file name given the "dbname" and file number.
// Format: OPTIONS-[number].dbtmp // Format: OPTIONS-[number].dbtmp
extern std::string OptionsFileName(const std::string& dbname, std::string OptionsFileName(const std::string& dbname, uint64_t file_num);
uint64_t file_num); std::string OptionsFileName(uint64_t file_num);
extern std::string OptionsFileName(uint64_t file_num);
// Return a temp options file name given the "dbname" and file number. // Return a temp options file name given the "dbname" and file number.
// Format: OPTIONS-[number] // Format: OPTIONS-[number]
extern std::string TempOptionsFileName(const std::string& dbname, std::string TempOptionsFileName(const std::string& dbname, uint64_t file_num);
uint64_t file_num);
// Return the name to use for a metadatabase. The result will be prefixed with // Return the name to use for a metadatabase. The result will be prefixed with
// "dbname". // "dbname".
extern std::string MetaDatabaseName(const std::string& dbname, uint64_t number); std::string MetaDatabaseName(const std::string& dbname, uint64_t number);
// Return the name of the Identity file which stores a unique number for the db // Return the name of the Identity file which stores a unique number for the db
// that will get regenerated if the db loses all its data and is recreated fresh // that will get regenerated if the db loses all its data and is recreated fresh
// either from a backup-image or empty // either from a backup-image or empty
extern std::string IdentityFileName(const std::string& dbname); std::string IdentityFileName(const std::string& dbname);
// If filename is a rocksdb file, store the type of the file in *type. // If filename is a rocksdb file, store the type of the file in *type.
// The number encoded in the filename is stored in *number. If the // The number encoded in the filename is stored in *number. If the
// filename was successfully parsed, returns true. Else return false. // filename was successfully parsed, returns true. Else return false.
// info_log_name_prefix is the path of info logs. // info_log_name_prefix is the path of info logs.
extern bool ParseFileName(const std::string& filename, uint64_t* number, bool ParseFileName(const std::string& filename, uint64_t* number,
const Slice& info_log_name_prefix, FileType* type, const Slice& info_log_name_prefix, FileType* type,
WalFileType* log_type = nullptr); WalFileType* log_type = nullptr);
// Same as previous function, but skip info log files. // Same as previous function, but skip info log files.
extern bool ParseFileName(const std::string& filename, uint64_t* number, bool ParseFileName(const std::string& filename, uint64_t* number,
FileType* type, WalFileType* log_type = nullptr); FileType* type, WalFileType* log_type = nullptr);
// Make the CURRENT file point to the descriptor file with the // Make the CURRENT file point to the descriptor file with the
// specified number. On its success and when dir_contains_current_file is not // specified number. On its success and when dir_contains_current_file is not
// nullptr, the function will fsync the directory containing the CURRENT file // nullptr, the function will fsync the directory containing the CURRENT file
// when // when
extern IOStatus SetCurrentFile(const WriteOptions& write_options, IOStatus SetCurrentFile(const WriteOptions& write_options, FileSystem* fs,
FileSystem* fs, const std::string& dbname, const std::string& dbname, uint64_t descriptor_number,
uint64_t descriptor_number,
FSDirectory* dir_contains_current_file); FSDirectory* dir_contains_current_file);
// Make the IDENTITY file for the db // Make the IDENTITY file for the db
extern Status SetIdentityFile(const WriteOptions& write_options, Env* env, Status SetIdentityFile(const WriteOptions& write_options, Env* env,
const std::string& dbname, const std::string& dbname,
const std::string& db_id = {}); const std::string& db_id = {});
// Sync manifest file `file`. // Sync manifest file `file`.
extern IOStatus SyncManifest(const ImmutableDBOptions* db_options, IOStatus SyncManifest(const ImmutableDBOptions* db_options,
const WriteOptions& write_options, const WriteOptions& write_options,
WritableFileWriter* file); WritableFileWriter* file);
@ -181,11 +177,10 @@ extern IOStatus SyncManifest(const ImmutableDBOptions* db_options,
// The list only contains file name. The parent directory name is stored // The list only contains file name. The parent directory name is stored
// in `parent_dir`. // in `parent_dir`.
// `db_log_dir` should be the one as in options.db_log_dir // `db_log_dir` should be the one as in options.db_log_dir
extern Status GetInfoLogFiles(const std::shared_ptr<FileSystem>& fs, Status GetInfoLogFiles(const std::shared_ptr<FileSystem>& fs,
const std::string& db_log_dir, const std::string& db_log_dir, const std::string& dbname,
const std::string& dbname,
std::string* parent_dir, std::string* parent_dir,
std::vector<std::string>* file_names); std::vector<std::string>* file_names);
extern std::string NormalizePath(const std::string& path); std::string NormalizePath(const std::string& path);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -21,7 +21,7 @@ namespace ROCKSDB_NAMESPACE {
// fname : the file name. // fname : the file name.
// result : output arg. A WritableFile based on `fname` returned. // result : output arg. A WritableFile based on `fname` returned.
// options : the Env Options. // options : the Env Options.
extern IOStatus NewWritableFile(FileSystem* fs, const std::string& fname, IOStatus NewWritableFile(FileSystem* fs, const std::string& fname,
std::unique_ptr<FSWritableFile>* result, std::unique_ptr<FSWritableFile>* result,
const FileOptions& options); const FileOptions& options);

View file

@ -497,7 +497,7 @@ struct HyperClockCacheOptions : public ShardedCacheOptions {
// has been removed. The new HyperClockCache requires an additional // has been removed. The new HyperClockCache requires an additional
// configuration parameter that is not provided by this API. This function // configuration parameter that is not provided by this API. This function
// simply returns a new LRUCache for functional compatibility. // simply returns a new LRUCache for functional compatibility.
extern std::shared_ptr<Cache> NewClockCache( std::shared_ptr<Cache> NewClockCache(
size_t capacity, int num_shard_bits = -1, size_t capacity, int num_shard_bits = -1,
bool strict_capacity_limit = false, bool strict_capacity_limit = false,
CacheMetadataChargePolicy metadata_charge_policy = CacheMetadataChargePolicy metadata_charge_policy =
@ -556,8 +556,7 @@ struct TieredCacheOptions {
std::shared_ptr<SecondaryCache> nvm_sec_cache; std::shared_ptr<SecondaryCache> nvm_sec_cache;
}; };
extern std::shared_ptr<Cache> NewTieredCache( std::shared_ptr<Cache> NewTieredCache(const TieredCacheOptions& cache_opts);
const TieredCacheOptions& cache_opts);
// EXPERIMENTAL // EXPERIMENTAL
// Dynamically update some of the parameters of a TieredCache. The input // Dynamically update some of the parameters of a TieredCache. The input
@ -568,7 +567,7 @@ extern std::shared_ptr<Cache> NewTieredCache(
// 2. Once the compressed secondary cache is disabled by setting the // 2. Once the compressed secondary cache is disabled by setting the
// compressed_secondary_ratio to 0.0, it cannot be dynamically re-enabled // compressed_secondary_ratio to 0.0, it cannot be dynamically re-enabled
// again // again
extern Status UpdateTieredCache( Status UpdateTieredCache(
const std::shared_ptr<Cache>& cache, int64_t total_capacity = -1, const std::shared_ptr<Cache>& cache, int64_t total_capacity = -1,
double compressed_secondary_ratio = std::numeric_limits<double>::max(), double compressed_secondary_ratio = std::numeric_limits<double>::max(),
TieredAdmissionPolicy adm_policy = TieredAdmissionPolicy::kAdmPolicyMax); TieredAdmissionPolicy adm_policy = TieredAdmissionPolicy::kAdmPolicyMax);

View file

@ -45,7 +45,7 @@ class ConcurrentTaskLimiter {
// @param limit: max concurrent tasks. // @param limit: max concurrent tasks.
// limit = 0 means no new task allowed. // limit = 0 means no new task allowed.
// limit < 0 means no limitation. // limit < 0 means no limitation.
extern ConcurrentTaskLimiter* NewConcurrentTaskLimiter(const std::string& name, ConcurrentTaskLimiter* NewConcurrentTaskLimiter(const std::string& name,
int32_t limit); int32_t limit);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -1302,63 +1302,60 @@ class DynamicLibrary {
virtual Status LoadSymbol(const std::string& sym_name, void** func) = 0; virtual Status LoadSymbol(const std::string& sym_name, void** func) = 0;
}; };
extern void LogFlush(const std::shared_ptr<Logger>& info_log); void LogFlush(const std::shared_ptr<Logger>& info_log);
extern void Log(const InfoLogLevel log_level, void Log(const InfoLogLevel log_level, const std::shared_ptr<Logger>& info_log,
const std::shared_ptr<Logger>& info_log, const char* format, const char* format, ...) ROCKSDB_PRINTF_FORMAT_ATTR(3, 4);
...) ROCKSDB_PRINTF_FORMAT_ATTR(3, 4);
// a set of log functions with different log levels. // a set of log functions with different log levels.
extern void Header(const std::shared_ptr<Logger>& info_log, const char* format, void Header(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Debug(const std::shared_ptr<Logger>& info_log, const char* format, void Debug(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Info(const std::shared_ptr<Logger>& info_log, const char* format, void Info(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Warn(const std::shared_ptr<Logger>& info_log, const char* format, void Warn(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Error(const std::shared_ptr<Logger>& info_log, const char* format, void Error(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Fatal(const std::shared_ptr<Logger>& info_log, const char* format, void Fatal(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
// Log the specified data to *info_log if info_log is non-nullptr. // Log the specified data to *info_log if info_log is non-nullptr.
// The default info log level is InfoLogLevel::INFO_LEVEL. // The default info log level is InfoLogLevel::INFO_LEVEL.
extern void Log(const std::shared_ptr<Logger>& info_log, const char* format, void Log(const std::shared_ptr<Logger>& info_log, const char* format, ...)
...) ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void LogFlush(Logger* info_log); void LogFlush(Logger* info_log);
extern void Log(const InfoLogLevel log_level, Logger* info_log, void Log(const InfoLogLevel log_level, Logger* info_log, const char* format,
const char* format, ...) ROCKSDB_PRINTF_FORMAT_ATTR(3, 4); ...) ROCKSDB_PRINTF_FORMAT_ATTR(3, 4);
// The default info log level is InfoLogLevel::INFO_LEVEL. // The default info log level is InfoLogLevel::INFO_LEVEL.
extern void Log(Logger* info_log, const char* format, ...) void Log(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
// a set of log functions with different log levels. // a set of log functions with different log levels.
extern void Header(Logger* info_log, const char* format, ...) void Header(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Debug(Logger* info_log, const char* format, ...) void Debug(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Info(Logger* info_log, const char* format, ...) void Info(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Warn(Logger* info_log, const char* format, ...) void Warn(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Error(Logger* info_log, const char* format, ...) void Error(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
extern void Fatal(Logger* info_log, const char* format, ...) void Fatal(Logger* info_log, const char* format, ...)
ROCKSDB_PRINTF_FORMAT_ATTR(2, 3); ROCKSDB_PRINTF_FORMAT_ATTR(2, 3);
// A utility routine: write "data" to the named file. // A utility routine: write "data" to the named file.
extern Status WriteStringToFile(Env* env, const Slice& data, Status WriteStringToFile(Env* env, const Slice& data, const std::string& fname,
const std::string& fname,
bool should_sync = false, bool should_sync = false,
const IOOptions* io_options = nullptr); const IOOptions* io_options = nullptr);
// A utility routine: read contents of named file into *data // A utility routine: read contents of named file into *data
extern Status ReadFileToString(Env* env, const std::string& fname, Status ReadFileToString(Env* env, const std::string& fname, std::string* data);
std::string* data);
// Below are helpers for wrapping most of the classes in this file. // Below are helpers for wrapping most of the classes in this file.
// They forward all calls to another instance of the class. // They forward all calls to another instance of the class.

View file

@ -131,7 +131,7 @@ class FileChecksumList {
}; };
// Create a new file checksum list. // Create a new file checksum list.
extern FileChecksumList* NewFileChecksumList(); FileChecksumList* NewFileChecksumList();
// Return a shared_ptr of the builtin Crc32c based file checksum generator // Return a shared_ptr of the builtin Crc32c based file checksum generator
// factory object, which can be shared to create the Crc32c based checksum // factory object, which can be shared to create the Crc32c based checksum

View file

@ -1916,13 +1916,12 @@ class FSDirectoryWrapper : public FSDirectory {
}; };
// A utility routine: write "data" to the named file. // A utility routine: write "data" to the named file.
extern IOStatus WriteStringToFile(FileSystem* fs, const Slice& data, IOStatus WriteStringToFile(FileSystem* fs, const Slice& data,
const std::string& fname, const std::string& fname, bool should_sync = false,
bool should_sync = false,
const IOOptions& io_options = IOOptions()); const IOOptions& io_options = IOOptions());
// A utility routine: read contents of named file into *data // A utility routine: read contents of named file into *data
extern IOStatus ReadFileToString(FileSystem* fs, const std::string& fname, IOStatus ReadFileToString(FileSystem* fs, const std::string& fname,
std::string* data); std::string* data);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -155,9 +155,9 @@ class Iterator : public Cleanable {
}; };
// Return an empty iterator (yields nothing). // Return an empty iterator (yields nothing).
extern Iterator* NewEmptyIterator(); Iterator* NewEmptyIterator();
// Return an empty iterator with the specified status. // Return an empty iterator with the specified status.
extern Iterator* NewErrorIterator(const Status& status); Iterator* NewErrorIterator(const Status& status);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -80,7 +80,7 @@ struct JemallocAllocatorOptions {
// (thread-local cache) is enabled to cache unused allocations for future use. // (thread-local cache) is enabled to cache unused allocations for future use.
// The tcache normally incurs 0.5M extra memory usage per-thread. The usage // The tcache normally incurs 0.5M extra memory usage per-thread. The usage
// can be reduced by limiting allocation sizes to cache. // can be reduced by limiting allocation sizes to cache.
extern Status NewJemallocNodumpAllocator( Status NewJemallocNodumpAllocator(
const JemallocAllocatorOptions& options, const JemallocAllocatorOptions& options,
std::shared_ptr<MemoryAllocator>* memory_allocator); std::shared_ptr<MemoryAllocator>* memory_allocator);

View file

@ -56,7 +56,7 @@ struct DBOptions;
using KeyHandle = void*; using KeyHandle = void*;
extern Slice GetLengthPrefixedSlice(const char* data); Slice GetLengthPrefixedSlice(const char* data);
class MemTableRep { class MemTableRep {
public: public:
@ -392,7 +392,7 @@ class VectorRepFactory : public MemTableRepFactory {
// skiplist_height: the max height of the skiplist // skiplist_height: the max height of the skiplist
// skiplist_branching_factor: probabilistic size ratio between adjacent // skiplist_branching_factor: probabilistic size ratio between adjacent
// link lists in the skiplist // link lists in the skiplist
extern MemTableRepFactory* NewHashSkipListRepFactory( MemTableRepFactory* NewHashSkipListRepFactory(
size_t bucket_count = 1000000, int32_t skiplist_height = 4, size_t bucket_count = 1000000, int32_t skiplist_height = 4,
int32_t skiplist_branching_factor = 4); int32_t skiplist_branching_factor = 4);
@ -412,7 +412,7 @@ extern MemTableRepFactory* NewHashSkipListRepFactory(
// entries when flushing. // entries when flushing.
// @threshold_use_skiplist: a bucket switches to skip list if number of // @threshold_use_skiplist: a bucket switches to skip list if number of
// entries exceed this parameter. // entries exceed this parameter.
extern MemTableRepFactory* NewHashLinkListRepFactory( MemTableRepFactory* NewHashLinkListRepFactory(
size_t bucket_count = 50000, size_t huge_page_tlb_size = 0, size_t bucket_count = 50000, size_t huge_page_tlb_size = 0,
int bucket_entries_logging_threshold = 4096, int bucket_entries_logging_threshold = 4096,
bool if_log_bucket_dist_when_flash = true, bool if_log_bucket_dist_when_flash = true,

View file

@ -1877,7 +1877,7 @@ struct FlushOptions {
}; };
// Create a Logger from provided DBOptions // Create a Logger from provided DBOptions
extern Status CreateLoggerFromOptions(const std::string& dbname, Status CreateLoggerFromOptions(const std::string& dbname,
const DBOptions& options, const DBOptions& options,
std::shared_ptr<Logger>* logger); std::shared_ptr<Logger>* logger);

View file

@ -159,7 +159,7 @@ class RateLimiter {
// @auto_tuned: Enables dynamic adjustment of rate limit within the range // @auto_tuned: Enables dynamic adjustment of rate limit within the range
// `[rate_bytes_per_sec / 20, rate_bytes_per_sec]`, according to // `[rate_bytes_per_sec / 20, rate_bytes_per_sec]`, according to
// the recent demand for background I/O. // the recent demand for background I/O.
extern RateLimiter* NewGenericRateLimiter( RateLimiter* NewGenericRateLimiter(
int64_t rate_bytes_per_sec, int64_t refill_period_us = 100 * 1000, int64_t rate_bytes_per_sec, int64_t refill_period_us = 100 * 1000,
int32_t fairness = 10, int32_t fairness = 10,
RateLimiter::Mode mode = RateLimiter::Mode::kWritesOnly, RateLimiter::Mode mode = RateLimiter::Mode::kWritesOnly,

View file

@ -123,13 +123,13 @@ class SliceTransform : public Customizable {
// The prefix is the first `prefix_len` bytes of the key, and keys shorter // The prefix is the first `prefix_len` bytes of the key, and keys shorter
// then `prefix_len` are not InDomain. // then `prefix_len` are not InDomain.
extern const SliceTransform* NewFixedPrefixTransform(size_t prefix_len); const SliceTransform* NewFixedPrefixTransform(size_t prefix_len);
// The prefix is the first min(length(key),`cap_len`) bytes of the key, and // The prefix is the first min(length(key),`cap_len`) bytes of the key, and
// all keys are InDomain. // all keys are InDomain.
extern const SliceTransform* NewCappedPrefixTransform(size_t cap_len); const SliceTransform* NewCappedPrefixTransform(size_t cap_len);
// Prefix is equal to key. All keys are InDomain. // Prefix is equal to key. All keys are InDomain.
extern const SliceTransform* NewNoopTransform(); const SliceTransform* NewNoopTransform();
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -117,17 +117,19 @@ class SstFileManager {
// `rate_bytes_per_sec` will be appreciated. NOTE that with this option, // `rate_bytes_per_sec` will be appreciated. NOTE that with this option,
// files already renamed as a trash may be partial, so users should not // files already renamed as a trash may be partial, so users should not
// directly recover them without checking. // directly recover them without checking.
extern SstFileManager* NewSstFileManager( SstFileManager* NewSstFileManager(Env* env, std::shared_ptr<FileSystem> fs,
Env* env, std::shared_ptr<FileSystem> fs,
std::shared_ptr<Logger> info_log = nullptr, std::shared_ptr<Logger> info_log = nullptr,
const std::string& trash_dir = "", int64_t rate_bytes_per_sec = 0, const std::string& trash_dir = "",
bool delete_existing_trash = true, Status* status = nullptr, int64_t rate_bytes_per_sec = 0,
bool delete_existing_trash = true,
Status* status = nullptr,
double max_trash_db_ratio = 0.25, double max_trash_db_ratio = 0.25,
uint64_t bytes_max_delete_chunk = 64 * 1024 * 1024); uint64_t bytes_max_delete_chunk = 64 * 1024 *
1024);
// Same as above, but takes a pointer to a legacy Env object, instead of // Same as above, but takes a pointer to a legacy Env object, instead of
// Env and FileSystem objects // Env and FileSystem objects
extern SstFileManager* NewSstFileManager( SstFileManager* NewSstFileManager(
Env* env, std::shared_ptr<Logger> info_log = nullptr, Env* env, std::shared_ptr<Logger> info_log = nullptr,
std::string trash_dir = "", int64_t rate_bytes_per_sec = 0, std::string trash_dir = "", int64_t rate_bytes_per_sec = 0,
bool delete_existing_trash = true, Status* status = nullptr, bool delete_existing_trash = true, Status* status = nullptr,

View file

@ -136,7 +136,7 @@ class SstPartitionerFixedPrefixFactory : public SstPartitionerFactory {
size_t len_; size_t len_;
}; };
extern std::shared_ptr<SstPartitionerFactory> std::shared_ptr<SstPartitionerFactory> NewSstPartitionerFixedPrefixFactory(
NewSstPartitionerFixedPrefixFactory(size_t prefix_len); size_t prefix_len);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -674,10 +674,9 @@ struct BlockBasedTablePropertyNames {
}; };
// Create default block based table factory. // Create default block based table factory.
extern TableFactory* NewBlockBasedTableFactory( TableFactory* NewBlockBasedTableFactory(
const BlockBasedTableOptions& table_options = BlockBasedTableOptions()); const BlockBasedTableOptions& table_options = BlockBasedTableOptions());
enum EncodingType : char { enum EncodingType : char {
// Always write full keys without any special encoding. // Always write full keys without any special encoding.
kPlain, kPlain,
@ -763,7 +762,7 @@ struct PlainTableOptions {
// the hash bucket found, a binary search is executed for hash conflicts. // the hash bucket found, a binary search is executed for hash conflicts.
// Finally, a linear search is used. // Finally, a linear search is used.
extern TableFactory* NewPlainTableFactory( TableFactory* NewPlainTableFactory(
const PlainTableOptions& options = PlainTableOptions()); const PlainTableOptions& options = PlainTableOptions());
struct CuckooTablePropertyNames { struct CuckooTablePropertyNames {
@ -830,10 +829,9 @@ struct CuckooTableOptions {
}; };
// Cuckoo Table Factory for SST table format using Cache Friendly Cuckoo Hashing // Cuckoo Table Factory for SST table format using Cache Friendly Cuckoo Hashing
extern TableFactory* NewCuckooTableFactory( TableFactory* NewCuckooTableFactory(
const CuckooTableOptions& table_options = CuckooTableOptions()); const CuckooTableOptions& table_options = CuckooTableOptions());
class RandomAccessFileReader; class RandomAccessFileReader;
// A base class for table factories. // A base class for table factories.
@ -923,11 +921,10 @@ class TableFactory : public Customizable {
// @plain_table_factory: plain table factory to use. If NULL, use a default one. // @plain_table_factory: plain table factory to use. If NULL, use a default one.
// @cuckoo_table_factory: cuckoo table factory to use. If NULL, use a default // @cuckoo_table_factory: cuckoo table factory to use. If NULL, use a default
// one. // one.
extern TableFactory* NewAdaptiveTableFactory( TableFactory* NewAdaptiveTableFactory(
std::shared_ptr<TableFactory> table_factory_to_write = nullptr, std::shared_ptr<TableFactory> table_factory_to_write = nullptr,
std::shared_ptr<TableFactory> block_based_table_factory = nullptr, std::shared_ptr<TableFactory> block_based_table_factory = nullptr,
std::shared_ptr<TableFactory> plain_table_factory = nullptr, std::shared_ptr<TableFactory> plain_table_factory = nullptr,
std::shared_ptr<TableFactory> cuckoo_table_factory = nullptr); std::shared_ptr<TableFactory> cuckoo_table_factory = nullptr);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -349,8 +349,8 @@ struct TableProperties {
// DEPRECATED: these properties now belong as TableProperties members. Please // DEPRECATED: these properties now belong as TableProperties members. Please
// use TableProperties::num_deletions and TableProperties::num_merge_operands, // use TableProperties::num_deletions and TableProperties::num_merge_operands,
// respectively. // respectively.
extern uint64_t GetDeletedKeys(const UserCollectedProperties& props); uint64_t GetDeletedKeys(const UserCollectedProperties& props);
extern uint64_t GetMergeOperands(const UserCollectedProperties& props, uint64_t GetMergeOperands(const UserCollectedProperties& props,
bool* property_present); bool* property_present);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -62,6 +62,6 @@ class ThreadPool {
// NewThreadPool() is a function that could be used to create a ThreadPool // NewThreadPool() is a function that could be used to create a ThreadPool
// with `num_threads` background threads. // with `num_threads` background threads.
extern ThreadPool* NewThreadPool(int num_threads); ThreadPool* NewThreadPool(int num_threads);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -34,11 +34,10 @@ class SimCache;
// BlockBasedTableOptions.block_size = 4096 by default but is configurable, // BlockBasedTableOptions.block_size = 4096 by default but is configurable,
// Therefore, generally the actual memory overhead of SimCache is Less than // Therefore, generally the actual memory overhead of SimCache is Less than
// sim_capacity * 2% // sim_capacity * 2%
extern std::shared_ptr<SimCache> NewSimCache(std::shared_ptr<Cache> cache, std::shared_ptr<SimCache> NewSimCache(std::shared_ptr<Cache> cache,
size_t sim_capacity, size_t sim_capacity, int num_shard_bits);
int num_shard_bits);
extern std::shared_ptr<SimCache> NewSimCache(std::shared_ptr<Cache> sim_cache, std::shared_ptr<SimCache> NewSimCache(std::shared_ptr<Cache> sim_cache,
std::shared_ptr<Cache> cache, std::shared_ptr<Cache> cache,
int num_shard_bits); int num_shard_bits);

View file

@ -80,9 +80,8 @@ class CompactOnDeletionCollectorFactory
// the specified number for "D" will not be changed. // the specified number for "D" will not be changed.
// @param deletion_ratio, if <= 0 or > 1, disable triggering compaction // @param deletion_ratio, if <= 0 or > 1, disable triggering compaction
// based on deletion ratio. Disabled by default. // based on deletion ratio. Disabled by default.
extern std::shared_ptr<CompactOnDeletionCollectorFactory> std::shared_ptr<CompactOnDeletionCollectorFactory>
NewCompactOnDeletionCollectorFactory(size_t sliding_window_size, NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
size_t deletion_trigger, size_t deletion_trigger,
double deletion_ratio = 0); double deletion_ratio = 0);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -49,9 +49,9 @@ class LogBuffer {
// Add log to the LogBuffer for a delayed info logging. It can be used when // Add log to the LogBuffer for a delayed info logging. It can be used when
// we want to add some logs inside a mutex. // we want to add some logs inside a mutex.
// max_log_size indicates maximize log size, including some metadata. // max_log_size indicates maximize log size, including some metadata.
extern void LogToBuffer(LogBuffer* log_buffer, size_t max_log_size, void LogToBuffer(LogBuffer* log_buffer, size_t max_log_size, const char* format,
const char* format, ...); ...);
// Same as previous function, but with default max log size. // Same as previous function, but with default max log size.
extern void LogToBuffer(LogBuffer* log_buffer, const char* format, ...); void LogToBuffer(LogBuffer* log_buffer, const char* format, ...);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -9,8 +9,8 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
static const uint32_t kFileReadSampleRate = 1024; static const uint32_t kFileReadSampleRate = 1024;
extern bool should_sample_file_read(); bool should_sample_file_read();
extern void sample_file_read_inc(FileMetaData*); void sample_file_read_inc(FileMetaData*);
inline bool should_sample_file_read() { inline bool should_sample_file_read() {
return (Random::GetTLSInstance()->Next() % kFileReadSampleRate == 307); return (Random::GetTLSInstance()->Next() % kFileReadSampleRate == 307);

View file

@ -65,8 +65,7 @@ std::unique_ptr<Configurable> CFOptionsAsConfigurable(
const ColumnFamilyOptions& opts, const ColumnFamilyOptions& opts,
const std::unordered_map<std::string, std::string>* opt_map = nullptr); const std::unordered_map<std::string, std::string>* opt_map = nullptr);
extern Status StringToMap( Status StringToMap(const std::string& opts_str,
const std::string& opts_str,
std::unordered_map<std::string, std::string>* opts_map); std::unordered_map<std::string, std::string>* opts_map);
struct OptionsHelper { struct OptionsHelper {

View file

@ -72,19 +72,19 @@ class CondVar {
// port::InitOnce(&init_control, &Initializer); // port::InitOnce(&init_control, &Initializer);
using OnceType = intptr_t; using OnceType = intptr_t;
#define LEVELDB_ONCE_INIT 0 #define LEVELDB_ONCE_INIT 0
extern void InitOnce(port::OnceType*, void (*initializer)()); void InitOnce(port::OnceType*, void (*initializer)());
// ------------------ Compression ------------------- // ------------------ Compression -------------------
// Store the snappy compression of "input[0,input_length-1]" in *output. // Store the snappy compression of "input[0,input_length-1]" in *output.
// Returns false if snappy is not supported by this port. // Returns false if snappy is not supported by this port.
extern bool Snappy_Compress(const char* input, size_t input_length, bool Snappy_Compress(const char* input, size_t input_length,
std::string* output); std::string* output);
// If input[0,input_length-1] looks like a valid snappy compressed // If input[0,input_length-1] looks like a valid snappy compressed
// buffer, store the size of the uncompressed data in *result and // buffer, store the size of the uncompressed data in *result and
// return true. Else return false. // return true. Else return false.
extern bool Snappy_GetUncompressedLength(const char* input, size_t length, bool Snappy_GetUncompressedLength(const char* input, size_t length,
size_t* result); size_t* result);
// Attempt to snappy uncompress input[0,input_length-1] into *output. // Attempt to snappy uncompress input[0,input_length-1] into *output.
@ -94,7 +94,7 @@ extern bool Snappy_GetUncompressedLength(const char* input, size_t length,
// REQUIRES: at least the first "n" bytes of output[] must be writable // REQUIRES: at least the first "n" bytes of output[] must be writable
// where "n" is the result of a successful call to // where "n" is the result of a successful call to
// Snappy_GetUncompressedLength. // Snappy_GetUncompressedLength.
extern bool Snappy_Uncompress(const char* input_data, size_t input_length, bool Snappy_Uncompress(const char* input_data, size_t input_length,
char* output); char* output);
} // namespace port } // namespace port

View file

@ -41,9 +41,9 @@ namespace ROCKSDB_NAMESPACE {
// build environment then this happens automatically; otherwise it's up to the // build environment then this happens automatically; otherwise it's up to the
// consumer to define the identifier. // consumer to define the identifier.
#ifdef ROCKSDB_DEFAULT_TO_ADAPTIVE_MUTEX #ifdef ROCKSDB_DEFAULT_TO_ADAPTIVE_MUTEX
extern const bool kDefaultToAdaptiveMutex = true; const bool kDefaultToAdaptiveMutex = true;
#else #else
extern const bool kDefaultToAdaptiveMutex = false; const bool kDefaultToAdaptiveMutex = false;
#endif #endif
namespace port { namespace port {

View file

@ -179,11 +179,11 @@ static inline void AsmVolatilePause() {
} }
// Returns -1 if not available on this platform // Returns -1 if not available on this platform
extern int PhysicalCoreID(); int PhysicalCoreID();
using OnceType = pthread_once_t; using OnceType = pthread_once_t;
#define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
extern void InitOnce(OnceType* once, void (*initializer)()); void InitOnce(OnceType* once, void (*initializer)());
#ifndef CACHE_LINE_SIZE #ifndef CACHE_LINE_SIZE
// To test behavior with non-native cache line size, e.g. for // To test behavior with non-native cache line size, e.g. for
@ -211,9 +211,9 @@ extern void InitOnce(OnceType* once, void (*initializer)());
static_assert((CACHE_LINE_SIZE & (CACHE_LINE_SIZE - 1)) == 0, static_assert((CACHE_LINE_SIZE & (CACHE_LINE_SIZE - 1)) == 0,
"Cache line size must be a power of 2 number of bytes"); "Cache line size must be a power of 2 number of bytes");
extern void* cacheline_aligned_alloc(size_t size); void* cacheline_aligned_alloc(size_t size);
extern void cacheline_aligned_free(void* memblock); void cacheline_aligned_free(void* memblock);
#if defined(__aarch64__) #if defined(__aarch64__)
// __builtin_prefetch(..., 1) turns into a prefetch into prfm pldl3keep. On // __builtin_prefetch(..., 1) turns into a prefetch into prfm pldl3keep. On
@ -226,15 +226,15 @@ extern void cacheline_aligned_free(void* memblock);
#define PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality) #define PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality)
#endif #endif
extern void Crash(const std::string& srcfile, int srcline); void Crash(const std::string& srcfile, int srcline);
extern int GetMaxOpenFiles(); int GetMaxOpenFiles();
extern const size_t kPageSize; extern const size_t kPageSize;
using ThreadId = pid_t; using ThreadId = pid_t;
extern void SetCpuPriority(ThreadId id, CpuPriority priority); void SetCpuPriority(ThreadId id, CpuPriority priority);
int64_t GetProcessID(); int64_t GetProcessID();

View file

@ -36,7 +36,7 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern const bool kDefaultToAdaptiveMutex = false; const bool kDefaultToAdaptiveMutex = false;
namespace port { namespace port {

View file

@ -213,7 +213,7 @@ struct OnceType {
}; };
#define LEVELDB_ONCE_INIT port::OnceType::Init() #define LEVELDB_ONCE_INIT port::OnceType::Init()
extern void InitOnce(OnceType* once, void (*initializer)()); void InitOnce(OnceType* once, void (*initializer)());
#ifndef CACHE_LINE_SIZE #ifndef CACHE_LINE_SIZE
#define CACHE_LINE_SIZE 64U #define CACHE_LINE_SIZE 64U
@ -253,7 +253,7 @@ static inline void AsmVolatilePause() {
// it would be nice to get "wfe" on ARM here // it would be nice to get "wfe" on ARM here
} }
extern int PhysicalCoreID(); int PhysicalCoreID();
// For Thread Local Storage abstraction // For Thread Local Storage abstraction
using pthread_key_t = DWORD; using pthread_key_t = DWORD;
@ -303,13 +303,13 @@ inline void* pthread_getspecific(pthread_key_t key) {
int truncate(const char* path, int64_t length); int truncate(const char* path, int64_t length);
int Truncate(std::string path, int64_t length); int Truncate(std::string path, int64_t length);
void Crash(const std::string& srcfile, int srcline); void Crash(const std::string& srcfile, int srcline);
extern int GetMaxOpenFiles(); int GetMaxOpenFiles();
std::string utf16_to_utf8(const std::wstring& utf16); std::string utf16_to_utf8(const std::wstring& utf16);
std::wstring utf8_to_utf16(const std::string& utf8); std::wstring utf8_to_utf16(const std::string& utf8);
using ThreadId = int; using ThreadId = int;
extern void SetCpuPriority(ThreadId id, CpuPriority priority); void SetCpuPriority(ThreadId id, CpuPriority priority);
int64_t GetProcessID(); int64_t GetProcessID();

View file

@ -34,12 +34,6 @@ AdaptiveTableFactory::AdaptiveTableFactory(
} }
} }
extern const uint64_t kPlainTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kCuckooTableMagicNumber;
Status AdaptiveTableFactory::NewTableReader( Status AdaptiveTableFactory::NewTableReader(
const ReadOptions& ro, const TableReaderOptions& table_reader_options, const ReadOptions& ro, const TableReaderOptions& table_reader_options,
std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size, std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
@ -112,7 +106,7 @@ std::string AdaptiveTableFactory::GetPrintableOptions() const {
return ret; return ret;
} }
extern TableFactory* NewAdaptiveTableFactory( TableFactory* NewAdaptiveTableFactory(
std::shared_ptr<TableFactory> table_factory_to_write, std::shared_ptr<TableFactory> table_factory_to_write,
std::shared_ptr<TableFactory> block_based_table_factory, std::shared_ptr<TableFactory> block_based_table_factory,
std::shared_ptr<TableFactory> plain_table_factory, std::shared_ptr<TableFactory> plain_table_factory,

View file

@ -15,7 +15,7 @@ namespace ROCKSDB_NAMESPACE {
class Footer; class Footer;
// Release the cached entry and decrement its ref count. // Release the cached entry and decrement its ref count.
extern void ForceReleaseCachedEntry(void* arg, void* h); void ForceReleaseCachedEntry(void* arg, void* h);
inline MemoryAllocator* GetMemoryAllocator( inline MemoryAllocator* GetMemoryAllocator(
const BlockBasedTableOptions& table_options) { const BlockBasedTableOptions& table_options) {
@ -30,8 +30,7 @@ inline MemoryAllocator* GetMemoryAllocator(
// //
// Returns Status::OK() on checksum match, or Status::Corruption() on checksum // Returns Status::OK() on checksum match, or Status::Corruption() on checksum
// mismatch. // mismatch.
extern Status VerifyBlockChecksum(const Footer& footer, const char* data, Status VerifyBlockChecksum(const Footer& footer, const char* data,
size_t block_size, size_t block_size, const std::string& file_name,
const std::string& file_name,
uint64_t offset); uint64_t offset);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -44,7 +44,7 @@ const std::string CuckooTablePropertyNames::kUserKeyLength =
"rocksdb.cuckoo.hash.userkeylength"; "rocksdb.cuckoo.hash.userkeylength";
// Obtained by running echo rocksdb.table.cuckoo | sha1sum // Obtained by running echo rocksdb.table.cuckoo | sha1sum
extern const uint64_t kCuckooTableMagicNumber = 0x926789d0c5f17873ull; const uint64_t kCuckooTableMagicNumber = 0x926789d0c5f17873ull;
CuckooTableBuilder::CuckooTableBuilder( CuckooTableBuilder::CuckooTableBuilder(
WritableFileWriter* file, double max_hash_table_ratio, WritableFileWriter* file, double max_hash_table_ratio,

View file

@ -38,11 +38,6 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
const char* kHostnameForDbHostId = "__hostname__"; const char* kHostnameForDbHostId = "__hostname__";
bool ShouldReportDetailedTime(Env* env, Statistics* stats) { bool ShouldReportDetailedTime(Env* env, Statistics* stats) {

View file

@ -34,6 +34,14 @@ bool ShouldReportDetailedTime(Env* env, Statistics* stats);
// the length of the magic number in bytes. // the length of the magic number in bytes.
constexpr uint32_t kMagicNumberLengthByte = 8; constexpr uint32_t kMagicNumberLengthByte = 8;
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
extern const uint64_t kCuckooTableMagicNumber;
// BlockHandle is a pointer to the extent of a file that stores a data // BlockHandle is a pointer to the extent of a file that stores a data
// block or a meta block. // block or a meta block.
class BlockHandle { class BlockHandle {

View file

@ -220,16 +220,15 @@ using InternalIterator = InternalIteratorBase<Slice>;
// Return an empty iterator (yields nothing). // Return an empty iterator (yields nothing).
template <class TValue = Slice> template <class TValue = Slice>
extern InternalIteratorBase<TValue>* NewEmptyInternalIterator(); InternalIteratorBase<TValue>* NewEmptyInternalIterator();
// Return an empty iterator with the specified status. // Return an empty iterator with the specified status.
template <class TValue = Slice> template <class TValue = Slice>
extern InternalIteratorBase<TValue>* NewErrorInternalIterator( InternalIteratorBase<TValue>* NewErrorInternalIterator(const Status& status);
const Status& status);
// Return an empty iterator with the specified status, allocated arena. // Return an empty iterator with the specified status, allocated arena.
template <class TValue = Slice> template <class TValue = Slice>
extern InternalIteratorBase<TValue>* NewErrorInternalIterator( InternalIteratorBase<TValue>* NewErrorInternalIterator(const Status& status,
const Status& status, Arena* arena); Arena* arena);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -214,6 +214,6 @@ using IteratorWrapper = IteratorWrapperBase<Slice>;
class Arena; class Arena;
// Return an empty iterator (yields nothing) allocated from arena. // Return an empty iterator (yields nothing) allocated from arena.
template <class TValue = Slice> template <class TValue = Slice>
extern InternalIteratorBase<TValue>* NewEmptyInternalIterator(Arena* arena); InternalIteratorBase<TValue>* NewEmptyInternalIterator(Arena* arena);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -32,9 +32,10 @@ using InternalIterator = InternalIteratorBase<Slice>;
// key is present in K child iterators, it will be yielded K times. // key is present in K child iterators, it will be yielded K times.
// //
// REQUIRES: n >= 0 // REQUIRES: n >= 0
extern InternalIterator* NewMergingIterator( InternalIterator* NewMergingIterator(const InternalKeyComparator* comparator,
const InternalKeyComparator* comparator, InternalIterator** children, int n, InternalIterator** children, int n,
Arena* arena = nullptr, bool prefix_seek_mode = false); Arena* arena = nullptr,
bool prefix_seek_mode = false);
// The iterator returned by NewMergingIterator() and // The iterator returned by NewMergingIterator() and
// MergeIteratorBuilder::Finish(). MergingIterator handles the merging of data // MergeIteratorBuilder::Finish(). MergingIterator handles the merging of data

View file

@ -52,8 +52,8 @@ IOStatus WriteBlock(const Slice& block_contents, WritableFileWriter* file,
// kPlainTableMagicNumber was picked by running // kPlainTableMagicNumber was picked by running
// echo rocksdb.table.plain | sha1sum // echo rocksdb.table.plain | sha1sum
// and taking the leading 64 bits. // and taking the leading 64 bits.
extern const uint64_t kPlainTableMagicNumber = 0x8242229663bf9564ull; const uint64_t kPlainTableMagicNumber = 0x8242229663bf9564ull;
extern const uint64_t kLegacyPlainTableMagicNumber = 0x4f3418eb7a8f13b8ull; const uint64_t kLegacyPlainTableMagicNumber = 0x4f3418eb7a8f13b8ull;
PlainTableBuilder::PlainTableBuilder( PlainTableBuilder::PlainTableBuilder(
const ImmutableOptions& ioptions, const MutableCFOptions& moptions, const ImmutableOptions& ioptions, const MutableCFOptions& moptions,

View file

@ -279,7 +279,7 @@ Status GetPlainTableOptionsFromMap(
return s; return s;
} }
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) { TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
return new PlainTableFactory(options); return new PlainTableFactory(options);
} }

View file

@ -87,7 +87,6 @@ class PlainTableIterator : public InternalIterator {
Status status_; Status status_;
}; };
extern const uint64_t kPlainTableMagicNumber;
PlainTableReader::PlainTableReader( PlainTableReader::PlainTableReader(
const ImmutableOptions& ioptions, const ImmutableOptions& ioptions,
std::unique_ptr<RandomAccessFileReader>&& file, std::unique_ptr<RandomAccessFileReader>&& file,

View file

@ -68,12 +68,6 @@ SstFileDumper::SstFileDumper(const Options& options,
init_result_ = GetTableReader(file_name_); init_result_ = GetTableReader(file_name_);
} }
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kCuckooTableMagicNumber;
const char* testFileName = "test_file_name"; const char* testFileName = "test_file_name";
Status SstFileDumper::GetTableReader(const std::string& file_path) { Status SstFileDumper::GetTableReader(const std::string& file_path) {

View file

@ -79,11 +79,6 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
namespace { namespace {
const std::string kDummyValue(10000, 'o'); const std::string kDummyValue(10000, 'o');

View file

@ -36,7 +36,7 @@ struct TwoLevelIteratorState {
// Uses a supplied function to convert an index_iter value into // Uses a supplied function to convert an index_iter value into
// an iterator over the contents of the corresponding block. // an iterator over the contents of the corresponding block.
// Note: this function expects first_level_iter was not created using the arena // Note: this function expects first_level_iter was not created using the arena
extern InternalIteratorBase<IndexValue>* NewTwoLevelIterator( InternalIteratorBase<IndexValue>* NewTwoLevelIterator(
TwoLevelIteratorState* state, TwoLevelIteratorState* state,
InternalIteratorBase<IndexValue>* first_level_iter); InternalIteratorBase<IndexValue>* first_level_iter);

View file

@ -91,8 +91,8 @@ bool ShouldPersistUDT(const UserDefinedTimestampTestMode& test_mode) {
return test_mode != UserDefinedTimestampTestMode::kStripUserDefinedTimestamp; return test_mode != UserDefinedTimestampTestMode::kStripUserDefinedTimestamp;
} }
extern Slice CompressibleString(Random* rnd, double compressed_fraction, Slice CompressibleString(Random* rnd, double compressed_fraction, int len,
int len, std::string* dst) { std::string* dst) {
int raw = static_cast<int>(len * compressed_fraction); int raw = static_cast<int>(len * compressed_fraction);
if (raw < 1) { if (raw < 1) {
raw = 1; raw = 1;

View file

@ -49,7 +49,7 @@ extern const std::set<uint32_t> kFooterFormatVersionsToTest;
// Return a random key with the specified length that may contain interesting // Return a random key with the specified length that may contain interesting
// characters (e.g. \x00, \xff, etc.). // characters (e.g. \x00, \xff, etc.).
enum RandomKeyType : char { RANDOM, LARGEST, SMALLEST, MIDDLE }; enum RandomKeyType : char { RANDOM, LARGEST, SMALLEST, MIDDLE };
extern std::string RandomKey(Random* rnd, int len, std::string RandomKey(Random* rnd, int len,
RandomKeyType type = RandomKeyType::RANDOM); RandomKeyType type = RandomKeyType::RANDOM);
enum class UserDefinedTimestampTestMode { enum class UserDefinedTimestampTestMode {
@ -62,17 +62,17 @@ enum class UserDefinedTimestampTestMode {
kStripUserDefinedTimestamp, kStripUserDefinedTimestamp,
}; };
extern const std::vector<UserDefinedTimestampTestMode>& GetUDTTestModes(); const std::vector<UserDefinedTimestampTestMode>& GetUDTTestModes();
extern bool IsUDTEnabled(const UserDefinedTimestampTestMode& test_mode); bool IsUDTEnabled(const UserDefinedTimestampTestMode& test_mode);
extern bool ShouldPersistUDT(const UserDefinedTimestampTestMode& test_mode); bool ShouldPersistUDT(const UserDefinedTimestampTestMode& test_mode);
// Store in *dst a string of length "len" that will compress to // Store in *dst a string of length "len" that will compress to
// "N*compressed_fraction" bytes and return a Slice that references // "N*compressed_fraction" bytes and return a Slice that references
// the generated data. // the generated data.
extern Slice CompressibleString(Random* rnd, double compressed_fraction, Slice CompressibleString(Random* rnd, double compressed_fraction, int len,
int len, std::string* dst); std::string* dst);
#ifndef NDEBUG #ifndef NDEBUG
// An internal comparator that just forward comparing results from the // An internal comparator that just forward comparing results from the
@ -127,13 +127,13 @@ class SimpleSuffixReverseComparator : public Comparator {
// at once. Assumes same endian-ness is used though the database's lifetime. // at once. Assumes same endian-ness is used though the database's lifetime.
// Symantics of comparison would differ from Bytewise comparator in little // Symantics of comparison would differ from Bytewise comparator in little
// endian machines. // endian machines.
extern const Comparator* Uint64Comparator(); const Comparator* Uint64Comparator();
// A wrapper api for getting the ComparatorWithU64Ts<BytewiseComparator> // A wrapper api for getting the ComparatorWithU64Ts<BytewiseComparator>
extern const Comparator* BytewiseComparatorWithU64TsWrapper(); const Comparator* BytewiseComparatorWithU64TsWrapper();
// A wrapper api for getting the ComparatorWithU64Ts<ReverseBytewiseComparator> // A wrapper api for getting the ComparatorWithU64Ts<ReverseBytewiseComparator>
extern const Comparator* ReverseBytewiseComparatorWithU64TsWrapper(); const Comparator* ReverseBytewiseComparatorWithU64TsWrapper();
class StringSink : public FSWritableFile { class StringSink : public FSWritableFile {
public: public:
@ -364,13 +364,12 @@ class NullLogger : public Logger {
}; };
// Corrupts key by changing the type // Corrupts key by changing the type
extern void CorruptKeyType(InternalKey* ikey); void CorruptKeyType(InternalKey* ikey);
extern std::string KeyStr(const std::string& user_key, std::string KeyStr(const std::string& user_key, const SequenceNumber& seq,
const SequenceNumber& seq, const ValueType& t, const ValueType& t, bool corrupt = false);
bool corrupt = false);
extern std::string KeyStr(uint64_t ts, const std::string& user_key, std::string KeyStr(uint64_t ts, const std::string& user_key,
const SequenceNumber& seq, const ValueType& t, const SequenceNumber& seq, const ValueType& t,
bool corrupt = false); bool corrupt = false);
@ -831,7 +830,7 @@ class ChanglingCompactionFilterFactory : public CompactionFilterFactory {
// The factory for the hacky skip list mem table that triggers flush after // The factory for the hacky skip list mem table that triggers flush after
// number of entries exceeds a threshold. // number of entries exceeds a threshold.
extern MemTableRepFactory* NewSpecialSkipListFactory(int num_entries_per_flush); MemTableRepFactory* NewSpecialSkipListFactory(int num_entries_per_flush);
CompressionType RandomCompressionType(Random* rnd); CompressionType RandomCompressionType(Random* rnd);

View file

@ -34,40 +34,38 @@ namespace ROCKSDB_NAMESPACE {
const uint32_t kMaxVarint64Length = 10; const uint32_t kMaxVarint64Length = 10;
// Standard Put... routines append to a string // Standard Put... routines append to a string
extern void PutFixed16(std::string* dst, uint16_t value); void PutFixed16(std::string* dst, uint16_t value);
extern void PutFixed32(std::string* dst, uint32_t value); void PutFixed32(std::string* dst, uint32_t value);
extern void PutFixed64(std::string* dst, uint64_t value); void PutFixed64(std::string* dst, uint64_t value);
extern void PutVarint32(std::string* dst, uint32_t value); void PutVarint32(std::string* dst, uint32_t value);
extern void PutVarint32Varint32(std::string* dst, uint32_t value1, void PutVarint32Varint32(std::string* dst, uint32_t value1, uint32_t value2);
uint32_t value2); void PutVarint32Varint32Varint32(std::string* dst, uint32_t value1,
extern void PutVarint32Varint32Varint32(std::string* dst, uint32_t value1,
uint32_t value2, uint32_t value3); uint32_t value2, uint32_t value3);
extern void PutVarint64(std::string* dst, uint64_t value); void PutVarint64(std::string* dst, uint64_t value);
extern void PutVarint64Varint64(std::string* dst, uint64_t value1, void PutVarint64Varint64(std::string* dst, uint64_t value1, uint64_t value2);
uint64_t value2); void PutVarint32Varint64(std::string* dst, uint32_t value1, uint64_t value2);
extern void PutVarint32Varint64(std::string* dst, uint32_t value1, void PutVarint32Varint32Varint64(std::string* dst, uint32_t value1,
uint64_t value2);
extern void PutVarint32Varint32Varint64(std::string* dst, uint32_t value1,
uint32_t value2, uint64_t value3); uint32_t value2, uint64_t value3);
extern void PutLengthPrefixedSlice(std::string* dst, const Slice& value); void PutLengthPrefixedSlice(std::string* dst, const Slice& value);
extern void PutLengthPrefixedSliceParts(std::string* dst, void PutLengthPrefixedSliceParts(std::string* dst,
const SliceParts& slice_parts); const SliceParts& slice_parts);
extern void PutLengthPrefixedSlicePartsWithPadding( void PutLengthPrefixedSlicePartsWithPadding(std::string* dst,
std::string* dst, const SliceParts& slice_parts, size_t pad_sz); const SliceParts& slice_parts,
size_t pad_sz);
// Standard Get... routines parse a value from the beginning of a Slice // Standard Get... routines parse a value from the beginning of a Slice
// and advance the slice past the parsed value. // and advance the slice past the parsed value.
extern bool GetFixed64(Slice* input, uint64_t* value); bool GetFixed64(Slice* input, uint64_t* value);
extern bool GetFixed32(Slice* input, uint32_t* value); bool GetFixed32(Slice* input, uint32_t* value);
extern bool GetFixed16(Slice* input, uint16_t* value); bool GetFixed16(Slice* input, uint16_t* value);
extern bool GetVarint32(Slice* input, uint32_t* value); bool GetVarint32(Slice* input, uint32_t* value);
extern bool GetVarint64(Slice* input, uint64_t* value); bool GetVarint64(Slice* input, uint64_t* value);
extern bool GetVarsignedint64(Slice* input, int64_t* value); bool GetVarsignedint64(Slice* input, int64_t* value);
extern bool GetLengthPrefixedSlice(Slice* input, Slice* result); bool GetLengthPrefixedSlice(Slice* input, Slice* result);
// This function assumes data is well-formed. // This function assumes data is well-formed.
extern Slice GetLengthPrefixedSlice(const char* data); Slice GetLengthPrefixedSlice(const char* data);
extern Slice GetSliceUntil(Slice* slice, char delimiter); Slice GetSliceUntil(Slice* slice, char delimiter);
// Borrowed from // Borrowed from
// https://github.com/facebook/fbthrift/blob/449a5f77f9f9bae72c9eb5e78093247eef185c04/thrift/lib/cpp/util/VarintUtils-inl.h#L202-L208 // https://github.com/facebook/fbthrift/blob/449a5f77f9f9bae72c9eb5e78093247eef185c04/thrift/lib/cpp/util/VarintUtils-inl.h#L202-L208
@ -82,10 +80,8 @@ inline int64_t zigzagToI64(uint64_t n) {
// in *v and return a pointer just past the parsed value, or return // in *v and return a pointer just past the parsed value, or return
// nullptr on error. These routines only look at bytes in the range // nullptr on error. These routines only look at bytes in the range
// [p..limit-1] // [p..limit-1]
extern const char* GetVarint32Ptr(const char* p, const char* limit, const char* GetVarint32Ptr(const char* p, const char* limit, uint32_t* v);
uint32_t* v); const char* GetVarint64Ptr(const char* p, const char* limit, uint64_t* v);
extern const char* GetVarint64Ptr(const char* p, const char* limit,
uint64_t* v);
inline const char* GetVarsignedint64Ptr(const char* p, const char* limit, inline const char* GetVarsignedint64Ptr(const char* p, const char* limit,
int64_t* value) { int64_t* value) {
uint64_t u = 0; uint64_t u = 0;
@ -95,16 +91,16 @@ inline const char* GetVarsignedint64Ptr(const char* p, const char* limit,
} }
// Returns the length of the varint32 or varint64 encoding of "v" // Returns the length of the varint32 or varint64 encoding of "v"
extern int VarintLength(uint64_t v); int VarintLength(uint64_t v);
// Lower-level versions of Put... that write directly into a character buffer // Lower-level versions of Put... that write directly into a character buffer
// and return a pointer just past the last byte written. // and return a pointer just past the last byte written.
// REQUIRES: dst has enough space for the value being written // REQUIRES: dst has enough space for the value being written
extern char* EncodeVarint32(char* dst, uint32_t value); char* EncodeVarint32(char* dst, uint32_t value);
extern char* EncodeVarint64(char* dst, uint64_t value); char* EncodeVarint64(char* dst, uint64_t value);
// Internal routine for use by fallback path of GetVarint32Ptr // Internal routine for use by fallback path of GetVarint32Ptr
extern const char* GetVarint32PtrFallback(const char* p, const char* limit, const char* GetVarint32PtrFallback(const char* p, const char* limit,
uint32_t* value); uint32_t* value);
inline const char* GetVarint32Ptr(const char* p, const char* limit, inline const char* GetVarint32Ptr(const char* p, const char* limit,
uint32_t* value) { uint32_t* value) {

View file

@ -18,18 +18,18 @@
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
namespace crc32c { namespace crc32c {
extern std::string IsFastCrc32Supported(); std::string IsFastCrc32Supported();
// Return the crc32c of concat(A, data[0,n-1]) where init_crc is the // Return the crc32c of concat(A, data[0,n-1]) where init_crc is the
// crc32c of some string A. Extend() is often used to maintain the // crc32c of some string A. Extend() is often used to maintain the
// crc32c of a stream of data. // crc32c of a stream of data.
extern uint32_t Extend(uint32_t init_crc, const char* data, size_t n); uint32_t Extend(uint32_t init_crc, const char* data, size_t n);
// Takes two unmasked crc32c values, and the length of the string from // Takes two unmasked crc32c values, and the length of the string from
// which `crc2` was computed, and computes a crc32c value for the // which `crc2` was computed, and computes a crc32c value for the
// concatenation of the original two input strings. Running time is // concatenation of the original two input strings. Running time is
// ~ log(crc2len). // ~ log(crc2len).
extern uint32_t Crc32cCombine(uint32_t crc1, uint32_t crc2, size_t crc2len); uint32_t Crc32cCombine(uint32_t crc1, uint32_t crc2, size_t crc2len);
// Return the crc32c of data[0,n-1] // Return the crc32c of data[0,n-1]
inline uint32_t Value(const char* data, size_t n) { return Extend(0, data, n); } inline uint32_t Value(const char* data, size_t n) { return Extend(0, data, n); }

View file

@ -36,10 +36,9 @@
PREF4X64L1(buffer, (PREF_OFFSET), 8) \ PREF4X64L1(buffer, (PREF_OFFSET), 8) \
PREF4X64L1(buffer, (PREF_OFFSET), 12) PREF4X64L1(buffer, (PREF_OFFSET), 12)
extern uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, uint32_t crc32c_arm64(uint32_t crc, unsigned char const *data, size_t len);
size_t len); uint32_t crc32c_runtime_check(void);
extern uint32_t crc32c_runtime_check(void); bool crc32c_pmull_runtime_check(void);
extern bool crc32c_pmull_runtime_check(void);
#ifdef __ARM_FEATURE_CRYPTO #ifdef __ARM_FEATURE_CRYPTO
#define HAVE_ARM64_CRYPTO #define HAVE_ARM64_CRYPTO

View file

@ -14,8 +14,7 @@
extern "C" { extern "C" {
#endif #endif
extern uint32_t crc32c_ppc(uint32_t crc, unsigned char const *buffer, uint32_t crc32c_ppc(uint32_t crc, unsigned char const *buffer, size_t len);
size_t len);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -31,10 +31,10 @@ namespace ROCKSDB_NAMESPACE {
// Hash(), especially for inputs > 24 bytes. // Hash(), especially for inputs > 24 bytes.
// KNOWN FLAW: incrementing seed by 1 might not give sufficiently independent // KNOWN FLAW: incrementing seed by 1 might not give sufficiently independent
// results from previous seed. Recommend incrementing by a large odd number. // results from previous seed. Recommend incrementing by a large odd number.
extern uint64_t Hash64(const char* data, size_t n, uint64_t seed); uint64_t Hash64(const char* data, size_t n, uint64_t seed);
// Specific optimization without seed (same as seed = 0) // Specific optimization without seed (same as seed = 0)
extern uint64_t Hash64(const char* data, size_t n); uint64_t Hash64(const char* data, size_t n);
// Non-persistent hash. Must only used for in-memory data structures. // Non-persistent hash. Must only used for in-memory data structures.
// The hash results are thus subject to change between releases, // The hash results are thus subject to change between releases,
@ -87,7 +87,7 @@ void BijectiveUnhash2x64(uint64_t in_high64, uint64_t in_low64, uint64_t seed,
// TODO: consider rename to Hash32 // TODO: consider rename to Hash32
// KNOWN FLAW: incrementing seed by 1 might not give sufficiently independent // KNOWN FLAW: incrementing seed by 1 might not give sufficiently independent
// results from previous seed. Recommend pseudorandom or hashed seeds. // results from previous seed. Recommend pseudorandom or hashed seeds.
extern uint32_t Hash(const char* data, size_t n, uint32_t seed); uint32_t Hash(const char* data, size_t n, uint32_t seed);
// TODO: consider rename to LegacyBloomHash32 // TODO: consider rename to LegacyBloomHash32
inline uint32_t BloomHash(const Slice& key) { inline uint32_t BloomHash(const Slice& key) {
@ -111,7 +111,7 @@ inline uint64_t GetSliceNPHash64(const Slice& s, uint64_t seed) {
// Similar to `GetSliceNPHash64()` with `seed`, but input comes from // Similar to `GetSliceNPHash64()` with `seed`, but input comes from
// concatenation of `Slice`s in `data`. // concatenation of `Slice`s in `data`.
extern uint64_t GetSlicePartsNPHash64(const SliceParts& data, uint64_t seed); uint64_t GetSlicePartsNPHash64(const SliceParts& data, uint64_t seed);
inline size_t GetSliceRangedNPHash(const Slice& s, size_t range) { inline size_t GetSliceRangedNPHash(const Slice& s, size_t range) {
return FastRange64(NPHash64(s.data(), s.size()), range); return FastRange64(NPHash64(s.data(), s.size()), range);

View file

@ -18,14 +18,14 @@ namespace ROCKSDB_NAMESPACE {
class Slice; class Slice;
extern std::vector<std::string> StringSplit(const std::string& arg, char delim); std::vector<std::string> StringSplit(const std::string& arg, char delim);
// Append a human-readable printout of "num" to *str // Append a human-readable printout of "num" to *str
extern void AppendNumberTo(std::string* str, uint64_t num); void AppendNumberTo(std::string* str, uint64_t num);
// Append a human-readable printout of "value" to *str. // Append a human-readable printout of "value" to *str.
// Escapes any non-printable characters found in "value". // Escapes any non-printable characters found in "value".
extern void AppendEscapedStringTo(std::string* str, const Slice& value); void AppendEscapedStringTo(std::string* str, const Slice& value);
// Put n digits from v in base kBase to (*buf)[0] to (*buf)[n-1] and // Put n digits from v in base kBase to (*buf)[0] to (*buf)[n-1] and
// advance *buf to the position after what was written. // advance *buf to the position after what was written.
@ -73,15 +73,15 @@ inline bool ParseBaseChars(const char** buf, size_t n, uint64_t* v) {
// for num >= 10.000, prints "xxK" // for num >= 10.000, prints "xxK"
// for num >= 10.000.000, prints "xxM" // for num >= 10.000.000, prints "xxM"
// for num >= 10.000.000.000, prints "xxG" // for num >= 10.000.000.000, prints "xxG"
extern std::string NumberToHumanString(int64_t num); std::string NumberToHumanString(int64_t num);
// Return a human-readable version of bytes // Return a human-readable version of bytes
// ex: 1048576 -> 1.00 GB // ex: 1048576 -> 1.00 GB
extern std::string BytesToHumanString(uint64_t bytes); std::string BytesToHumanString(uint64_t bytes);
// Return a human-readable version of unix time // Return a human-readable version of unix time
// ex: 1562116015 -> "Tue Jul 2 18:06:55 2019" // ex: 1562116015 -> "Tue Jul 2 18:06:55 2019"
extern std::string TimeToHumanString(int unixtime); std::string TimeToHumanString(int unixtime);
// Append a human-readable time in micros. // Append a human-readable time in micros.
int AppendHumanMicros(uint64_t micros, char* output, int len, int AppendHumanMicros(uint64_t micros, char* output, int len,
@ -92,13 +92,13 @@ int AppendHumanBytes(uint64_t bytes, char* output, int len);
// Return a human-readable version of "value". // Return a human-readable version of "value".
// Escapes any non-printable characters found in "value". // Escapes any non-printable characters found in "value".
extern std::string EscapeString(const Slice& value); std::string EscapeString(const Slice& value);
// Parse a human-readable number from "*in" into *value. On success, // Parse a human-readable number from "*in" into *value. On success,
// advances "*in" past the consumed number and sets "*val" to the // advances "*in" past the consumed number and sets "*val" to the
// numeric value. Otherwise, returns false and leaves *in in an // numeric value. Otherwise, returns false and leaves *in in an
// unspecified state. // unspecified state.
extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val); bool ConsumeDecimalNumber(Slice* in, uint64_t* val);
// Returns true if the input char "c" is considered as a special character // Returns true if the input char "c" is considered as a special character
// that will be escaped when EscapeOptionString() is called. // that will be escaped when EscapeOptionString() is called.
@ -180,6 +180,6 @@ extern const std::string kNullptrString;
// errnoStr() function returns a string that describes the error code passed in // errnoStr() function returns a string that describes the error code passed in
// the argument err // the argument err
extern std::string errnoStr(int err); std::string errnoStr(int err);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View file

@ -44,6 +44,6 @@ class AggMergeOperator : public MergeOperator {
static Accumulator& GetTLSAccumulator(); static Accumulator& GetTLSAccumulator();
}; };
extern std::string EncodeAggFuncAndPayloadNoCheck(const Slice& function_name, std::string EncodeAggFuncAndPayloadNoCheck(const Slice& function_name,
const Slice& value); const Slice& value);
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE