/
CompactionStyle.java
80 lines (73 loc) · 2.49 KB
/
CompactionStyle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
// This source code is licensed under both the GPLv2 (found in the
// COPYING file in the root directory) and Apache 2.0 License
// (found in the LICENSE.Apache file in the root directory).
package org.rocksdb;
import java.util.List;
/**
* Enum CompactionStyle
*
* RocksDB supports different styles of compaction. Available
* compaction styles can be chosen using this enumeration.
*
* <ol>
* <li><strong>LEVEL</strong> - Level based Compaction style</li>
* <li><strong>UNIVERSAL</strong> - Universal Compaction Style is a
* compaction style, targeting the use cases requiring lower write
* amplification, trading off read amplification and space
* amplification.</li>
* <li><strong>FIFO</strong> - FIFO compaction style is the simplest
* compaction strategy. It is suited for keeping event log data with
* very low overhead (query log for example). It periodically deletes
* the old data, so it's basically a TTL compaction style.</li>
* <li><strong>NONE</strong> - Disable background compaction.
* Compaction jobs are submitted
* {@link RocksDB#compactFiles(CompactionOptions, ColumnFamilyHandle, List, int, int, CompactionJobInfo)} ()}.</li>
* </ol>
*
* @see <a
* href="https://github.com/facebook/rocksdb/wiki/Universal-Compaction">
* Universal Compaction</a>
* @see <a
* href="https://github.com/facebook/rocksdb/wiki/FIFO-compaction-style">
* FIFO Compaction</a>
*/
public enum CompactionStyle {
LEVEL((byte) 0x0),
UNIVERSAL((byte) 0x1),
FIFO((byte) 0x2),
NONE((byte) 0x3);
private final byte value;
CompactionStyle(final byte value) {
this.value = value;
}
/**
* Get the internal representation value.
*
* @return the internal representation value.
*/
//TODO(AR) should be made package-private
public byte getValue() {
return value;
}
/**
* Get the Compaction style from the internal representation value.
*
* @param value the internal representation value.
*
* @return the Compaction style
*
* @throws IllegalArgumentException if the value does not match a
* CompactionStyle
*/
static CompactionStyle fromValue(final byte value)
throws IllegalArgumentException {
for (final CompactionStyle compactionStyle : CompactionStyle.values()) {
if (compactionStyle.value == value) {
return compactionStyle;
}
}
throw new IllegalArgumentException("Unknown value for CompactionStyle: "
+ value);
}
}