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).
9 * Compaction Priorities
11 public enum CompactionPriority
{
14 * Slightly Prioritize larger files by size compensated by #deletes
16 ByCompensatedSize((byte)0x0),
19 * First compact files whose data's latest update time is oldest.
20 * Try this if you only update some hot keys in small ranges.
22 OldestLargestSeqFirst((byte)0x1),
25 * First compact files whose range hasn't been compacted to the next level
26 * for the longest. If your updates are random across the key space,
27 * write amplification is slightly better with this option.
29 OldestSmallestSeqFirst((byte)0x2),
32 * First compact files whose ratio between overlapping size in next level
33 * and its size is the smallest. It in many cases can optimize write
36 MinOverlappingRatio((byte)0x3);
39 private final byte value
;
41 CompactionPriority(final byte value
) {
46 * Returns the byte value of the enumerations value
48 * @return byte representation
50 public byte getValue() {
55 * Get CompactionPriority by byte value.
57 * @param value byte representation of CompactionPriority.
59 * @return {@link org.rocksdb.CompactionPriority} instance or null.
60 * @throws java.lang.IllegalArgumentException if an invalid
63 public static CompactionPriority
getCompactionPriority(final byte value
) {
64 for (final CompactionPriority compactionPriority
:
65 CompactionPriority
.values()) {
66 if (compactionPriority
.getValue() == value
){
67 return compactionPriority
;
70 throw new IllegalArgumentException(
71 "Illegal value provided for CompactionPriority.");