mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Update src/rocksdb2 to rocksdb-3.5.1:
Merge commit 'c168d54495d7d7b84639514f6443ad99b89ce996' into develop
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#include "table/two_level_iterator.h"
|
||||
#include "table/plain_table_factory.h"
|
||||
#include "table/plain_table_key_coding.h"
|
||||
#include "table/get_context.h"
|
||||
|
||||
#include "util/arena.h"
|
||||
#include "util/coding.h"
|
||||
@@ -88,7 +87,7 @@ class PlainTableIterator : public Iterator {
|
||||
};
|
||||
|
||||
extern const uint64_t kPlainTableMagicNumber;
|
||||
PlainTableReader::PlainTableReader(const ImmutableCFOptions& ioptions,
|
||||
PlainTableReader::PlainTableReader(const Options& options,
|
||||
unique_ptr<RandomAccessFile>&& file,
|
||||
const EnvOptions& storage_options,
|
||||
const InternalKeyComparator& icomparator,
|
||||
@@ -100,10 +99,10 @@ PlainTableReader::PlainTableReader(const ImmutableCFOptions& ioptions,
|
||||
full_scan_mode_(false),
|
||||
data_end_offset_(table_properties->data_size),
|
||||
user_key_len_(table_properties->fixed_key_len),
|
||||
prefix_extractor_(ioptions.prefix_extractor),
|
||||
prefix_extractor_(options.prefix_extractor.get()),
|
||||
enable_bloom_(false),
|
||||
bloom_(6, nullptr),
|
||||
ioptions_(ioptions),
|
||||
options_(options),
|
||||
file_(std::move(file)),
|
||||
file_size_(file_size),
|
||||
table_properties_(nullptr) {}
|
||||
@@ -111,8 +110,8 @@ PlainTableReader::PlainTableReader(const ImmutableCFOptions& ioptions,
|
||||
PlainTableReader::~PlainTableReader() {
|
||||
}
|
||||
|
||||
Status PlainTableReader::Open(const ImmutableCFOptions& ioptions,
|
||||
const EnvOptions& env_options,
|
||||
Status PlainTableReader::Open(const Options& options,
|
||||
const EnvOptions& soptions,
|
||||
const InternalKeyComparator& internal_comparator,
|
||||
unique_ptr<RandomAccessFile>&& file,
|
||||
uint64_t file_size,
|
||||
@@ -120,14 +119,14 @@ Status PlainTableReader::Open(const ImmutableCFOptions& ioptions,
|
||||
const int bloom_bits_per_key,
|
||||
double hash_table_ratio, size_t index_sparseness,
|
||||
size_t huge_page_tlb_size, bool full_scan_mode) {
|
||||
assert(ioptions.allow_mmap_reads);
|
||||
assert(options.allow_mmap_reads);
|
||||
if (file_size > PlainTableIndex::kMaxFileSize) {
|
||||
return Status::NotSupported("File is too large for PlainTableReader!");
|
||||
}
|
||||
|
||||
TableProperties* props = nullptr;
|
||||
auto s = ReadTableProperties(file.get(), file_size, kPlainTableMagicNumber,
|
||||
ioptions.env, ioptions.info_log, &props);
|
||||
options.env, options.info_log.get(), &props);
|
||||
if (!s.ok()) {
|
||||
return s;
|
||||
}
|
||||
@@ -138,12 +137,12 @@ Status PlainTableReader::Open(const ImmutableCFOptions& ioptions,
|
||||
user_props.find(PlainTablePropertyNames::kPrefixExtractorName);
|
||||
|
||||
if (!full_scan_mode && prefix_extractor_in_file != user_props.end()) {
|
||||
if (!ioptions.prefix_extractor) {
|
||||
if (!options.prefix_extractor) {
|
||||
return Status::InvalidArgument(
|
||||
"Prefix extractor is missing when opening a PlainTable built "
|
||||
"using a prefix extractor");
|
||||
} else if (prefix_extractor_in_file->second.compare(
|
||||
ioptions.prefix_extractor->Name()) != 0) {
|
||||
options.prefix_extractor->Name()) != 0) {
|
||||
return Status::InvalidArgument(
|
||||
"Prefix extractor given doesn't match the one used to build "
|
||||
"PlainTable");
|
||||
@@ -159,8 +158,8 @@ Status PlainTableReader::Open(const ImmutableCFOptions& ioptions,
|
||||
}
|
||||
|
||||
std::unique_ptr<PlainTableReader> new_reader(new PlainTableReader(
|
||||
ioptions, std::move(file), env_options, internal_comparator,
|
||||
encoding_type, file_size, props));
|
||||
options, std::move(file), soptions, internal_comparator, encoding_type,
|
||||
file_size, props));
|
||||
|
||||
s = new_reader->MmapDataFile();
|
||||
if (!s.ok()) {
|
||||
@@ -208,7 +207,7 @@ Status PlainTableReader::PopulateIndexRecordList(
|
||||
bool is_first_record = true;
|
||||
Slice key_prefix_slice;
|
||||
PlainTableKeyDecoder decoder(encoding_type_, user_key_len_,
|
||||
ioptions_.prefix_extractor);
|
||||
options_.prefix_extractor.get());
|
||||
while (pos < data_end_offset_) {
|
||||
uint32_t key_offset = pos;
|
||||
ParsedInternalKey key;
|
||||
@@ -253,8 +252,8 @@ void PlainTableReader::AllocateAndFillBloom(int bloom_bits_per_key,
|
||||
uint32_t bloom_total_bits = num_prefixes * bloom_bits_per_key;
|
||||
if (bloom_total_bits > 0) {
|
||||
enable_bloom_ = true;
|
||||
bloom_.SetTotalBits(&arena_, bloom_total_bits, ioptions_.bloom_locality,
|
||||
huge_page_tlb_size, ioptions_.info_log);
|
||||
bloom_.SetTotalBits(&arena_, bloom_total_bits, options_.bloom_locality,
|
||||
huge_page_tlb_size, options_.info_log.get());
|
||||
FillBloom(prefix_hashes);
|
||||
}
|
||||
}
|
||||
@@ -282,14 +281,14 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
|
||||
|
||||
BlockContents bloom_block_contents;
|
||||
auto s = ReadMetaBlock(file_.get(), file_size_, kPlainTableMagicNumber,
|
||||
ioptions_.env, BloomBlockBuilder::kBloomBlock,
|
||||
options_.env, BloomBlockBuilder::kBloomBlock,
|
||||
&bloom_block_contents);
|
||||
bool index_in_file = s.ok();
|
||||
|
||||
BlockContents index_block_contents;
|
||||
s = ReadMetaBlock(file_.get(), file_size_, kPlainTableMagicNumber,
|
||||
ioptions_.env, PlainTableIndexBuilder::kPlainTableIndexBlock,
|
||||
&index_block_contents);
|
||||
options_.env, PlainTableIndexBuilder::kPlainTableIndexBlock,
|
||||
&index_block_contents);
|
||||
|
||||
index_in_file &= s.ok();
|
||||
|
||||
@@ -311,9 +310,8 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
|
||||
index_block = nullptr;
|
||||
}
|
||||
|
||||
if ((ioptions_.prefix_extractor == nullptr) &&
|
||||
(hash_table_ratio != 0)) {
|
||||
// ioptions.prefix_extractor is requried for a hash-based look-up.
|
||||
if ((options_.prefix_extractor.get() == nullptr) && (hash_table_ratio != 0)) {
|
||||
// options.prefix_extractor is requried for a hash-based look-up.
|
||||
return Status::NotSupported(
|
||||
"PlainTable requires a prefix extractor enable prefix hash mode.");
|
||||
}
|
||||
@@ -330,8 +328,8 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
|
||||
table_properties_->num_entries * bloom_bits_per_key;
|
||||
if (num_bloom_bits > 0) {
|
||||
enable_bloom_ = true;
|
||||
bloom_.SetTotalBits(&arena_, num_bloom_bits, ioptions_.bloom_locality,
|
||||
huge_page_tlb_size, ioptions_.info_log);
|
||||
bloom_.SetTotalBits(&arena_, num_bloom_bits, options_.bloom_locality,
|
||||
huge_page_tlb_size, options_.info_log.get());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -353,7 +351,7 @@ Status PlainTableReader::PopulateIndex(TableProperties* props,
|
||||
bloom_block->size() * 8, num_blocks);
|
||||
}
|
||||
|
||||
PlainTableIndexBuilder index_builder(&arena_, ioptions_, index_sparseness,
|
||||
PlainTableIndexBuilder index_builder(&arena_, options_, index_sparseness,
|
||||
hash_table_ratio, huge_page_tlb_size);
|
||||
|
||||
std::vector<uint32_t> prefix_hashes;
|
||||
@@ -424,7 +422,7 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
|
||||
uint32_t file_offset = GetFixed32Element(base_ptr, mid);
|
||||
size_t tmp;
|
||||
Status s = PlainTableKeyDecoder(encoding_type_, user_key_len_,
|
||||
ioptions_.prefix_extractor)
|
||||
options_.prefix_extractor.get())
|
||||
.NextKey(file_data_.data() + file_offset,
|
||||
file_data_.data() + data_end_offset_, &mid_key,
|
||||
nullptr, &tmp);
|
||||
@@ -453,7 +451,7 @@ Status PlainTableReader::GetOffset(const Slice& target, const Slice& prefix,
|
||||
size_t tmp;
|
||||
uint32_t low_key_offset = GetFixed32Element(base_ptr, low);
|
||||
Status s = PlainTableKeyDecoder(encoding_type_, user_key_len_,
|
||||
ioptions_.prefix_extractor)
|
||||
options_.prefix_extractor.get())
|
||||
.NextKey(file_data_.data() + low_key_offset,
|
||||
file_data_.data() + data_end_offset_, &low_key,
|
||||
nullptr, &tmp);
|
||||
@@ -526,7 +524,10 @@ void PlainTableReader::Prepare(const Slice& target) {
|
||||
}
|
||||
|
||||
Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
|
||||
GetContext* get_context) {
|
||||
void* arg,
|
||||
bool (*saver)(void*, const ParsedInternalKey&,
|
||||
const Slice&),
|
||||
void (*mark_key_may_exist)(void*)) {
|
||||
// Check bloom filter first.
|
||||
Slice prefix_slice;
|
||||
uint32_t prefix_hash;
|
||||
@@ -564,7 +565,7 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
|
||||
}
|
||||
Slice found_value;
|
||||
PlainTableKeyDecoder decoder(encoding_type_, user_key_len_,
|
||||
ioptions_.prefix_extractor);
|
||||
options_.prefix_extractor.get());
|
||||
while (offset < data_end_offset_) {
|
||||
Status s = Next(&decoder, &offset, &found_key, nullptr, &found_value);
|
||||
if (!s.ok()) {
|
||||
@@ -578,10 +579,8 @@ Status PlainTableReader::Get(const ReadOptions& ro, const Slice& target,
|
||||
}
|
||||
prefix_match = true;
|
||||
}
|
||||
// TODO(ljin): since we know the key comparison result here,
|
||||
// can we enable the fast path?
|
||||
if (internal_comparator_.Compare(found_key, parsed_target) >= 0) {
|
||||
if (!get_context->SaveValue(found_key, found_value)) {
|
||||
if (!(*saver)(arg, found_key, found_value)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user