]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/table/cuckoo_table_factory.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / table / cuckoo_table_factory.cc
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
7c673cae
FG
5
6#ifndef ROCKSDB_LITE
7#include "table/cuckoo_table_factory.h"
8
9#include "db/dbformat.h"
10#include "table/cuckoo_table_builder.h"
11#include "table/cuckoo_table_reader.h"
12
13namespace rocksdb {
14
15Status CuckooTableFactory::NewTableReader(
16 const TableReaderOptions& table_reader_options,
494da23a 17 std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
7c673cae 18 std::unique_ptr<TableReader>* table,
11fdf7f2 19 bool /*prefetch_index_and_filter_in_cache*/) const {
7c673cae
FG
20 std::unique_ptr<CuckooTableReader> new_reader(new CuckooTableReader(
21 table_reader_options.ioptions, std::move(file), file_size,
22 table_reader_options.internal_comparator.user_comparator(), nullptr));
23 Status s = new_reader->status();
24 if (s.ok()) {
25 *table = std::move(new_reader);
26 }
27 return s;
28}
29
30TableBuilder* CuckooTableFactory::NewTableBuilder(
31 const TableBuilderOptions& table_builder_options, uint32_t column_family_id,
32 WritableFileWriter* file) const {
33 // Ignore the skipFIlters flag. Does not apply to this file format
34 //
35
36 // TODO: change builder to take the option struct
37 return new CuckooTableBuilder(
38 file, table_options_.hash_table_ratio, 64,
39 table_options_.max_search_depth,
40 table_builder_options.internal_comparator.user_comparator(),
41 table_options_.cuckoo_block_size, table_options_.use_module_hash,
42 table_options_.identity_as_first_hash, nullptr /* get_slice_hash */,
43 column_family_id, table_builder_options.column_family_name);
44}
45
46std::string CuckooTableFactory::GetPrintableTableOptions() const {
47 std::string ret;
48 ret.reserve(2000);
49 const int kBufferSize = 200;
50 char buffer[kBufferSize];
51
52 snprintf(buffer, kBufferSize, " hash_table_ratio: %lf\n",
53 table_options_.hash_table_ratio);
54 ret.append(buffer);
55 snprintf(buffer, kBufferSize, " max_search_depth: %u\n",
56 table_options_.max_search_depth);
57 ret.append(buffer);
58 snprintf(buffer, kBufferSize, " cuckoo_block_size: %u\n",
59 table_options_.cuckoo_block_size);
60 ret.append(buffer);
61 snprintf(buffer, kBufferSize, " identity_as_first_hash: %d\n",
62 table_options_.identity_as_first_hash);
63 ret.append(buffer);
64 return ret;
65}
66
67TableFactory* NewCuckooTableFactory(const CuckooTableOptions& table_options) {
68 return new CuckooTableFactory(table_options);
69}
70
71} // namespace rocksdb
72#endif // ROCKSDB_LITE