]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/TableProperties.java
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / java / src / main / java / org / rocksdb / TableProperties.java
1 // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2 package org.rocksdb;
3
4 import java.util.Arrays;
5 import java.util.Map;
6 import java.util.Objects;
7
8 /**
9 * TableProperties contains read-only properties of its associated
10 * table.
11 */
12 public class TableProperties {
13 private final long dataSize;
14 private final long indexSize;
15 private final long indexPartitions;
16 private final long topLevelIndexSize;
17 private final long indexKeyIsUserKey;
18 private final long indexValueIsDeltaEncoded;
19 private final long filterSize;
20 private final long rawKeySize;
21 private final long rawValueSize;
22 private final long numDataBlocks;
23 private final long numEntries;
24 private final long numDeletions;
25 private final long numMergeOperands;
26 private final long numRangeDeletions;
27 private final long formatVersion;
28 private final long fixedKeyLen;
29 private final long columnFamilyId;
30 private final long creationTime;
31 private final long oldestKeyTime;
32 private final byte[] columnFamilyName;
33 private final String filterPolicyName;
34 private final String comparatorName;
35 private final String mergeOperatorName;
36 private final String prefixExtractorName;
37 private final String propertyCollectorsNames;
38 private final String compressionName;
39 private final Map<String, String> userCollectedProperties;
40 private final Map<String, String> readableProperties;
41 private final Map<String, Long> propertiesOffsets;
42
43 /**
44 * Access is package private as this will only be constructed from
45 * C++ via JNI and for testing.
46 */
47 TableProperties(final long dataSize, final long indexSize, final long indexPartitions,
48 final long topLevelIndexSize, final long indexKeyIsUserKey,
49 final long indexValueIsDeltaEncoded, final long filterSize, final long rawKeySize,
50 final long rawValueSize, final long numDataBlocks, final long numEntries,
51 final long numDeletions, final long numMergeOperands, final long numRangeDeletions,
52 final long formatVersion, final long fixedKeyLen, final long columnFamilyId,
53 final long creationTime, final long oldestKeyTime, final byte[] columnFamilyName,
54 final String filterPolicyName, final String comparatorName, final String mergeOperatorName,
55 final String prefixExtractorName, final String propertyCollectorsNames,
56 final String compressionName, final Map<String, String> userCollectedProperties,
57 final Map<String, String> readableProperties, final Map<String, Long> propertiesOffsets) {
58 this.dataSize = dataSize;
59 this.indexSize = indexSize;
60 this.indexPartitions = indexPartitions;
61 this.topLevelIndexSize = topLevelIndexSize;
62 this.indexKeyIsUserKey = indexKeyIsUserKey;
63 this.indexValueIsDeltaEncoded = indexValueIsDeltaEncoded;
64 this.filterSize = filterSize;
65 this.rawKeySize = rawKeySize;
66 this.rawValueSize = rawValueSize;
67 this.numDataBlocks = numDataBlocks;
68 this.numEntries = numEntries;
69 this.numDeletions = numDeletions;
70 this.numMergeOperands = numMergeOperands;
71 this.numRangeDeletions = numRangeDeletions;
72 this.formatVersion = formatVersion;
73 this.fixedKeyLen = fixedKeyLen;
74 this.columnFamilyId = columnFamilyId;
75 this.creationTime = creationTime;
76 this.oldestKeyTime = oldestKeyTime;
77 this.columnFamilyName = columnFamilyName;
78 this.filterPolicyName = filterPolicyName;
79 this.comparatorName = comparatorName;
80 this.mergeOperatorName = mergeOperatorName;
81 this.prefixExtractorName = prefixExtractorName;
82 this.propertyCollectorsNames = propertyCollectorsNames;
83 this.compressionName = compressionName;
84 this.userCollectedProperties = userCollectedProperties;
85 this.readableProperties = readableProperties;
86 this.propertiesOffsets = propertiesOffsets;
87 }
88
89 /**
90 * Get the total size of all data blocks.
91 *
92 * @return the total size of all data blocks.
93 */
94 public long getDataSize() {
95 return dataSize;
96 }
97
98 /**
99 * Get the size of index block.
100 *
101 * @return the size of index block.
102 */
103 public long getIndexSize() {
104 return indexSize;
105 }
106
107 /**
108 * Get the total number of index partitions
109 * if {@link IndexType#kTwoLevelIndexSearch} is used.
110 *
111 * @return the total number of index partitions.
112 */
113 public long getIndexPartitions() {
114 return indexPartitions;
115 }
116
117 /**
118 * Size of the top-level index
119 * if {@link IndexType#kTwoLevelIndexSearch} is used.
120 *
121 * @return the size of the top-level index.
122 */
123 public long getTopLevelIndexSize() {
124 return topLevelIndexSize;
125 }
126
127 /**
128 * Whether the index key is user key.
129 * Otherwise it includes 8 byte of sequence
130 * number added by internal key format.
131 *
132 * @return the index key
133 */
134 public long getIndexKeyIsUserKey() {
135 return indexKeyIsUserKey;
136 }
137
138 /**
139 * Whether delta encoding is used to encode the index values.
140 *
141 * @return whether delta encoding is used to encode the index values.
142 */
143 public long getIndexValueIsDeltaEncoded() {
144 return indexValueIsDeltaEncoded;
145 }
146
147 /**
148 * Get the size of filter block.
149 *
150 * @return the size of filter block.
151 */
152 public long getFilterSize() {
153 return filterSize;
154 }
155
156 /**
157 * Get the total raw key size.
158 *
159 * @return the total raw key size.
160 */
161 public long getRawKeySize() {
162 return rawKeySize;
163 }
164
165 /**
166 * Get the total raw value size.
167 *
168 * @return the total raw value size.
169 */
170 public long getRawValueSize() {
171 return rawValueSize;
172 }
173
174 /**
175 * Get the number of blocks in this table.
176 *
177 * @return the number of blocks in this table.
178 */
179 public long getNumDataBlocks() {
180 return numDataBlocks;
181 }
182
183 /**
184 * Get the number of entries in this table.
185 *
186 * @return the number of entries in this table.
187 */
188 public long getNumEntries() {
189 return numEntries;
190 }
191
192 /**
193 * Get the number of deletions in the table.
194 *
195 * @return the number of deletions in the table.
196 */
197 public long getNumDeletions() {
198 return numDeletions;
199 }
200
201 /**
202 * Get the number of merge operands in the table.
203 *
204 * @return the number of merge operands in the table.
205 */
206 public long getNumMergeOperands() {
207 return numMergeOperands;
208 }
209
210 /**
211 * Get the number of range deletions in this table.
212 *
213 * @return the number of range deletions in this table.
214 */
215 public long getNumRangeDeletions() {
216 return numRangeDeletions;
217 }
218
219 /**
220 * Get the format version, reserved for backward compatibility.
221 *
222 * @return the format version.
223 */
224 public long getFormatVersion() {
225 return formatVersion;
226 }
227
228 /**
229 * Get the length of the keys.
230 *
231 * @return 0 when the key is variable length, otherwise number of
232 * bytes for each key.
233 */
234 public long getFixedKeyLen() {
235 return fixedKeyLen;
236 }
237
238 /**
239 * Get the ID of column family for this SST file,
240 * corresponding to the column family identified by
241 * {@link #getColumnFamilyName()}.
242 *
243 * @return the id of the column family.
244 */
245 public long getColumnFamilyId() {
246 return columnFamilyId;
247 }
248
249 /**
250 * The time when the SST file was created.
251 * Since SST files are immutable, this is equivalent
252 * to last modified time.
253 *
254 * @return the created time.
255 */
256 public long getCreationTime() {
257 return creationTime;
258 }
259
260 /**
261 * Get the timestamp of the earliest key.
262 *
263 * @return 0 means unknown, otherwise the timestamp.
264 */
265 public long getOldestKeyTime() {
266 return oldestKeyTime;
267 }
268
269 /**
270 * Get the name of the column family with which this
271 * SST file is associated.
272 *
273 * @return the name of the column family, or null if the
274 * column family is unknown.
275 */
276 /*@Nullable*/ public byte[] getColumnFamilyName() {
277 return columnFamilyName;
278 }
279
280 /**
281 * Get the name of the filter policy used in this table.
282 *
283 * @return the name of the filter policy, or null if
284 * no filter policy is used.
285 */
286 /*@Nullable*/ public String getFilterPolicyName() {
287 return filterPolicyName;
288 }
289
290 /**
291 * Get the name of the comparator used in this table.
292 *
293 * @return the name of the comparator.
294 */
295 public String getComparatorName() {
296 return comparatorName;
297 }
298
299 /**
300 * Get the name of the merge operator used in this table.
301 *
302 * @return the name of the merge operator, or null if no merge operator
303 * is used.
304 */
305 /*@Nullable*/ public String getMergeOperatorName() {
306 return mergeOperatorName;
307 }
308
309 /**
310 * Get the name of the prefix extractor used in this table.
311 *
312 * @return the name of the prefix extractor, or null if no prefix
313 * extractor is used.
314 */
315 /*@Nullable*/ public String getPrefixExtractorName() {
316 return prefixExtractorName;
317 }
318
319 /**
320 * Get the names of the property collectors factories used in this table.
321 *
322 * @return the names of the property collector factories separated
323 * by commas, e.g. {collector_name[1]},{collector_name[2]},...
324 */
325 public String getPropertyCollectorsNames() {
326 return propertyCollectorsNames;
327 }
328
329 /**
330 * Get the name of the compression algorithm used to compress the SST files.
331 *
332 * @return the name of the compression algorithm.
333 */
334 public String getCompressionName() {
335 return compressionName;
336 }
337
338 /**
339 * Get the user collected properties.
340 *
341 * @return the user collected properties.
342 */
343 public Map<String, String> getUserCollectedProperties() {
344 return userCollectedProperties;
345 }
346
347 /**
348 * Get the readable properties.
349 *
350 * @return the readable properties.
351 */
352 public Map<String, String> getReadableProperties() {
353 return readableProperties;
354 }
355
356 /**
357 * The offset of the value of each property in the file.
358 *
359 * @return the offset of each property.
360 */
361 public Map<String, Long> getPropertiesOffsets() {
362 return propertiesOffsets;
363 }
364
365 @Override
366 public boolean equals(Object o) {
367 if (this == o)
368 return true;
369 if (o == null || getClass() != o.getClass())
370 return false;
371 TableProperties that = (TableProperties) o;
372 return dataSize == that.dataSize && indexSize == that.indexSize
373 && indexPartitions == that.indexPartitions && topLevelIndexSize == that.topLevelIndexSize
374 && indexKeyIsUserKey == that.indexKeyIsUserKey
375 && indexValueIsDeltaEncoded == that.indexValueIsDeltaEncoded
376 && filterSize == that.filterSize && rawKeySize == that.rawKeySize
377 && rawValueSize == that.rawValueSize && numDataBlocks == that.numDataBlocks
378 && numEntries == that.numEntries && numDeletions == that.numDeletions
379 && numMergeOperands == that.numMergeOperands && numRangeDeletions == that.numRangeDeletions
380 && formatVersion == that.formatVersion && fixedKeyLen == that.fixedKeyLen
381 && columnFamilyId == that.columnFamilyId && creationTime == that.creationTime
382 && oldestKeyTime == that.oldestKeyTime
383 && Arrays.equals(columnFamilyName, that.columnFamilyName)
384 && Objects.equals(filterPolicyName, that.filterPolicyName)
385 && Objects.equals(comparatorName, that.comparatorName)
386 && Objects.equals(mergeOperatorName, that.mergeOperatorName)
387 && Objects.equals(prefixExtractorName, that.prefixExtractorName)
388 && Objects.equals(propertyCollectorsNames, that.propertyCollectorsNames)
389 && Objects.equals(compressionName, that.compressionName)
390 && Objects.equals(userCollectedProperties, that.userCollectedProperties)
391 && Objects.equals(readableProperties, that.readableProperties)
392 && Objects.equals(propertiesOffsets, that.propertiesOffsets);
393 }
394
395 @Override
396 public int hashCode() {
397 int result = Objects.hash(dataSize, indexSize, indexPartitions, topLevelIndexSize,
398 indexKeyIsUserKey, indexValueIsDeltaEncoded, filterSize, rawKeySize, rawValueSize,
399 numDataBlocks, numEntries, numDeletions, numMergeOperands, numRangeDeletions, formatVersion,
400 fixedKeyLen, columnFamilyId, creationTime, oldestKeyTime, filterPolicyName, comparatorName,
401 mergeOperatorName, prefixExtractorName, propertyCollectorsNames, compressionName,
402 userCollectedProperties, readableProperties, propertiesOffsets);
403 result = 31 * result + Arrays.hashCode(columnFamilyName);
404 return result;
405 }
406 }