]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/include/rocksdb/metadata.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / include / rocksdb / metadata.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
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).
7c673cae
FG
5
6#pragma once
7
8#include <stdint.h>
9
10#include <limits>
11#include <string>
12#include <vector>
13
14#include "rocksdb/types.h"
15
f67539c2 16namespace ROCKSDB_NAMESPACE {
7c673cae
FG
17struct ColumnFamilyMetaData;
18struct LevelMetaData;
19struct SstFileMetaData;
20
21// The metadata that describes a column family.
22struct ColumnFamilyMetaData {
11fdf7f2 23 ColumnFamilyMetaData() : size(0), file_count(0), name("") {}
7c673cae 24 ColumnFamilyMetaData(const std::string& _name, uint64_t _size,
494da23a
TL
25 const std::vector<LevelMetaData>&& _levels)
26 : size(_size), name(_name), levels(_levels) {}
7c673cae
FG
27
28 // The size of this column family in bytes, which is equal to the sum of
29 // the file size of its "levels".
30 uint64_t size;
31 // The number of files in this column family.
32 size_t file_count;
33 // The name of the column family.
34 std::string name;
35 // The metadata of all levels in this column family.
36 std::vector<LevelMetaData> levels;
37};
38
39// The metadata that describes a level.
40struct LevelMetaData {
41 LevelMetaData(int _level, uint64_t _size,
494da23a
TL
42 const std::vector<SstFileMetaData>&& _files)
43 : level(_level), size(_size), files(_files) {}
7c673cae
FG
44
45 // The level which this meta data describes.
46 const int level;
47 // The size of this level in bytes, which is equal to the sum of
48 // the file size of its "files".
49 const uint64_t size;
50 // The metadata of all sst files in this level.
51 const std::vector<SstFileMetaData> files;
52};
53
54// The metadata that describes a SST file.
55struct SstFileMetaData {
11fdf7f2
TL
56 SstFileMetaData()
57 : size(0),
f67539c2 58 file_number(0),
11fdf7f2
TL
59 smallest_seqno(0),
60 largest_seqno(0),
11fdf7f2 61 num_reads_sampled(0),
494da23a
TL
62 being_compacted(false),
63 num_entries(0),
f67539c2 64 num_deletions(0),
20effc67
TL
65 oldest_blob_file_number(0),
66 oldest_ancester_time(0),
67 file_creation_time(0) {}
494da23a 68
f67539c2
TL
69 SstFileMetaData(const std::string& _file_name, uint64_t _file_number,
70 const std::string& _path, size_t _size,
71 SequenceNumber _smallest_seqno, SequenceNumber _largest_seqno,
7c673cae 72 const std::string& _smallestkey,
11fdf7f2 73 const std::string& _largestkey, uint64_t _num_reads_sampled,
f67539c2
TL
74 bool _being_compacted, uint64_t _oldest_blob_file_number,
75 uint64_t _oldest_ancester_time, uint64_t _file_creation_time,
76 std::string& _file_checksum,
77 std::string& _file_checksum_func_name)
11fdf7f2
TL
78 : size(_size),
79 name(_file_name),
f67539c2 80 file_number(_file_number),
11fdf7f2
TL
81 db_path(_path),
82 smallest_seqno(_smallest_seqno),
83 largest_seqno(_largest_seqno),
84 smallestkey(_smallestkey),
85 largestkey(_largestkey),
86 num_reads_sampled(_num_reads_sampled),
494da23a
TL
87 being_compacted(_being_compacted),
88 num_entries(0),
f67539c2
TL
89 num_deletions(0),
90 oldest_blob_file_number(_oldest_blob_file_number),
91 oldest_ancester_time(_oldest_ancester_time),
92 file_creation_time(_file_creation_time),
93 file_checksum(_file_checksum),
94 file_checksum_func_name(_file_checksum_func_name) {}
7c673cae
FG
95
96 // File size in bytes.
11fdf7f2 97 size_t size;
7c673cae
FG
98 // The name of the file.
99 std::string name;
f67539c2
TL
100 // The id of the file.
101 uint64_t file_number;
7c673cae
FG
102 // The full path where the file locates.
103 std::string db_path;
104
105 SequenceNumber smallest_seqno; // Smallest sequence number in file.
106 SequenceNumber largest_seqno; // Largest sequence number in file.
494da23a
TL
107 std::string smallestkey; // Smallest user defined key in the file.
108 std::string largestkey; // Largest user defined key in the file.
109 uint64_t num_reads_sampled; // How many times the file is read.
7c673cae 110 bool being_compacted; // true if the file is currently being compacted.
494da23a
TL
111
112 uint64_t num_entries;
113 uint64_t num_deletions;
f67539c2
TL
114
115 uint64_t oldest_blob_file_number; // The id of the oldest blob file
116 // referenced by the file.
117 // An SST file may be generated by compactions whose input files may
118 // in turn be generated by earlier compactions. The creation time of the
119 // oldest SST file that is the compaction ancester of this file.
120 // The timestamp is provided Env::GetCurrentTime().
121 // 0 if the information is not available.
20effc67
TL
122 //
123 // Note: for TTL blob files, it contains the start of the expiration range.
f67539c2
TL
124 uint64_t oldest_ancester_time;
125 // Timestamp when the SST file is created, provided by Env::GetCurrentTime().
126 // 0 if the information is not available.
127 uint64_t file_creation_time;
128
129 // The checksum of a SST file, the value is decided by the file content and
130 // the checksum algorithm used for this SST file. The checksum function is
131 // identified by the file_checksum_func_name. If the checksum function is
132 // not specified, file_checksum is "0" by default.
133 std::string file_checksum;
134
135 // The name of the checksum function used to generate the file checksum
136 // value. If file checksum is not enabled (e.g., sst_file_checksum_func is
137 // null), file_checksum_func_name is UnknownFileChecksumFuncName, which is
138 // "Unknown".
139 std::string file_checksum_func_name;
7c673cae
FG
140};
141
142// The full set of metadata associated with each SST file.
143struct LiveFileMetaData : SstFileMetaData {
144 std::string column_family_name; // Name of the column family
494da23a
TL
145 int level; // Level at which this file resides.
146 LiveFileMetaData() : column_family_name(), level(0) {}
7c673cae 147};
f67539c2
TL
148
149// Metadata returned as output from ExportColumnFamily() and used as input to
150// CreateColumnFamiliesWithImport().
151struct ExportImportFilesMetaData {
152 std::string db_comparator_name; // Used to safety check at import.
153 std::vector<LiveFileMetaData> files; // Vector of file metadata.
154};
155} // namespace ROCKSDB_NAMESPACE