2013-10-29 04:34:02 +01: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 22:39:26 +02:00
|
|
|
#ifndef ROCKSDB_LITE
|
2014-01-28 06:58:46 +01:00
|
|
|
#include "table/plain_table_factory.h"
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <stdint.h>
|
2014-01-27 22:53:22 +01:00
|
|
|
#include "db/dbformat.h"
|
2013-10-29 04:34:02 +01: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-18 01:16:11 +02:00
|
|
|
Status PlainTableFactory::NewTableReader(
|
2015-09-11 20:36:33 +02:00
|
|
|
const TableReaderOptions& table_reader_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-18 01:16:11 +02:00
|
|
|
unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
|
|
|
|
unique_ptr<TableReader>* table) const {
|
2015-09-11 20:36:33 +02:00
|
|
|
return PlainTableReader::Open(
|
|
|
|
table_reader_options.ioptions, table_reader_options.env_options,
|
|
|
|
table_reader_options.internal_comparator, std::move(file), file_size,
|
2015-11-16 21:56:21 +01:00
|
|
|
table, table_options_.bloom_bits_per_key, table_options_.hash_table_ratio,
|
|
|
|
table_options_.index_sparseness, table_options_.huge_page_tlb_size,
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.full_scan_mode);
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 06:58:46 +01:00
|
|
|
TableBuilder* PlainTableFactory::NewTableBuilder(
|
2015-10-09 01:57:35 +02:00
|
|
|
const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
|
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-18 01:16:11 +02:00
|
|
|
WritableFileWriter* file) const {
|
2015-02-17 17:03:45 +01: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 16:35:56 +02:00
|
|
|
return new PlainTableBuilder(
|
|
|
|
table_builder_options.ioptions,
|
2015-10-09 01:57:35 +02:00
|
|
|
table_builder_options.int_tbl_prop_collector_factories, column_family_id,
|
2015-11-16 21:56:21 +01:00
|
|
|
file, table_options_.user_key_len, table_options_.encoding_type,
|
2016-04-07 08:10:32 +02:00
|
|
|
table_options_.index_sparseness, table_options_.bloom_bits_per_key,
|
|
|
|
table_builder_options.column_family_name, 6,
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.huge_page_tlb_size, table_options_.hash_table_ratio,
|
|
|
|
table_options_.store_index_in_file);
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
2014-01-28 06:58:46 +01:00
|
|
|
|
2014-08-25 23:24:09 +02: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-10-28 18:46:01 +01:00
|
|
|
table_options_.user_key_len);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " bloom_bits_per_key: %d\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.bloom_bits_per_key);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.hash_table_ratio);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
2015-07-02 01:13:49 +02:00
|
|
|
snprintf(buffer, kBufferSize, " index_sparseness: %" ROCKSDB_PRIszt "\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.index_sparseness);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
2015-07-02 01:13:49 +02:00
|
|
|
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %" ROCKSDB_PRIszt "\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.huge_page_tlb_size);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " encoding_type: %d\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.encoding_type);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " full_scan_mode: %d\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.full_scan_mode);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " store_index_in_file: %d\n",
|
2015-10-28 18:46:01 +01:00
|
|
|
table_options_.store_index_in_file);
|
2014-08-25 23:24:09 +02:00
|
|
|
ret.append(buffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-10-30 23:58:46 +01:00
|
|
|
const PlainTableOptions& PlainTableFactory::table_options() const {
|
2015-10-28 18:46:01 +01:00
|
|
|
return table_options_;
|
|
|
|
}
|
|
|
|
|
2014-07-18 09:08:38 +02:00
|
|
|
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options) {
|
|
|
|
return new PlainTableFactory(options);
|
2014-01-28 06:58:46 +01:00
|
|
|
}
|
|
|
|
|
2014-06-19 01:36:48 +02:00
|
|
|
const std::string PlainTablePropertyNames::kPrefixExtractorName =
|
|
|
|
"rocksdb.prefix.extractor.name";
|
|
|
|
|
|
|
|
const std::string PlainTablePropertyNames::kEncodingType =
|
|
|
|
"rocksdb.plain.table.encoding.type";
|
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
const std::string PlainTablePropertyNames::kBloomVersion =
|
|
|
|
"rocksdb.plain.table.bloom.version";
|
|
|
|
|
|
|
|
const std::string PlainTablePropertyNames::kNumBloomBlocks =
|
|
|
|
"rocksdb.plain.table.bloom.numblocks";
|
|
|
|
|
2013-10-29 04:34:02 +01:00
|
|
|
} // namespace rocksdb
|
2014-04-15 22:39:26 +02:00
|
|
|
#endif // ROCKSDB_LITE
|