/Users/deen/code/yugabyte-db/src/yb/rocksdb/table/block_based_table_factory.h
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
21 | | // Use of this source code is governed by a BSD-style license that can be |
22 | | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
23 | | |
24 | | #ifndef YB_ROCKSDB_TABLE_BLOCK_BASED_TABLE_FACTORY_H |
25 | | #define YB_ROCKSDB_TABLE_BLOCK_BASED_TABLE_FACTORY_H |
26 | | |
27 | | #include <stdint.h> |
28 | | |
29 | | #include <memory> |
30 | | #include <string> |
31 | | |
32 | | #include "yb/rocksdb/table.h" |
33 | | #include "yb/rocksdb/table/block_based_table_reader.h" |
34 | | |
35 | | namespace rocksdb { |
36 | | |
37 | | struct EnvOptions; |
38 | | |
39 | | using std::unique_ptr; |
40 | | class BlockBasedTableBuilder; |
41 | | |
42 | | class BlockBasedTableFactory : public TableFactory { |
43 | | public: |
44 | | explicit BlockBasedTableFactory( |
45 | | const BlockBasedTableOptions& table_options = BlockBasedTableOptions()); |
46 | | |
47 | 6.66M | ~BlockBasedTableFactory() {} |
48 | | |
49 | 7.71M | const char* Name() const override { return "BlockBasedTable"; } |
50 | | |
51 | | Status NewTableReader(const TableReaderOptions& table_reader_options, |
52 | | unique_ptr<RandomAccessFileReader>&& file, |
53 | | uint64_t file_size, |
54 | | unique_ptr<TableReader>* table_reader) const override; |
55 | | |
56 | | // This is a variant of virtual member function NewTableReader function with |
57 | | // added capability to control pre-fetching of blocks on BlockBasedTable::Open |
58 | | Status NewTableReader(const TableReaderOptions& table_reader_options, |
59 | | unique_ptr<RandomAccessFileReader>&& file, |
60 | | uint64_t file_size, |
61 | | unique_ptr<TableReader>* table_reader, |
62 | | DataIndexLoadMode prefetch_data_index, |
63 | | PrefetchFilter prefetch_filter) const; |
64 | | |
65 | 86.1k | bool IsSplitSstForWriteSupported() const override { return true; } |
66 | | |
67 | | // base_file should be not nullptr, data_file should either point to different file writer |
68 | | // or be nullptr in order to produce single SST file containing both data and metadata. |
69 | | TableBuilder* NewTableBuilder( |
70 | | const TableBuilderOptions& table_builder_options, |
71 | | uint32_t column_family_id, WritableFileWriter* base_file, |
72 | | WritableFileWriter* data_file = nullptr) const override; |
73 | | |
74 | | // Sanitizes the specified DB Options. |
75 | | Status SanitizeOptions(const DBOptions& db_opts, |
76 | | const ColumnFamilyOptions& cf_opts) const override; |
77 | | |
78 | | std::string GetPrintableTableOptions() const override; |
79 | | |
80 | | const BlockBasedTableOptions& table_options() const; |
81 | | |
82 | 14 | void* GetOptions() override { return &table_options_; } |
83 | | |
84 | | std::shared_ptr<TableAwareReadFileFilter> NewTableAwareReadFileFilter( |
85 | | const ReadOptions &read_options, const Slice &user_key) const override; |
86 | | |
87 | | private: |
88 | | BlockBasedTableOptions table_options_; |
89 | | }; |
90 | | |
91 | | extern const char kHashIndexPrefixesBlock[]; |
92 | | extern const char kHashIndexPrefixesMetadataBlock[]; |
93 | | extern const char kPropTrue[]; |
94 | | extern const char kPropFalse[]; |
95 | | |
96 | 242k | inline const char* ToBlockBasedTablePropertyValue(bool value) { |
97 | 242k | return value ? kPropTrue125k : kPropFalse117k ; |
98 | 242k | } |
99 | | |
100 | | } // namespace rocksdb |
101 | | |
102 | | #endif // YB_ROCKSDB_TABLE_BLOCK_BASED_TABLE_FACTORY_H |