]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/table/cuckoo_table_factory.cc
84d22468eb9634ed739ab3f6cedccf697b1629f4
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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).
7 #include "table/cuckoo_table_factory.h"
9 #include "db/dbformat.h"
10 #include "table/cuckoo_table_builder.h"
11 #include "table/cuckoo_table_reader.h"
15 Status
CuckooTableFactory::NewTableReader(
16 const TableReaderOptions
& table_reader_options
,
17 unique_ptr
<RandomAccessFileReader
>&& file
, uint64_t file_size
,
18 std::unique_ptr
<TableReader
>* table
,
19 bool /*prefetch_index_and_filter_in_cache*/) const {
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();
25 *table
= std::move(new_reader
);
30 TableBuilder
* 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
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
);
46 std::string
CuckooTableFactory::GetPrintableTableOptions() const {
49 const int kBufferSize
= 200;
50 char buffer
[kBufferSize
];
52 snprintf(buffer
, kBufferSize
, " hash_table_ratio: %lf\n",
53 table_options_
.hash_table_ratio
);
55 snprintf(buffer
, kBufferSize
, " max_search_depth: %u\n",
56 table_options_
.max_search_depth
);
58 snprintf(buffer
, kBufferSize
, " cuckoo_block_size: %u\n",
59 table_options_
.cuckoo_block_size
);
61 snprintf(buffer
, kBufferSize
, " identity_as_first_hash: %d\n",
62 table_options_
.identity_as_first_hash
);
67 TableFactory
* NewCuckooTableFactory(const CuckooTableOptions
& table_options
) {
68 return new CuckooTableFactory(table_options
);
71 } // namespace rocksdb
72 #endif // ROCKSDB_LITE