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 
25 namespace ROCKSDB_NAMESPACE {
26 
27 struct FileMetaData;
28 
29 class VersionSet;
30 class BlobFileAddition;
31 class SnapshotChecker;
32 class TableCache;
33 class TableBuilder;
34 class WritableFileWriter;
35 class InternalStats;
36 class BlobFileCompletionCallback;
37 
38 // Convenience function for NewTableBuilder on the embedded table_factory.
39 TableBuilder* NewTableBuilder(const TableBuilderOptions& tboptions,
40                               WritableFileWriter* file);
41 
42 // Build a Table file from the contents of *iter.  The generated file
43 // will be named according to number specified in meta. On success, the rest of
44 // *meta will be filled with metadata about the generated table.
45 // If no data is present in *iter, meta->file_size will be set to
46 // zero, and no Table file will be produced.
47 //
48 // @param column_family_name Name of the column family that is also identified
49 //    by column_family_id, or empty string if unknown.
50 extern Status BuildTable(
51     const std::string& dbname, VersionSet* versions,
52     const ImmutableDBOptions& db_options, const TableBuilderOptions& tboptions,
53     const FileOptions& file_options, TableCache* table_cache,
54     InternalIterator* iter,
55     std::vector<std::unique_ptr<FragmentedRangeTombstoneIterator>>
56         range_del_iters,
57     FileMetaData* meta, std::vector<BlobFileAddition>* blob_file_additions,
58     std::vector<SequenceNumber> snapshots,
59     SequenceNumber earliest_write_conflict_snapshot,
60     SnapshotChecker* snapshot_checker, bool paranoid_file_checks,
61     InternalStats* internal_stats, IOStatus* io_status,
62     const std::shared_ptr<IOTracer>& io_tracer,
63     EventLogger* event_logger = nullptr, int job_id = 0,
64     const Env::IOPriority io_priority = Env::IO_HIGH,
65     TableProperties* table_properties = nullptr,
66     Env::WriteLifeTimeHint write_hint = Env::WLTH_NOT_SET,
67     const std::string* full_history_ts_low = nullptr,
68     BlobFileCompletionCallback* blob_callback = nullptr,
69     uint64_t* num_input_entries = nullptr);
70 
71 }  // namespace ROCKSDB_NAMESPACE
72