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 {
|
|
|
|
|
2014-09-05 01:18:36 +02:00
|
|
|
Status PlainTableFactory::NewTableReader(const ImmutableCFOptions& ioptions,
|
|
|
|
const EnvOptions& env_options,
|
2014-01-27 22:53:22 +01:00
|
|
|
const InternalKeyComparator& icomp,
|
2014-01-28 06:58:46 +01:00
|
|
|
unique_ptr<RandomAccessFile>&& file,
|
2013-10-29 04:34:02 +01:00
|
|
|
uint64_t file_size,
|
2014-01-28 06:58:46 +01:00
|
|
|
unique_ptr<TableReader>* table) const {
|
2014-09-05 01:18:36 +02:00
|
|
|
return PlainTableReader::Open(ioptions, env_options, icomp, std::move(file),
|
2014-01-27 22:53:22 +01:00
|
|
|
file_size, table, bloom_bits_per_key_,
|
2014-05-04 22:55:53 +02:00
|
|
|
hash_table_ratio_, index_sparseness_,
|
2014-06-19 01:36:48 +02:00
|
|
|
huge_page_tlb_size_, full_scan_mode_);
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 06:58:46 +01:00
|
|
|
TableBuilder* PlainTableFactory::NewTableBuilder(
|
2014-09-05 01:18:36 +02:00
|
|
|
const ImmutableCFOptions& ioptions,
|
|
|
|
const InternalKeyComparator& internal_comparator,
|
|
|
|
WritableFile* file, const CompressionType,
|
|
|
|
const CompressionOptions&) const {
|
|
|
|
return new PlainTableBuilder(ioptions, file, user_key_len_, encoding_type_,
|
2014-07-19 01:58:13 +02:00
|
|
|
index_sparseness_, bloom_bits_per_key_, 6,
|
|
|
|
huge_page_tlb_size_, hash_table_ratio_,
|
|
|
|
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",
|
|
|
|
user_key_len_);
|
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " bloom_bits_per_key: %d\n",
|
|
|
|
bloom_bits_per_key_);
|
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
|
|
|
|
hash_table_ratio_);
|
|
|
|
ret.append(buffer);
|
2014-09-29 23:23:09 +02:00
|
|
|
snprintf(buffer, kBufferSize, " index_sparseness: %zu\n",
|
2014-08-25 23:24:09 +02:00
|
|
|
index_sparseness_);
|
|
|
|
ret.append(buffer);
|
2014-09-29 23:23:09 +02:00
|
|
|
snprintf(buffer, kBufferSize, " huge_page_tlb_size: %zu\n",
|
2014-08-25 23:24:09 +02:00
|
|
|
huge_page_tlb_size_);
|
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " encoding_type: %d\n",
|
|
|
|
encoding_type_);
|
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " full_scan_mode: %d\n",
|
|
|
|
full_scan_mode_);
|
|
|
|
ret.append(buffer);
|
|
|
|
snprintf(buffer, kBufferSize, " store_index_in_file: %d\n",
|
|
|
|
store_index_in_file_);
|
|
|
|
ret.append(buffer);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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
|