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).
8 public interface ColumnFamilyOptionsInterface
9 <T
extends ColumnFamilyOptionsInterface
>
10 extends AdvancedColumnFamilyOptionsInterface
<T
> {
13 * Use this if your DB is very small (like under 1GB) and you don't want to
14 * spend lots of memory for memtables.
16 * @return the instance of the current object.
18 T
optimizeForSmallDb();
21 * Use this if you don't need to keep the data sorted, i.e. you'll never use
22 * an iterator, only Put() and Get() API calls
24 * @param blockCacheSizeMb Block cache size in MB
25 * @return the instance of the current object.
27 T
optimizeForPointLookup(long blockCacheSizeMb
);
30 * <p>Default values for some parameters in ColumnFamilyOptions are not
31 * optimized for heavy workloads and big datasets, which means you might
32 * observe write stalls under some conditions. As a starting point for tuning
33 * RocksDB options, use the following for level style compaction.</p>
35 * <p>Make sure to also call IncreaseParallelism(), which will provide the
36 * biggest performance gains.</p>
37 * <p>Note: we might use more memory than memtable_memory_budget during high
38 * write rate period</p>
40 * @return the instance of the current object.
42 T
optimizeLevelStyleCompaction();
45 * <p>Default values for some parameters in ColumnFamilyOptions are not
46 * optimized for heavy workloads and big datasets, which means you might
47 * observe write stalls under some conditions. As a starting point for tuning
48 * RocksDB options, use the following for level style compaction.</p>
50 * <p>Make sure to also call IncreaseParallelism(), which will provide the
51 * biggest performance gains.</p>
52 * <p>Note: we might use more memory than memtable_memory_budget during high
53 * write rate period</p>
55 * @param memtableMemoryBudget memory budget in bytes
56 * @return the instance of the current object.
58 T
optimizeLevelStyleCompaction(
59 long memtableMemoryBudget
);
62 * <p>Default values for some parameters in ColumnFamilyOptions are not
63 * optimized for heavy workloads and big datasets, which means you might
64 * observe write stalls under some conditions. As a starting point for tuning
65 * RocksDB options, use the following for universal style compaction.</p>
67 * <p>Universal style compaction is focused on reducing Write Amplification
68 * Factor for big data sets, but increases Space Amplification.</p>
70 * <p>Make sure to also call IncreaseParallelism(), which will provide the
71 * biggest performance gains.</p>
73 * <p>Note: we might use more memory than memtable_memory_budget during high
74 * write rate period</p>
76 * @return the instance of the current object.
78 T
optimizeUniversalStyleCompaction();
81 * <p>Default values for some parameters in ColumnFamilyOptions are not
82 * optimized for heavy workloads and big datasets, which means you might
83 * observe write stalls under some conditions. As a starting point for tuning
84 * RocksDB options, use the following for universal style compaction.</p>
86 * <p>Universal style compaction is focused on reducing Write Amplification
87 * Factor for big data sets, but increases Space Amplification.</p>
89 * <p>Make sure to also call IncreaseParallelism(), which will provide the
90 * biggest performance gains.</p>
92 * <p>Note: we might use more memory than memtable_memory_budget during high
93 * write rate period</p>
95 * @param memtableMemoryBudget memory budget in bytes
96 * @return the instance of the current object.
98 T
optimizeUniversalStyleCompaction(
99 long memtableMemoryBudget
);
102 * Set {@link BuiltinComparator} to be used with RocksDB.
104 * Note: Comparator can be set once upon database creation.
106 * Default: BytewiseComparator.
107 * @param builtinComparator a {@link BuiltinComparator} type.
108 * @return the instance of the current object.
111 BuiltinComparator builtinComparator
);
114 * Use the specified comparator for key ordering.
116 * Comparator should not be disposed before options instances using this comparator is
117 * disposed. If dispose() function is not called, then comparator object will be
118 * GC'd automatically.
120 * Comparator instance can be re-used in multiple options instances.
122 * @param comparator java instance.
123 * @return the instance of the current object.
126 AbstractComparator
<?
extends AbstractSlice
<?
>> comparator
);
129 * <p>Set the merge operator to be used for merging two merge operands
130 * of the same key. The merge function is invoked during
131 * compaction and at lookup time, if multiple key/value pairs belonging
132 * to the same key are found in the database.</p>
134 * @param name the name of the merge function, as defined by
135 * the MergeOperators factory (see utilities/MergeOperators.h)
136 * The merge function is specified by name and must be one of the
137 * standard merge operators provided by RocksDB. The available
138 * operators are "put", "uint64add", "stringappend" and "stringappendtest".
139 * @return the instance of the current object.
141 T
setMergeOperatorName(String name
);
144 * <p>Set the merge operator to be used for merging two different key/value
145 * pairs that share the same key. The merge function is invoked during
146 * compaction and at lookup time, if multiple key/value pairs belonging
147 * to the same key are found in the database.</p>
149 * @param mergeOperator {@link MergeOperator} instance.
150 * @return the instance of the current object.
152 T
setMergeOperator(MergeOperator mergeOperator
);
155 * This prefix-extractor uses the first n bytes of a key as its prefix.
157 * In some hash-based memtable representation such as HashLinkedList
158 * and HashSkipList, prefixes are used to partition the keys into
159 * several buckets. Prefix extractor is used to specify how to
160 * extract the prefix given a key.
162 * @param n use the first n bytes of a key as its prefix.
163 * @return the reference to the current option.
165 T
useFixedLengthPrefixExtractor(int n
);
168 * Same as fixed length prefix extractor, except that when slice is
169 * shorter than the fixed length, it will use the full key.
171 * @param n use the first n bytes of a key as its prefix.
172 * @return the reference to the current option.
174 T
useCappedPrefixExtractor(int n
);
177 * Number of files to trigger level-0 compaction. A value < 0 means that
178 * level-0 compaction will not be triggered by number of files at all.
181 * @param numFiles the number of files in level-0 to trigger compaction.
182 * @return the reference to the current option.
184 T
setLevelZeroFileNumCompactionTrigger(
188 * The number of files in level 0 to trigger compaction from level-0 to
189 * level-1. A value < 0 means that level-0 compaction will not be
190 * triggered by number of files at all.
193 * @return the number of files in level 0 to trigger compaction.
195 int levelZeroFileNumCompactionTrigger();
198 * Soft limit on number of level-0 files. We start slowing down writes at this
199 * point. A value < 0 means that no writing slow down will be triggered by
200 * number of files in level-0.
202 * @param numFiles soft limit on number of level-0 files.
203 * @return the reference to the current option.
205 T
setLevelZeroSlowdownWritesTrigger(
209 * Soft limit on the number of level-0 files. We start slowing down writes
210 * at this point. A value < 0 means that no writing slow down will be
211 * triggered by number of files in level-0.
213 * @return the soft limit on the number of level-0 files.
215 int levelZeroSlowdownWritesTrigger();
218 * Maximum number of level-0 files. We stop writes at this point.
220 * @param numFiles the hard limit of the number of level-0 files.
221 * @return the reference to the current option.
223 T
setLevelZeroStopWritesTrigger(int numFiles
);
226 * Maximum number of level-0 files. We stop writes at this point.
228 * @return the hard limit of the number of level-0 file.
230 int levelZeroStopWritesTrigger();
233 * The ratio between the total size of level-(L+1) files and the total
234 * size of level-L files for all L.
237 * @param multiplier the ratio between the total size of level-(L+1)
238 * files and the total size of level-L files for all L.
239 * @return the reference to the current option.
241 T
setMaxBytesForLevelMultiplier(
245 * The ratio between the total size of level-(L+1) files and the total
246 * size of level-L files for all L.
249 * @return the ratio between the total size of level-(L+1) files and
250 * the total size of level-L files for all L.
252 double maxBytesForLevelMultiplier();
255 * FIFO compaction option.
256 * The oldest table file will be deleted
257 * once the sum of table files reaches this size.
258 * The default value is 1GB (1 * 1024 * 1024 * 1024).
260 * @param maxTableFilesSize the size limit of the total sum of table files.
261 * @return the instance of the current object.
263 T
setMaxTableFilesSizeFIFO(
264 long maxTableFilesSize
);
267 * FIFO compaction option.
268 * The oldest table file will be deleted
269 * once the sum of table files reaches this size.
270 * The default value is 1GB (1 * 1024 * 1024 * 1024).
272 * @return the size limit of the total sum of table files.
274 long maxTableFilesSizeFIFO();
277 * Get the config for mem-table.
279 * @return the mem-table config.
281 MemTableConfig
memTableConfig();
284 * Set the config for mem-table.
286 * @param memTableConfig the mem-table config.
287 * @return the instance of the current object.
288 * @throws java.lang.IllegalArgumentException thrown on 32-Bit platforms
289 * while overflowing the underlying platform specific value.
291 T
setMemTableConfig(MemTableConfig memTableConfig
);
294 * Returns the name of the current mem table representation.
295 * Memtable format can be set using setTableFormatConfig.
297 * @return the name of the currently-used memtable factory.
298 * @see #setTableFormatConfig(org.rocksdb.TableFormatConfig)
300 String
memTableFactoryName();
303 * Get the config for table format.
305 * @return the table format config.
307 TableFormatConfig
tableFormatConfig();
310 * Set the config for table format.
312 * @param config the table format config.
313 * @return the reference of the current options.
315 T
setTableFormatConfig(TableFormatConfig config
);
318 * @return the name of the currently used table factory.
320 String
tableFactoryName();
323 * Compression algorithm that will be used for the bottommost level that
324 * contain files. If level-compaction is used, this option will only affect
325 * levels after base level.
327 * Default: {@link CompressionType#DISABLE_COMPRESSION_OPTION}
329 * @param bottommostCompressionType The compression type to use for the
332 * @return the reference of the current options.
334 T
setBottommostCompressionType(
335 final CompressionType bottommostCompressionType
);
338 * Compression algorithm that will be used for the bottommost level that
339 * contain files. If level-compaction is used, this option will only affect
340 * levels after base level.
342 * Default: {@link CompressionType#DISABLE_COMPRESSION_OPTION}
344 * @return The compression type used for the bottommost level
346 CompressionType
bottommostCompressionType();
350 * Set the different options for compression algorithms
352 * @param compressionOptions The compression options
354 * @return the reference of the current options.
356 T
setCompressionOptions(
357 CompressionOptions compressionOptions
);
360 * Get the different options for compression algorithms
362 * @return The compression options
364 CompressionOptions
compressionOptions();
367 * Default memtable memory budget used with the following methods:
370 * <li>{@link #optimizeLevelStyleCompaction()}</li>
371 * <li>{@link #optimizeUniversalStyleCompaction()}</li>
374 long DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET
= 512 * 1024 * 1024;