1 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. See the AUTHORS file for names of contributors.
5 
6 #pragma once
7 
8 #ifndef ROCKSDB_LITE
9 
10 #include <string>
11 #include "rocksdb/options.h"
12 #include "rocksdb/table.h"
13 
14 namespace ROCKSDB_NAMESPACE {
15 
16 struct EnvOptions;
17 
18 class Status;
19 class RandomAccessFile;
20 class WritableFile;
21 class Table;
22 class TableBuilder;
23 
24 class AdaptiveTableFactory : public TableFactory {
25  public:
~AdaptiveTableFactory()26   ~AdaptiveTableFactory() {}
27 
28   explicit AdaptiveTableFactory(
29       std::shared_ptr<TableFactory> table_factory_to_write,
30       std::shared_ptr<TableFactory> block_based_table_factory,
31       std::shared_ptr<TableFactory> plain_table_factory,
32       std::shared_ptr<TableFactory> cuckoo_table_factory);
33 
Name()34   const char* Name() const override { return "AdaptiveTableFactory"; }
35 
36   Status NewTableReader(
37       const TableReaderOptions& table_reader_options,
38       std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
39       std::unique_ptr<TableReader>* table,
40       bool prefetch_index_and_filter_in_cache = true) const override;
41 
42   TableBuilder* NewTableBuilder(
43       const TableBuilderOptions& table_builder_options,
44       uint32_t column_family_id, WritableFileWriter* file) const override;
45 
46   // Sanitizes the specified DB Options.
SanitizeOptions(const DBOptions &,const ColumnFamilyOptions &)47   Status SanitizeOptions(
48       const DBOptions& /*db_opts*/,
49       const ColumnFamilyOptions& /*cf_opts*/) const override {
50     return Status::OK();
51   }
52 
53   std::string GetPrintableTableOptions() const override;
54 
55  private:
56   std::shared_ptr<TableFactory> table_factory_to_write_;
57   std::shared_ptr<TableFactory> block_based_table_factory_;
58   std::shared_ptr<TableFactory> plain_table_factory_;
59   std::shared_ptr<TableFactory> cuckoo_table_factory_;
60 };
61 
62 }  // namespace ROCKSDB_NAMESPACE
63 #endif  // ROCKSDB_LITE
64