adaptive_table_factory.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #pragma once
  6. #ifndef ROCKSDB_LITE
  7. #include <string>
  8. #include "rocksdb/options.h"
  9. #include "rocksdb/table.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. struct EnvOptions;
  12. class Status;
  13. class RandomAccessFile;
  14. class WritableFile;
  15. class Table;
  16. class TableBuilder;
  17. class AdaptiveTableFactory : public TableFactory {
  18. public:
  19. ~AdaptiveTableFactory() {}
  20. explicit AdaptiveTableFactory(
  21. std::shared_ptr<TableFactory> table_factory_to_write,
  22. std::shared_ptr<TableFactory> block_based_table_factory,
  23. std::shared_ptr<TableFactory> plain_table_factory,
  24. std::shared_ptr<TableFactory> cuckoo_table_factory);
  25. const char* Name() const override { return "AdaptiveTableFactory"; }
  26. Status NewTableReader(
  27. const TableReaderOptions& table_reader_options,
  28. std::unique_ptr<RandomAccessFileReader>&& file, uint64_t file_size,
  29. std::unique_ptr<TableReader>* table,
  30. bool prefetch_index_and_filter_in_cache = true) const override;
  31. TableBuilder* NewTableBuilder(
  32. const TableBuilderOptions& table_builder_options,
  33. uint32_t column_family_id, WritableFileWriter* file) const override;
  34. // Sanitizes the specified DB Options.
  35. Status SanitizeOptions(
  36. const DBOptions& /*db_opts*/,
  37. const ColumnFamilyOptions& /*cf_opts*/) const override {
  38. return Status::OK();
  39. }
  40. std::string GetPrintableTableOptions() const override;
  41. private:
  42. std::shared_ptr<TableFactory> table_factory_to_write_;
  43. std::shared_ptr<TableFactory> block_based_table_factory_;
  44. std::shared_ptr<TableFactory> plain_table_factory_;
  45. std::shared_ptr<TableFactory> cuckoo_table_factory_;
  46. };
  47. } // namespace ROCKSDB_NAMESPACE
  48. #endif // ROCKSDB_LITE