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