builder.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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).
  5. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  6. // Use of this source code is governed by a BSD-style license that can be
  7. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  8. #pragma once
  9. #include <string>
  10. #include <utility>
  11. #include <vector>
  12. #include "db/range_tombstone_fragmenter.h"
  13. #include "db/table_properties_collector.h"
  14. #include "logging/event_logger.h"
  15. #include "options/cf_options.h"
  16. #include "rocksdb/comparator.h"
  17. #include "rocksdb/env.h"
  18. #include "rocksdb/listener.h"
  19. #include "rocksdb/options.h"
  20. #include "rocksdb/status.h"
  21. #include "rocksdb/table_properties.h"
  22. #include "rocksdb/types.h"
  23. #include "table/scoped_arena_iterator.h"
  24. namespace ROCKSDB_NAMESPACE {
  25. struct Options;
  26. struct FileMetaData;
  27. class Env;
  28. struct EnvOptions;
  29. class Iterator;
  30. class SnapshotChecker;
  31. class TableCache;
  32. class VersionEdit;
  33. class TableBuilder;
  34. class WritableFileWriter;
  35. class InternalStats;
  36. // @param column_family_name Name of the column family that is also identified
  37. // by column_family_id, or empty string if unknown. It must outlive the
  38. // TableBuilder returned by this function.
  39. TableBuilder* NewTableBuilder(
  40. const ImmutableCFOptions& options, const MutableCFOptions& moptions,
  41. const InternalKeyComparator& internal_comparator,
  42. const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
  43. int_tbl_prop_collector_factories,
  44. uint32_t column_family_id, const std::string& column_family_name,
  45. WritableFileWriter* file, const CompressionType compression_type,
  46. const uint64_t sample_for_compression,
  47. const CompressionOptions& compression_opts, int level,
  48. const bool skip_filters = false, const uint64_t creation_time = 0,
  49. const uint64_t oldest_key_time = 0, const uint64_t target_file_size = 0,
  50. const uint64_t file_creation_time = 0);
  51. // Build a Table file from the contents of *iter. The generated file
  52. // will be named according to number specified in meta. On success, the rest of
  53. // *meta will be filled with metadata about the generated table.
  54. // If no data is present in *iter, meta->file_size will be set to
  55. // zero, and no Table file will be produced.
  56. //
  57. // @param column_family_name Name of the column family that is also identified
  58. // by column_family_id, or empty string if unknown.
  59. extern Status BuildTable(
  60. const std::string& dbname, Env* env, FileSystem* fs,
  61. const ImmutableCFOptions& options,
  62. const MutableCFOptions& mutable_cf_options, const FileOptions& file_options,
  63. TableCache* table_cache, InternalIterator* iter,
  64. std::vector<std::unique_ptr<FragmentedRangeTombstoneIterator>>
  65. range_del_iters,
  66. FileMetaData* meta, const InternalKeyComparator& internal_comparator,
  67. const std::vector<std::unique_ptr<IntTblPropCollectorFactory>>*
  68. int_tbl_prop_collector_factories,
  69. uint32_t column_family_id, const std::string& column_family_name,
  70. std::vector<SequenceNumber> snapshots,
  71. SequenceNumber earliest_write_conflict_snapshot,
  72. SnapshotChecker* snapshot_checker, const CompressionType compression,
  73. const uint64_t sample_for_compression,
  74. const CompressionOptions& compression_opts, bool paranoid_file_checks,
  75. InternalStats* internal_stats, TableFileCreationReason reason,
  76. EventLogger* event_logger = nullptr, int job_id = 0,
  77. const Env::IOPriority io_priority = Env::IO_HIGH,
  78. TableProperties* table_properties = nullptr, int level = -1,
  79. const uint64_t creation_time = 0, const uint64_t oldest_key_time = 0,
  80. Env::WriteLifeTimeHint write_hint = Env::WLTH_NOT_SET,
  81. const uint64_t file_creation_time = 0);
  82. } // namespace ROCKSDB_NAMESPACE