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 * Keeps a cursor(s) of the successor of the file (key range) was/were
40 * compacted before, and always picks the next files (key range) in that
41 * level. The file picking process will cycle through all the files in a
44 RoundRobin((byte)0x4);
47 private final byte value
;
49 CompactionPriority(final byte value
) {
54 * Returns the byte value of the enumerations value
56 * @return byte representation
58 public byte getValue() {
63 * Get CompactionPriority by byte value.
65 * @param value byte representation of CompactionPriority.
67 * @return {@link org.rocksdb.CompactionPriority} instance or null.
68 * @throws java.lang.IllegalArgumentException if an invalid
71 public static CompactionPriority
getCompactionPriority(final byte value
) {
72 for (final CompactionPriority compactionPriority
:
73 CompactionPriority
.values()) {
74 if (compactionPriority
.getValue() == value
){
75 return compactionPriority
;
78 throw new IllegalArgumentException(
79 "Illegal value provided for CompactionPriority.");