2013-10-29 03:34:02 +00:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2014-04-15 20:39:26 +00:00
|
|
|
#ifndef ROCKSDB_LITE
|
2014-01-28 05:58:46 +00:00
|
|
|
#include "table/plain_table_factory.h"
|
2013-10-29 03:34:02 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <stdint.h>
|
2014-01-27 21:53:22 +00:00
|
|
|
#include "db/dbformat.h"
|
2013-10-29 03:34:02 +00:00
|
|
|
#include "table/plain_table_builder.h"
|
|
|
|
#include "table/plain_table_reader.h"
|
|
|
|
#include "port/port.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-17 23:16:11 +00:00
|
|
|
Status PlainTableFactory::NewTableReader(
|
|
|
|
const ImmutableCFOptions& ioptions, const EnvOptions& env_options,
|
|
|
|
const InternalKeyComparator& icomp,
|
|
|
|
unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
|
|
|
|
unique_ptr<TableReader>* table) const {
|
2015-07-08 14:35:56 +00:00
|
|
|
return PlainTableReader::Open(ioptions, env_options, icomp, std::move(file),
|
|
|
|
file_size, table, bloom_bits_per_key_,
|
|
|
|
hash_table_ratio_, index_sparseness_,
|
|
|
|
huge_page_tlb_size_, full_scan_mode_);
|
2013-10-29 03:34:02 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 05:58:46 +00:00
|
|
|
TableBuilder* PlainTableFactory::NewTableBuilder(
|
A new call back to TablePropertiesCollector to allow users know the entry is add, delete or merge
Summary:
Currently users have no idea a key is add, delete or merge from TablePropertiesCollector call back. Add a new function to add it.
Also refactor the codes so that
(1) make table property collector and internal table property collector two separate data structures with the later one now exposed
(2) table builders only receive internal table properties
Test Plan: Add cases in table_properties_collector_test to cover both of old and new ways of using TablePropertiesCollector.
Reviewers: yhchiang, igor.sugak, rven, igor
Reviewed By: rven, igor
Subscribers: meyering, yoshinorim, maykov, leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D35373
2015-04-06 17:04:30 +00:00
|
|
|
const TableBuilderOptions& table_builder_options,
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-17 23:16:11 +00:00
|
|
|
WritableFileWriter* file) const {
|
2015-02-17 16:03:45 +00:00
|
|
|
// Ignore the skip_filters flag. PlainTable format is optimized for small
|
|
|
|
// in-memory dbs. The skip_filters optimization is not useful for plain
|
|
|
|
// tables
|
|
|
|
//
|
2015-07-08 14:35:56 +00:00
|
|
|
return new PlainTableBuilder(
|
|
|
|
table_builder_options.ioptions,
|
|
|
|
table_builder_options.int_tbl_prop_collector_factories, file,
|
|
|
|
user_key_len_, encoding_type_, index_sparseness_, bloom_bits_per_key_, 6,
|
|
|
|
huge_page_tlb_size_, hash_table_ratio_, store_index_in_file_);
|
2013-10-29 03:34:02 +00:00
|
|
|
}
|
2014-01-28 05:58:46 +00:00
|
|
|
|
2014-08-25 21:24:09 +00:00
|
|
|
std::string PlainTableFactory::GetPrintableTableOptions() const {
|
|
|
|
std::string ret;
|
|
|
|
ret.reserve(20000);
|
|
|
|
const int kBufferSize = 200;
|
|
|
|
char buffer[kBufferSize];
|
|
|
|
|
|
|
|
snprintf(buffer, kBufferSize, " user_key_len: %u\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
user_key_len_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " bloom_bits_per_key: %d\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
bloom_bits_per_key_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
hash_table_ratio_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
2015-07-01 23:13:49 +00:00
|
|
|
snprintf(buffer, kBufferSize, " index_sparseness: %" ROCKSDB_PRIszt "\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
index_sparseness_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
2015-07-01 23:13:49 +00:00
|
|
|
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %" ROCKSDB_PRIszt "\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
huge_page_tlb_size_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " encoding_type: %d\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
encoding_type_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " full_scan_mode: %d\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
full_scan_mode_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " store_index_in_file: %d\n",
|
2015-07-08 14:35:56 +00:00
|
|
|
store_index_in_file_);
|
2014-08-25 21:24:09 +00:00
|
|
|
ret.append(buffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-18 07:08:38 +00:00
|
|
|
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
|
|
|
|
return new PlainTableFactory(options);
|
2014-01-28 05:58:46 +00:00
|
|
|
}
|
|
|
|
|
2014-06-18 23:36:48 +00:00
|
|
|
const std::string PlainTablePropertyNames::kPrefixExtractorName =
|
|
|
|
"rocksdb.prefix.extractor.name";
|
|
|
|
|
|
|
|
const std::string PlainTablePropertyNames::kEncodingType =
|
|
|
|
"rocksdb.plain.table.encoding.type";
|
|
|
|
|
2014-07-18 23:58:13 +00:00
|
|
|
const std::string PlainTablePropertyNames::kBloomVersion =
|
|
|
|
"rocksdb.plain.table.bloom.version";
|
|
|
|
|
|
|
|
const std::string PlainTablePropertyNames::kNumBloomBlocks =
|
|
|
|
"rocksdb.plain.table.bloom.numblocks";
|
|
|
|
|
2013-10-29 03:34:02 +00:00
|
|
|
} // namespace rocksdb
|
2014-04-15 20:39:26 +00:00
|
|
|
#endif // ROCKSDB_LITE
|