]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
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). | |
7c673cae FG |
5 | |
6 | package org.rocksdb; | |
7 | ||
20effc67 TL |
8 | import java.nio.file.Paths; |
9 | import java.util.*; | |
7c673cae FG |
10 | |
11 | /** | |
12 | * ColumnFamilyOptions to control the behavior of a database. It will be used | |
13 | * during the creation of a {@link org.rocksdb.RocksDB} (i.e., RocksDB.open()). | |
14 | * | |
1e59de90 TL |
15 | * As a descendent of {@link AbstractNativeReference}, this class is {@link AutoCloseable} |
16 | * and will be automatically released if opened in the preamble of a try with resources block. | |
7c673cae FG |
17 | */ |
18 | public class ColumnFamilyOptions extends RocksObject | |
19 | implements ColumnFamilyOptionsInterface<ColumnFamilyOptions>, | |
20 | MutableColumnFamilyOptionsInterface<ColumnFamilyOptions> { | |
21 | static { | |
22 | RocksDB.loadLibrary(); | |
23 | } | |
24 | ||
25 | /** | |
26 | * Construct ColumnFamilyOptions. | |
27 | * | |
28 | * This constructor will create (by allocating a block of memory) | |
11fdf7f2 | 29 | * an {@code rocksdb::ColumnFamilyOptions} in the c++ side. |
7c673cae FG |
30 | */ |
31 | public ColumnFamilyOptions() { | |
32 | super(newColumnFamilyOptions()); | |
33 | } | |
34 | ||
11fdf7f2 TL |
35 | /** |
36 | * Copy constructor for ColumnFamilyOptions. | |
37 | * | |
38 | * NOTE: This does a shallow copy, which means comparator, merge_operator, compaction_filter, | |
39 | * compaction_filter_factory and other pointers will be cloned! | |
40 | * | |
41 | * @param other The ColumnFamilyOptions to copy. | |
42 | */ | |
43 | public ColumnFamilyOptions(ColumnFamilyOptions other) { | |
44 | super(copyColumnFamilyOptions(other.nativeHandle_)); | |
45 | this.memTableConfig_ = other.memTableConfig_; | |
46 | this.tableFormatConfig_ = other.tableFormatConfig_; | |
47 | this.comparator_ = other.comparator_; | |
48 | this.compactionFilter_ = other.compactionFilter_; | |
49 | this.compactionFilterFactory_ = other.compactionFilterFactory_; | |
50 | this.compactionOptionsUniversal_ = other.compactionOptionsUniversal_; | |
51 | this.compactionOptionsFIFO_ = other.compactionOptionsFIFO_; | |
494da23a | 52 | this.bottommostCompressionOptions_ = other.bottommostCompressionOptions_; |
11fdf7f2 | 53 | this.compressionOptions_ = other.compressionOptions_; |
20effc67 | 54 | this.compactionThreadLimiter_ = other.compactionThreadLimiter_; |
1e59de90 | 55 | this.sstPartitionerFactory_ = other.sstPartitionerFactory_; |
11fdf7f2 TL |
56 | } |
57 | ||
494da23a TL |
58 | /** |
59 | * Constructor from Options | |
60 | * | |
61 | * @param options The options. | |
62 | */ | |
63 | public ColumnFamilyOptions(final Options options) { | |
64 | super(newColumnFamilyOptionsFromOptions(options.nativeHandle_)); | |
65 | } | |
66 | ||
11fdf7f2 TL |
67 | /** |
68 | * <p>Constructor to be used by | |
69 | * {@link #getColumnFamilyOptionsFromProps(java.util.Properties)}, | |
f67539c2 | 70 | * {@link ColumnFamilyDescriptor#getOptions()} |
11fdf7f2 TL |
71 | * and also called via JNI.</p> |
72 | * | |
73 | * @param handle native handle to ColumnFamilyOptions instance. | |
74 | */ | |
75 | ColumnFamilyOptions(final long handle) { | |
76 | super(handle); | |
77 | } | |
78 | ||
7c673cae FG |
79 | /** |
80 | * <p>Method to get a options instance by using pre-configured | |
81 | * property values. If one or many values are undefined in | |
82 | * the context of RocksDB the method will return a null | |
83 | * value.</p> | |
84 | * | |
85 | * <p><strong>Note</strong>: Property keys can be derived from | |
86 | * getter methods within the options class. Example: the method | |
87 | * {@code writeBufferSize()} has a property key: | |
88 | * {@code write_buffer_size}.</p> | |
89 | * | |
90 | * @param properties {@link java.util.Properties} instance. | |
91 | * | |
92 | * @return {@link org.rocksdb.ColumnFamilyOptions instance} | |
93 | * or null. | |
94 | * | |
95 | * @throws java.lang.IllegalArgumentException if null or empty | |
96 | * {@link Properties} instance is passed to the method call. | |
97 | */ | |
98 | public static ColumnFamilyOptions getColumnFamilyOptionsFromProps( | |
99 | final Properties properties) { | |
7c673cae | 100 | ColumnFamilyOptions columnFamilyOptions = null; |
20effc67 TL |
101 | final long handle = |
102 | getColumnFamilyOptionsFromProps(Options.getOptionStringFromProps(properties)); | |
103 | if (handle != 0) { | |
104 | columnFamilyOptions = new ColumnFamilyOptions(handle); | |
7c673cae | 105 | } |
20effc67 TL |
106 | return columnFamilyOptions; |
107 | } | |
108 | ||
109 | /** | |
110 | * <p>Method to get a options instance by using pre-configured | |
111 | * property values. If one or many values are undefined in | |
112 | * the context of RocksDB the method will return a null | |
113 | * value.</p> | |
114 | * | |
115 | * <p><strong>Note</strong>: Property keys can be derived from | |
116 | * getter methods within the options class. Example: the method | |
117 | * {@code writeBufferSize()} has a property key: | |
118 | * {@code write_buffer_size}.</p> | |
119 | * | |
120 | * @param cfgOpts ConfigOptions controlling how the properties are parsed. | |
121 | * @param properties {@link java.util.Properties} instance. | |
122 | * | |
123 | * @return {@link org.rocksdb.ColumnFamilyOptions instance} | |
124 | * or null. | |
125 | * | |
126 | * @throws java.lang.IllegalArgumentException if null or empty | |
127 | * {@link Properties} instance is passed to the method call. | |
128 | */ | |
129 | public static ColumnFamilyOptions getColumnFamilyOptionsFromProps( | |
130 | final ConfigOptions cfgOpts, final Properties properties) { | |
131 | ColumnFamilyOptions columnFamilyOptions = null; | |
132 | final long handle = getColumnFamilyOptionsFromProps( | |
133 | cfgOpts.nativeHandle_, Options.getOptionStringFromProps(properties)); | |
7c673cae FG |
134 | if (handle != 0){ |
135 | columnFamilyOptions = new ColumnFamilyOptions(handle); | |
136 | } | |
137 | return columnFamilyOptions; | |
138 | } | |
139 | ||
20effc67 TL |
140 | @Override |
141 | public ColumnFamilyOptions oldDefaults(final int majorVersion, final int minorVersion) { | |
142 | oldDefaults(nativeHandle_, majorVersion, minorVersion); | |
143 | return this; | |
144 | } | |
145 | ||
7c673cae FG |
146 | @Override |
147 | public ColumnFamilyOptions optimizeForSmallDb() { | |
148 | optimizeForSmallDb(nativeHandle_); | |
149 | return this; | |
150 | } | |
151 | ||
20effc67 TL |
152 | @Override |
153 | public ColumnFamilyOptions optimizeForSmallDb(final Cache cache) { | |
154 | optimizeForSmallDb(nativeHandle_, cache.getNativeHandle()); | |
155 | return this; | |
156 | } | |
157 | ||
7c673cae FG |
158 | @Override |
159 | public ColumnFamilyOptions optimizeForPointLookup( | |
160 | final long blockCacheSizeMb) { | |
161 | optimizeForPointLookup(nativeHandle_, | |
162 | blockCacheSizeMb); | |
163 | return this; | |
164 | } | |
165 | ||
166 | @Override | |
167 | public ColumnFamilyOptions optimizeLevelStyleCompaction() { | |
168 | optimizeLevelStyleCompaction(nativeHandle_, | |
169 | DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET); | |
170 | return this; | |
171 | } | |
172 | ||
173 | @Override | |
174 | public ColumnFamilyOptions optimizeLevelStyleCompaction( | |
175 | final long memtableMemoryBudget) { | |
176 | optimizeLevelStyleCompaction(nativeHandle_, | |
177 | memtableMemoryBudget); | |
178 | return this; | |
179 | } | |
180 | ||
181 | @Override | |
182 | public ColumnFamilyOptions optimizeUniversalStyleCompaction() { | |
183 | optimizeUniversalStyleCompaction(nativeHandle_, | |
184 | DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET); | |
185 | return this; | |
186 | } | |
187 | ||
188 | @Override | |
189 | public ColumnFamilyOptions optimizeUniversalStyleCompaction( | |
190 | final long memtableMemoryBudget) { | |
191 | optimizeUniversalStyleCompaction(nativeHandle_, | |
192 | memtableMemoryBudget); | |
193 | return this; | |
194 | } | |
195 | ||
196 | @Override | |
197 | public ColumnFamilyOptions setComparator( | |
198 | final BuiltinComparator builtinComparator) { | |
199 | assert(isOwningHandle()); | |
200 | setComparatorHandle(nativeHandle_, builtinComparator.ordinal()); | |
201 | return this; | |
202 | } | |
203 | ||
204 | @Override | |
205 | public ColumnFamilyOptions setComparator( | |
f67539c2 | 206 | final AbstractComparator comparator) { |
7c673cae | 207 | assert (isOwningHandle()); |
11fdf7f2 TL |
208 | setComparatorHandle(nativeHandle_, comparator.nativeHandle_, |
209 | comparator.getComparatorType().getValue()); | |
7c673cae FG |
210 | comparator_ = comparator; |
211 | return this; | |
212 | } | |
213 | ||
214 | @Override | |
215 | public ColumnFamilyOptions setMergeOperatorName(final String name) { | |
216 | assert (isOwningHandle()); | |
217 | if (name == null) { | |
218 | throw new IllegalArgumentException( | |
219 | "Merge operator name must not be null."); | |
220 | } | |
221 | setMergeOperatorName(nativeHandle_, name); | |
222 | return this; | |
223 | } | |
224 | ||
225 | @Override | |
226 | public ColumnFamilyOptions setMergeOperator( | |
227 | final MergeOperator mergeOperator) { | |
228 | setMergeOperator(nativeHandle_, mergeOperator.nativeHandle_); | |
229 | return this; | |
230 | } | |
231 | ||
494da23a | 232 | @Override |
7c673cae FG |
233 | public ColumnFamilyOptions setCompactionFilter( |
234 | final AbstractCompactionFilter<? extends AbstractSlice<?>> | |
235 | compactionFilter) { | |
236 | setCompactionFilterHandle(nativeHandle_, compactionFilter.nativeHandle_); | |
237 | compactionFilter_ = compactionFilter; | |
238 | return this; | |
239 | } | |
240 | ||
494da23a TL |
241 | @Override |
242 | public AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter() { | |
243 | assert (isOwningHandle()); | |
244 | return compactionFilter_; | |
245 | } | |
246 | ||
247 | @Override | |
11fdf7f2 TL |
248 | public ColumnFamilyOptions setCompactionFilterFactory(final AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> compactionFilterFactory) { |
249 | assert (isOwningHandle()); | |
250 | setCompactionFilterFactoryHandle(nativeHandle_, compactionFilterFactory.nativeHandle_); | |
251 | compactionFilterFactory_ = compactionFilterFactory; | |
252 | return this; | |
253 | } | |
254 | ||
494da23a TL |
255 | @Override |
256 | public AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> compactionFilterFactory() { | |
257 | assert (isOwningHandle()); | |
258 | return compactionFilterFactory_; | |
259 | } | |
260 | ||
7c673cae FG |
261 | @Override |
262 | public ColumnFamilyOptions setWriteBufferSize(final long writeBufferSize) { | |
263 | assert(isOwningHandle()); | |
264 | setWriteBufferSize(nativeHandle_, writeBufferSize); | |
265 | return this; | |
266 | } | |
267 | ||
268 | @Override | |
269 | public long writeBufferSize() { | |
270 | assert(isOwningHandle()); | |
271 | return writeBufferSize(nativeHandle_); | |
272 | } | |
273 | ||
274 | @Override | |
275 | public ColumnFamilyOptions setMaxWriteBufferNumber( | |
276 | final int maxWriteBufferNumber) { | |
277 | assert(isOwningHandle()); | |
278 | setMaxWriteBufferNumber(nativeHandle_, maxWriteBufferNumber); | |
279 | return this; | |
280 | } | |
281 | ||
282 | @Override | |
283 | public int maxWriteBufferNumber() { | |
284 | assert(isOwningHandle()); | |
285 | return maxWriteBufferNumber(nativeHandle_); | |
286 | } | |
287 | ||
288 | @Override | |
289 | public ColumnFamilyOptions setMinWriteBufferNumberToMerge( | |
290 | final int minWriteBufferNumberToMerge) { | |
291 | setMinWriteBufferNumberToMerge(nativeHandle_, minWriteBufferNumberToMerge); | |
292 | return this; | |
293 | } | |
294 | ||
295 | @Override | |
296 | public int minWriteBufferNumberToMerge() { | |
297 | return minWriteBufferNumberToMerge(nativeHandle_); | |
298 | } | |
299 | ||
300 | @Override | |
301 | public ColumnFamilyOptions useFixedLengthPrefixExtractor(final int n) { | |
302 | assert(isOwningHandle()); | |
303 | useFixedLengthPrefixExtractor(nativeHandle_, n); | |
304 | return this; | |
305 | } | |
306 | ||
307 | @Override | |
308 | public ColumnFamilyOptions useCappedPrefixExtractor(final int n) { | |
309 | assert(isOwningHandle()); | |
310 | useCappedPrefixExtractor(nativeHandle_, n); | |
311 | return this; | |
312 | } | |
313 | ||
314 | @Override | |
315 | public ColumnFamilyOptions setCompressionType( | |
316 | final CompressionType compressionType) { | |
317 | setCompressionType(nativeHandle_, compressionType.getValue()); | |
318 | return this; | |
319 | } | |
320 | ||
321 | @Override | |
322 | public CompressionType compressionType() { | |
323 | return CompressionType.getCompressionType(compressionType(nativeHandle_)); | |
324 | } | |
325 | ||
326 | @Override | |
327 | public ColumnFamilyOptions setCompressionPerLevel( | |
328 | final List<CompressionType> compressionLevels) { | |
329 | final byte[] byteCompressionTypes = new byte[ | |
330 | compressionLevels.size()]; | |
331 | for (int i = 0; i < compressionLevels.size(); i++) { | |
332 | byteCompressionTypes[i] = compressionLevels.get(i).getValue(); | |
333 | } | |
334 | setCompressionPerLevel(nativeHandle_, byteCompressionTypes); | |
335 | return this; | |
336 | } | |
337 | ||
338 | @Override | |
339 | public List<CompressionType> compressionPerLevel() { | |
340 | final byte[] byteCompressionTypes = | |
341 | compressionPerLevel(nativeHandle_); | |
342 | final List<CompressionType> compressionLevels = new ArrayList<>(); | |
1e59de90 | 343 | for (final byte byteCompressionType : byteCompressionTypes) { |
7c673cae FG |
344 | compressionLevels.add(CompressionType.getCompressionType( |
345 | byteCompressionType)); | |
346 | } | |
347 | return compressionLevels; | |
348 | } | |
349 | ||
350 | @Override | |
351 | public ColumnFamilyOptions setBottommostCompressionType( | |
352 | final CompressionType bottommostCompressionType) { | |
353 | setBottommostCompressionType(nativeHandle_, | |
354 | bottommostCompressionType.getValue()); | |
355 | return this; | |
356 | } | |
357 | ||
358 | @Override | |
359 | public CompressionType bottommostCompressionType() { | |
360 | return CompressionType.getCompressionType( | |
361 | bottommostCompressionType(nativeHandle_)); | |
362 | } | |
363 | ||
494da23a TL |
364 | @Override |
365 | public ColumnFamilyOptions setBottommostCompressionOptions( | |
366 | final CompressionOptions bottommostCompressionOptions) { | |
367 | setBottommostCompressionOptions(nativeHandle_, | |
368 | bottommostCompressionOptions.nativeHandle_); | |
369 | this.bottommostCompressionOptions_ = bottommostCompressionOptions; | |
370 | return this; | |
371 | } | |
372 | ||
373 | @Override | |
374 | public CompressionOptions bottommostCompressionOptions() { | |
375 | return this.bottommostCompressionOptions_; | |
376 | } | |
377 | ||
7c673cae FG |
378 | @Override |
379 | public ColumnFamilyOptions setCompressionOptions( | |
380 | final CompressionOptions compressionOptions) { | |
381 | setCompressionOptions(nativeHandle_, compressionOptions.nativeHandle_); | |
382 | this.compressionOptions_ = compressionOptions; | |
383 | return this; | |
384 | } | |
385 | ||
386 | @Override | |
387 | public CompressionOptions compressionOptions() { | |
388 | return this.compressionOptions_; | |
389 | } | |
390 | ||
391 | @Override | |
392 | public ColumnFamilyOptions setNumLevels(final int numLevels) { | |
393 | setNumLevels(nativeHandle_, numLevels); | |
394 | return this; | |
395 | } | |
396 | ||
397 | @Override | |
398 | public int numLevels() { | |
399 | return numLevels(nativeHandle_); | |
400 | } | |
401 | ||
402 | @Override | |
403 | public ColumnFamilyOptions setLevelZeroFileNumCompactionTrigger( | |
404 | final int numFiles) { | |
405 | setLevelZeroFileNumCompactionTrigger( | |
406 | nativeHandle_, numFiles); | |
407 | return this; | |
408 | } | |
409 | ||
410 | @Override | |
411 | public int levelZeroFileNumCompactionTrigger() { | |
412 | return levelZeroFileNumCompactionTrigger(nativeHandle_); | |
413 | } | |
414 | ||
415 | @Override | |
416 | public ColumnFamilyOptions setLevelZeroSlowdownWritesTrigger( | |
417 | final int numFiles) { | |
418 | setLevelZeroSlowdownWritesTrigger(nativeHandle_, numFiles); | |
419 | return this; | |
420 | } | |
421 | ||
422 | @Override | |
423 | public int levelZeroSlowdownWritesTrigger() { | |
424 | return levelZeroSlowdownWritesTrigger(nativeHandle_); | |
425 | } | |
426 | ||
427 | @Override | |
428 | public ColumnFamilyOptions setLevelZeroStopWritesTrigger(final int numFiles) { | |
429 | setLevelZeroStopWritesTrigger(nativeHandle_, numFiles); | |
430 | return this; | |
431 | } | |
432 | ||
433 | @Override | |
434 | public int levelZeroStopWritesTrigger() { | |
435 | return levelZeroStopWritesTrigger(nativeHandle_); | |
436 | } | |
437 | ||
438 | @Override | |
439 | public ColumnFamilyOptions setTargetFileSizeBase( | |
440 | final long targetFileSizeBase) { | |
441 | setTargetFileSizeBase(nativeHandle_, targetFileSizeBase); | |
442 | return this; | |
443 | } | |
444 | ||
445 | @Override | |
446 | public long targetFileSizeBase() { | |
447 | return targetFileSizeBase(nativeHandle_); | |
448 | } | |
449 | ||
450 | @Override | |
451 | public ColumnFamilyOptions setTargetFileSizeMultiplier( | |
452 | final int multiplier) { | |
453 | setTargetFileSizeMultiplier(nativeHandle_, multiplier); | |
454 | return this; | |
455 | } | |
456 | ||
457 | @Override | |
458 | public int targetFileSizeMultiplier() { | |
459 | return targetFileSizeMultiplier(nativeHandle_); | |
460 | } | |
461 | ||
462 | @Override | |
463 | public ColumnFamilyOptions setMaxBytesForLevelBase( | |
464 | final long maxBytesForLevelBase) { | |
465 | setMaxBytesForLevelBase(nativeHandle_, maxBytesForLevelBase); | |
466 | return this; | |
467 | } | |
468 | ||
469 | @Override | |
470 | public long maxBytesForLevelBase() { | |
471 | return maxBytesForLevelBase(nativeHandle_); | |
472 | } | |
473 | ||
474 | @Override | |
475 | public ColumnFamilyOptions setLevelCompactionDynamicLevelBytes( | |
476 | final boolean enableLevelCompactionDynamicLevelBytes) { | |
477 | setLevelCompactionDynamicLevelBytes(nativeHandle_, | |
478 | enableLevelCompactionDynamicLevelBytes); | |
479 | return this; | |
480 | } | |
481 | ||
482 | @Override | |
483 | public boolean levelCompactionDynamicLevelBytes() { | |
484 | return levelCompactionDynamicLevelBytes(nativeHandle_); | |
485 | } | |
486 | ||
487 | @Override | |
488 | public ColumnFamilyOptions setMaxBytesForLevelMultiplier(final double multiplier) { | |
489 | setMaxBytesForLevelMultiplier(nativeHandle_, multiplier); | |
490 | return this; | |
491 | } | |
492 | ||
493 | @Override | |
494 | public double maxBytesForLevelMultiplier() { | |
495 | return maxBytesForLevelMultiplier(nativeHandle_); | |
496 | } | |
497 | ||
498 | @Override | |
499 | public ColumnFamilyOptions setMaxCompactionBytes(final long maxCompactionBytes) { | |
500 | setMaxCompactionBytes(nativeHandle_, maxCompactionBytes); | |
501 | return this; | |
502 | } | |
503 | ||
504 | @Override | |
505 | public long maxCompactionBytes() { | |
506 | return maxCompactionBytes(nativeHandle_); | |
507 | } | |
508 | ||
509 | @Override | |
510 | public ColumnFamilyOptions setArenaBlockSize( | |
511 | final long arenaBlockSize) { | |
512 | setArenaBlockSize(nativeHandle_, arenaBlockSize); | |
513 | return this; | |
514 | } | |
515 | ||
516 | @Override | |
517 | public long arenaBlockSize() { | |
518 | return arenaBlockSize(nativeHandle_); | |
519 | } | |
520 | ||
521 | @Override | |
522 | public ColumnFamilyOptions setDisableAutoCompactions( | |
523 | final boolean disableAutoCompactions) { | |
524 | setDisableAutoCompactions(nativeHandle_, disableAutoCompactions); | |
525 | return this; | |
526 | } | |
527 | ||
528 | @Override | |
529 | public boolean disableAutoCompactions() { | |
530 | return disableAutoCompactions(nativeHandle_); | |
531 | } | |
532 | ||
533 | @Override | |
534 | public ColumnFamilyOptions setCompactionStyle( | |
535 | final CompactionStyle compactionStyle) { | |
536 | setCompactionStyle(nativeHandle_, compactionStyle.getValue()); | |
537 | return this; | |
538 | } | |
539 | ||
540 | @Override | |
541 | public CompactionStyle compactionStyle() { | |
494da23a | 542 | return CompactionStyle.fromValue(compactionStyle(nativeHandle_)); |
7c673cae FG |
543 | } |
544 | ||
545 | @Override | |
546 | public ColumnFamilyOptions setMaxTableFilesSizeFIFO( | |
547 | final long maxTableFilesSize) { | |
548 | assert(maxTableFilesSize > 0); // unsigned native type | |
549 | assert(isOwningHandle()); | |
550 | setMaxTableFilesSizeFIFO(nativeHandle_, maxTableFilesSize); | |
551 | return this; | |
552 | } | |
553 | ||
554 | @Override | |
555 | public long maxTableFilesSizeFIFO() { | |
556 | return maxTableFilesSizeFIFO(nativeHandle_); | |
557 | } | |
558 | ||
559 | @Override | |
560 | public ColumnFamilyOptions setMaxSequentialSkipInIterations( | |
561 | final long maxSequentialSkipInIterations) { | |
562 | setMaxSequentialSkipInIterations(nativeHandle_, | |
563 | maxSequentialSkipInIterations); | |
564 | return this; | |
565 | } | |
566 | ||
567 | @Override | |
568 | public long maxSequentialSkipInIterations() { | |
569 | return maxSequentialSkipInIterations(nativeHandle_); | |
570 | } | |
571 | ||
572 | @Override | |
573 | public MemTableConfig memTableConfig() { | |
574 | return this.memTableConfig_; | |
575 | } | |
576 | ||
577 | @Override | |
578 | public ColumnFamilyOptions setMemTableConfig( | |
579 | final MemTableConfig memTableConfig) { | |
580 | setMemTableFactory( | |
581 | nativeHandle_, memTableConfig.newMemTableFactoryHandle()); | |
582 | this.memTableConfig_ = memTableConfig; | |
583 | return this; | |
584 | } | |
585 | ||
586 | @Override | |
587 | public String memTableFactoryName() { | |
588 | assert(isOwningHandle()); | |
589 | return memTableFactoryName(nativeHandle_); | |
590 | } | |
591 | ||
592 | @Override | |
593 | public TableFormatConfig tableFormatConfig() { | |
594 | return this.tableFormatConfig_; | |
595 | } | |
596 | ||
597 | @Override | |
598 | public ColumnFamilyOptions setTableFormatConfig( | |
599 | final TableFormatConfig tableFormatConfig) { | |
600 | setTableFactory(nativeHandle_, tableFormatConfig.newTableFactoryHandle()); | |
601 | this.tableFormatConfig_ = tableFormatConfig; | |
602 | return this; | |
603 | } | |
604 | ||
605 | @Override | |
606 | public String tableFactoryName() { | |
607 | assert(isOwningHandle()); | |
608 | return tableFactoryName(nativeHandle_); | |
609 | } | |
610 | ||
20effc67 TL |
611 | @Override |
612 | public ColumnFamilyOptions setCfPaths(final Collection<DbPath> cfPaths) { | |
613 | assert (isOwningHandle()); | |
614 | ||
615 | final int len = cfPaths.size(); | |
1e59de90 TL |
616 | final String[] paths = new String[len]; |
617 | final long[] targetSizes = new long[len]; | |
20effc67 TL |
618 | |
619 | int i = 0; | |
620 | for (final DbPath dbPath : cfPaths) { | |
621 | paths[i] = dbPath.path.toString(); | |
622 | targetSizes[i] = dbPath.targetSize; | |
623 | i++; | |
624 | } | |
625 | setCfPaths(nativeHandle_, paths, targetSizes); | |
626 | return this; | |
627 | } | |
628 | ||
629 | @Override | |
630 | public List<DbPath> cfPaths() { | |
631 | final int len = (int) cfPathsLen(nativeHandle_); | |
632 | ||
633 | if (len == 0) { | |
634 | return Collections.emptyList(); | |
635 | } | |
636 | ||
1e59de90 TL |
637 | final String[] paths = new String[len]; |
638 | final long[] targetSizes = new long[len]; | |
20effc67 TL |
639 | |
640 | cfPaths(nativeHandle_, paths, targetSizes); | |
641 | ||
642 | final List<DbPath> cfPaths = new ArrayList<>(); | |
643 | for (int i = 0; i < len; i++) { | |
644 | cfPaths.add(new DbPath(Paths.get(paths[i]), targetSizes[i])); | |
645 | } | |
646 | ||
647 | return cfPaths; | |
648 | } | |
649 | ||
7c673cae FG |
650 | @Override |
651 | public ColumnFamilyOptions setInplaceUpdateSupport( | |
652 | final boolean inplaceUpdateSupport) { | |
653 | setInplaceUpdateSupport(nativeHandle_, inplaceUpdateSupport); | |
654 | return this; | |
655 | } | |
656 | ||
657 | @Override | |
658 | public boolean inplaceUpdateSupport() { | |
659 | return inplaceUpdateSupport(nativeHandle_); | |
660 | } | |
661 | ||
662 | @Override | |
663 | public ColumnFamilyOptions setInplaceUpdateNumLocks( | |
664 | final long inplaceUpdateNumLocks) { | |
665 | setInplaceUpdateNumLocks(nativeHandle_, inplaceUpdateNumLocks); | |
666 | return this; | |
667 | } | |
668 | ||
669 | @Override | |
670 | public long inplaceUpdateNumLocks() { | |
671 | return inplaceUpdateNumLocks(nativeHandle_); | |
672 | } | |
673 | ||
674 | @Override | |
675 | public ColumnFamilyOptions setMemtablePrefixBloomSizeRatio( | |
676 | final double memtablePrefixBloomSizeRatio) { | |
677 | setMemtablePrefixBloomSizeRatio(nativeHandle_, memtablePrefixBloomSizeRatio); | |
678 | return this; | |
679 | } | |
680 | ||
681 | @Override | |
682 | public double memtablePrefixBloomSizeRatio() { | |
683 | return memtablePrefixBloomSizeRatio(nativeHandle_); | |
684 | } | |
685 | ||
1e59de90 TL |
686 | @Override |
687 | public ColumnFamilyOptions setExperimentalMempurgeThreshold( | |
688 | final double experimentalMempurgeThreshold) { | |
689 | setExperimentalMempurgeThreshold(nativeHandle_, experimentalMempurgeThreshold); | |
690 | return this; | |
691 | } | |
692 | ||
693 | @Override | |
694 | public double experimentalMempurgeThreshold() { | |
695 | return experimentalMempurgeThreshold(nativeHandle_); | |
696 | } | |
697 | ||
698 | @Override | |
699 | public ColumnFamilyOptions setMemtableWholeKeyFiltering(final boolean memtableWholeKeyFiltering) { | |
700 | setMemtableWholeKeyFiltering(nativeHandle_, memtableWholeKeyFiltering); | |
701 | return this; | |
702 | } | |
703 | ||
704 | @Override | |
705 | public boolean memtableWholeKeyFiltering() { | |
706 | return memtableWholeKeyFiltering(nativeHandle_); | |
707 | } | |
708 | ||
7c673cae FG |
709 | @Override |
710 | public ColumnFamilyOptions setBloomLocality(int bloomLocality) { | |
711 | setBloomLocality(nativeHandle_, bloomLocality); | |
712 | return this; | |
713 | } | |
714 | ||
715 | @Override | |
716 | public int bloomLocality() { | |
717 | return bloomLocality(nativeHandle_); | |
718 | } | |
719 | ||
720 | @Override | |
721 | public ColumnFamilyOptions setMaxSuccessiveMerges( | |
722 | final long maxSuccessiveMerges) { | |
723 | setMaxSuccessiveMerges(nativeHandle_, maxSuccessiveMerges); | |
724 | return this; | |
725 | } | |
726 | ||
727 | @Override | |
728 | public long maxSuccessiveMerges() { | |
729 | return maxSuccessiveMerges(nativeHandle_); | |
730 | } | |
731 | ||
732 | @Override | |
733 | public ColumnFamilyOptions setOptimizeFiltersForHits( | |
734 | final boolean optimizeFiltersForHits) { | |
735 | setOptimizeFiltersForHits(nativeHandle_, optimizeFiltersForHits); | |
736 | return this; | |
737 | } | |
738 | ||
739 | @Override | |
740 | public boolean optimizeFiltersForHits() { | |
741 | return optimizeFiltersForHits(nativeHandle_); | |
742 | } | |
743 | ||
744 | @Override | |
745 | public ColumnFamilyOptions | |
746 | setMemtableHugePageSize( | |
747 | long memtableHugePageSize) { | |
748 | setMemtableHugePageSize(nativeHandle_, | |
749 | memtableHugePageSize); | |
750 | return this; | |
751 | } | |
752 | ||
753 | @Override | |
754 | public long memtableHugePageSize() { | |
755 | return memtableHugePageSize(nativeHandle_); | |
756 | } | |
757 | ||
758 | @Override | |
759 | public ColumnFamilyOptions setSoftPendingCompactionBytesLimit(long softPendingCompactionBytesLimit) { | |
760 | setSoftPendingCompactionBytesLimit(nativeHandle_, | |
761 | softPendingCompactionBytesLimit); | |
762 | return this; | |
763 | } | |
764 | ||
765 | @Override | |
766 | public long softPendingCompactionBytesLimit() { | |
767 | return softPendingCompactionBytesLimit(nativeHandle_); | |
768 | } | |
769 | ||
770 | @Override | |
771 | public ColumnFamilyOptions setHardPendingCompactionBytesLimit(long hardPendingCompactionBytesLimit) { | |
772 | setHardPendingCompactionBytesLimit(nativeHandle_, hardPendingCompactionBytesLimit); | |
773 | return this; | |
774 | } | |
775 | ||
776 | @Override | |
777 | public long hardPendingCompactionBytesLimit() { | |
778 | return hardPendingCompactionBytesLimit(nativeHandle_); | |
779 | } | |
780 | ||
781 | @Override | |
782 | public ColumnFamilyOptions setLevel0FileNumCompactionTrigger(int level0FileNumCompactionTrigger) { | |
783 | setLevel0FileNumCompactionTrigger(nativeHandle_, level0FileNumCompactionTrigger); | |
784 | return this; | |
785 | } | |
786 | ||
787 | @Override | |
788 | public int level0FileNumCompactionTrigger() { | |
789 | return level0FileNumCompactionTrigger(nativeHandle_); | |
790 | } | |
791 | ||
792 | @Override | |
793 | public ColumnFamilyOptions setLevel0SlowdownWritesTrigger(int level0SlowdownWritesTrigger) { | |
794 | setLevel0SlowdownWritesTrigger(nativeHandle_, level0SlowdownWritesTrigger); | |
795 | return this; | |
796 | } | |
797 | ||
798 | @Override | |
799 | public int level0SlowdownWritesTrigger() { | |
800 | return level0SlowdownWritesTrigger(nativeHandle_); | |
801 | } | |
802 | ||
803 | @Override | |
804 | public ColumnFamilyOptions setLevel0StopWritesTrigger(int level0StopWritesTrigger) { | |
805 | setLevel0StopWritesTrigger(nativeHandle_, level0StopWritesTrigger); | |
806 | return this; | |
807 | } | |
808 | ||
809 | @Override | |
810 | public int level0StopWritesTrigger() { | |
811 | return level0StopWritesTrigger(nativeHandle_); | |
812 | } | |
813 | ||
814 | @Override | |
815 | public ColumnFamilyOptions setMaxBytesForLevelMultiplierAdditional(int[] maxBytesForLevelMultiplierAdditional) { | |
816 | setMaxBytesForLevelMultiplierAdditional(nativeHandle_, maxBytesForLevelMultiplierAdditional); | |
817 | return this; | |
818 | } | |
819 | ||
820 | @Override | |
821 | public int[] maxBytesForLevelMultiplierAdditional() { | |
822 | return maxBytesForLevelMultiplierAdditional(nativeHandle_); | |
823 | } | |
824 | ||
825 | @Override | |
826 | public ColumnFamilyOptions setParanoidFileChecks(boolean paranoidFileChecks) { | |
827 | setParanoidFileChecks(nativeHandle_, paranoidFileChecks); | |
828 | return this; | |
829 | } | |
830 | ||
831 | @Override | |
832 | public boolean paranoidFileChecks() { | |
833 | return paranoidFileChecks(nativeHandle_); | |
834 | } | |
835 | ||
836 | @Override | |
837 | public ColumnFamilyOptions setMaxWriteBufferNumberToMaintain( | |
838 | final int maxWriteBufferNumberToMaintain) { | |
839 | setMaxWriteBufferNumberToMaintain( | |
840 | nativeHandle_, maxWriteBufferNumberToMaintain); | |
841 | return this; | |
842 | } | |
843 | ||
844 | @Override | |
845 | public int maxWriteBufferNumberToMaintain() { | |
846 | return maxWriteBufferNumberToMaintain(nativeHandle_); | |
847 | } | |
848 | ||
849 | @Override | |
850 | public ColumnFamilyOptions setCompactionPriority( | |
851 | final CompactionPriority compactionPriority) { | |
852 | setCompactionPriority(nativeHandle_, compactionPriority.getValue()); | |
853 | return this; | |
854 | } | |
855 | ||
856 | @Override | |
857 | public CompactionPriority compactionPriority() { | |
858 | return CompactionPriority.getCompactionPriority( | |
859 | compactionPriority(nativeHandle_)); | |
860 | } | |
861 | ||
862 | @Override | |
863 | public ColumnFamilyOptions setReportBgIoStats(final boolean reportBgIoStats) { | |
864 | setReportBgIoStats(nativeHandle_, reportBgIoStats); | |
865 | return this; | |
866 | } | |
867 | ||
868 | @Override | |
869 | public boolean reportBgIoStats() { | |
870 | return reportBgIoStats(nativeHandle_); | |
871 | } | |
872 | ||
494da23a TL |
873 | @Override |
874 | public ColumnFamilyOptions setTtl(final long ttl) { | |
875 | setTtl(nativeHandle_, ttl); | |
876 | return this; | |
877 | } | |
878 | ||
879 | @Override | |
880 | public long ttl() { | |
881 | return ttl(nativeHandle_); | |
882 | } | |
883 | ||
1e59de90 TL |
884 | @Override |
885 | public ColumnFamilyOptions setPeriodicCompactionSeconds(final long periodicCompactionSeconds) { | |
886 | setPeriodicCompactionSeconds(nativeHandle_, periodicCompactionSeconds); | |
887 | return this; | |
888 | } | |
889 | ||
890 | @Override | |
891 | public long periodicCompactionSeconds() { | |
892 | return periodicCompactionSeconds(nativeHandle_); | |
893 | } | |
894 | ||
7c673cae FG |
895 | @Override |
896 | public ColumnFamilyOptions setCompactionOptionsUniversal( | |
897 | final CompactionOptionsUniversal compactionOptionsUniversal) { | |
898 | setCompactionOptionsUniversal(nativeHandle_, | |
899 | compactionOptionsUniversal.nativeHandle_); | |
900 | this.compactionOptionsUniversal_ = compactionOptionsUniversal; | |
901 | return this; | |
902 | } | |
903 | ||
904 | @Override | |
905 | public CompactionOptionsUniversal compactionOptionsUniversal() { | |
906 | return this.compactionOptionsUniversal_; | |
907 | } | |
908 | ||
909 | @Override | |
910 | public ColumnFamilyOptions setCompactionOptionsFIFO(final CompactionOptionsFIFO compactionOptionsFIFO) { | |
911 | setCompactionOptionsFIFO(nativeHandle_, | |
912 | compactionOptionsFIFO.nativeHandle_); | |
913 | this.compactionOptionsFIFO_ = compactionOptionsFIFO; | |
914 | return this; | |
915 | } | |
916 | ||
917 | @Override | |
918 | public CompactionOptionsFIFO compactionOptionsFIFO() { | |
919 | return this.compactionOptionsFIFO_; | |
920 | } | |
921 | ||
922 | @Override | |
923 | public ColumnFamilyOptions setForceConsistencyChecks(final boolean forceConsistencyChecks) { | |
924 | setForceConsistencyChecks(nativeHandle_, forceConsistencyChecks); | |
925 | return this; | |
926 | } | |
927 | ||
928 | @Override | |
929 | public boolean forceConsistencyChecks() { | |
930 | return forceConsistencyChecks(nativeHandle_); | |
931 | } | |
932 | ||
20effc67 TL |
933 | @Override |
934 | public ColumnFamilyOptions setSstPartitionerFactory(SstPartitionerFactory sstPartitionerFactory) { | |
935 | setSstPartitionerFactory(nativeHandle_, sstPartitionerFactory.nativeHandle_); | |
936 | this.sstPartitionerFactory_ = sstPartitionerFactory; | |
937 | return this; | |
938 | } | |
939 | ||
940 | @Override | |
941 | public ColumnFamilyOptions setCompactionThreadLimiter( | |
942 | final ConcurrentTaskLimiter compactionThreadLimiter) { | |
943 | setCompactionThreadLimiter(nativeHandle_, compactionThreadLimiter.nativeHandle_); | |
944 | this.compactionThreadLimiter_ = compactionThreadLimiter; | |
945 | return this; | |
946 | } | |
947 | ||
948 | @Override | |
949 | public ConcurrentTaskLimiter compactionThreadLimiter() { | |
950 | assert (isOwningHandle()); | |
951 | return this.compactionThreadLimiter_; | |
952 | } | |
953 | ||
954 | @Override | |
955 | public SstPartitionerFactory sstPartitionerFactory() { | |
956 | return sstPartitionerFactory_; | |
957 | } | |
958 | ||
1e59de90 TL |
959 | // |
960 | // BEGIN options for blobs (integrated BlobDB) | |
961 | // | |
962 | ||
963 | /** | |
964 | * When set, large values (blobs) are written to separate blob files, and only | |
965 | * pointers to them are stored in SST files. This can reduce write amplification | |
966 | * for large-value use cases at the cost of introducing a level of indirection | |
967 | * for reads. See also the options min_blob_size, blob_file_size, | |
968 | * blob_compression_type, enable_blob_garbage_collection, and | |
969 | * blob_garbage_collection_age_cutoff below. | |
970 | * | |
971 | * Default: false | |
972 | * | |
973 | * Dynamically changeable through | |
974 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
975 | * | |
976 | * @param enableBlobFiles true iff blob files should be enabled | |
977 | * | |
978 | * @return the reference to the current options. | |
979 | */ | |
980 | @Override | |
981 | public ColumnFamilyOptions setEnableBlobFiles(final boolean enableBlobFiles) { | |
982 | setEnableBlobFiles(nativeHandle_, enableBlobFiles); | |
983 | return this; | |
984 | } | |
985 | ||
986 | /** | |
987 | * When set, large values (blobs) are written to separate blob files, and only | |
988 | * pointers to them are stored in SST files. This can reduce write amplification | |
989 | * for large-value use cases at the cost of introducing a level of indirection | |
990 | * for reads. See also the options min_blob_size, blob_file_size, | |
991 | * blob_compression_type, enable_blob_garbage_collection, and | |
992 | * blob_garbage_collection_age_cutoff below. | |
993 | * | |
994 | * Default: false | |
995 | * | |
996 | * Dynamically changeable through | |
997 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
998 | * | |
999 | * @return true iff blob files are currently enabled | |
1000 | */ | |
1001 | public boolean enableBlobFiles() { | |
1002 | return enableBlobFiles(nativeHandle_); | |
1003 | } | |
1004 | ||
1005 | /** | |
1006 | * Set the size of the smallest value to be stored separately in a blob file. Values | |
1007 | * which have an uncompressed size smaller than this threshold are stored | |
1008 | * alongside the keys in SST files in the usual fashion. A value of zero for | |
1009 | * this option means that all values are stored in blob files. Note that | |
1010 | * enable_blob_files has to be set in order for this option to have any effect. | |
1011 | * | |
1012 | * Default: 0 | |
1013 | * | |
1014 | * Dynamically changeable through | |
1015 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1016 | * | |
1017 | * @param minBlobSize the size of the smallest value to be stored separately in a blob file | |
1018 | * @return these options, updated with the supplied minimum blob size value | |
1019 | */ | |
1020 | @Override | |
1021 | public ColumnFamilyOptions setMinBlobSize(final long minBlobSize) { | |
1022 | setMinBlobSize(nativeHandle_, minBlobSize); | |
1023 | return this; | |
1024 | } | |
1025 | ||
1026 | /** | |
1027 | * Get the size of the smallest value to be stored separately in a blob file. Values | |
1028 | * which have an uncompressed size smaller than this threshold are stored | |
1029 | * alongside the keys in SST files in the usual fashion. A value of zero for | |
1030 | * this option means that all values are stored in blob files. Note that | |
1031 | * enable_blob_files has to be set in order for this option to have any effect. | |
1032 | * | |
1033 | * Default: 0 | |
1034 | * | |
1035 | * Dynamically changeable through | |
1036 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1037 | * | |
1038 | * @return the current minimum blob size | |
1039 | */ | |
1040 | @Override | |
1041 | public long minBlobSize() { | |
1042 | return minBlobSize(nativeHandle_); | |
1043 | } | |
1044 | ||
1045 | /** | |
1046 | * Set the size limit for blob files. When writing blob files, a new file is opened | |
1047 | * once this limit is reached. Note that enable_blob_files has to be set in | |
1048 | * order for this option to have any effect. | |
1049 | * | |
1050 | * Default: 256 MB | |
1051 | * | |
1052 | * Dynamically changeable through | |
1053 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1054 | * | |
1055 | * @param blobFileSize the new size limit for blob files | |
1056 | * | |
1057 | * @return the reference to the current options. | |
1058 | */ | |
1059 | @Override | |
1060 | public ColumnFamilyOptions setBlobFileSize(final long blobFileSize) { | |
1061 | setBlobFileSize(nativeHandle_, blobFileSize); | |
1062 | return this; | |
1063 | } | |
1064 | ||
1065 | /** | |
1066 | * Get the size limit for blob files. When writing blob files, a new file is opened | |
1067 | * once this limit is reached. Note that enable_blob_files has to be set in | |
1068 | * order for this option to have any effect. | |
1069 | * | |
1070 | * Default: 256 MB | |
1071 | * | |
1072 | * Dynamically changeable through | |
1073 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1074 | * | |
1075 | * @return the size limit for blob files | |
1076 | */ | |
1077 | @Override | |
1078 | public long blobFileSize() { | |
1079 | return blobFileSize(nativeHandle_); | |
1080 | } | |
1081 | ||
1082 | /** | |
1083 | * Set the compression algorithm to use for large values stored in blob files. Note | |
1084 | * that enable_blob_files has to be set in order for this option to have any | |
1085 | * effect. | |
1086 | * | |
1087 | * Default: no compression | |
1088 | * | |
1089 | * Dynamically changeable through | |
1090 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1091 | * | |
1092 | * @param compressionType the compression algorithm to use | |
1093 | * | |
1094 | * @return the reference to the current options. | |
1095 | */ | |
1096 | @Override | |
1097 | public ColumnFamilyOptions setBlobCompressionType(final CompressionType compressionType) { | |
1098 | setBlobCompressionType(nativeHandle_, compressionType.getValue()); | |
1099 | return this; | |
1100 | } | |
1101 | ||
1102 | /** | |
1103 | * Get the compression algorithm to use for large values stored in blob files. Note | |
1104 | * that enable_blob_files has to be set in order for this option to have any | |
1105 | * effect. | |
1106 | * | |
1107 | * Default: no compression | |
1108 | * | |
1109 | * Dynamically changeable through | |
1110 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1111 | * | |
1112 | * @return the compression algorithm currently in use for blobs | |
1113 | */ | |
1114 | @Override | |
1115 | public CompressionType blobCompressionType() { | |
1116 | return CompressionType.values()[blobCompressionType(nativeHandle_)]; | |
1117 | } | |
1118 | ||
1119 | /** | |
1120 | * Enable/disable garbage collection of blobs. Blob GC is performed as part of | |
1121 | * compaction. Valid blobs residing in blob files older than a cutoff get | |
1122 | * relocated to new files as they are encountered during compaction, which makes | |
1123 | * it possible to clean up blob files once they contain nothing but | |
1124 | * obsolete/garbage blobs. See also blob_garbage_collection_age_cutoff below. | |
1125 | * | |
1126 | * Default: false | |
1127 | * | |
1128 | * @param enableBlobGarbageCollection true iff blob garbage collection is to be enabled | |
1129 | * | |
1130 | * @return the reference to the current options. | |
1131 | */ | |
1132 | @Override | |
1133 | public ColumnFamilyOptions setEnableBlobGarbageCollection( | |
1134 | final boolean enableBlobGarbageCollection) { | |
1135 | setEnableBlobGarbageCollection(nativeHandle_, enableBlobGarbageCollection); | |
1136 | return this; | |
1137 | } | |
1138 | ||
1139 | /** | |
1140 | * Get enabled/disables state for garbage collection of blobs. Blob GC is performed as part of | |
1141 | * compaction. Valid blobs residing in blob files older than a cutoff get | |
1142 | * relocated to new files as they are encountered during compaction, which makes | |
1143 | * it possible to clean up blob files once they contain nothing but | |
1144 | * obsolete/garbage blobs. See also blob_garbage_collection_age_cutoff below. | |
1145 | * | |
1146 | * Default: false | |
1147 | * | |
1148 | * @return true iff blob garbage collection is currently enabled | |
1149 | */ | |
1150 | @Override | |
1151 | public boolean enableBlobGarbageCollection() { | |
1152 | return enableBlobGarbageCollection(nativeHandle_); | |
1153 | } | |
1154 | ||
1155 | /** | |
1156 | * Set the cutoff in terms of blob file age for garbage collection. Blobs in the | |
1157 | * oldest N blob files will be relocated when encountered during compaction, | |
1158 | * where N = garbage_collection_cutoff * number_of_blob_files. Note that | |
1159 | * enable_blob_garbage_collection has to be set in order for this option to have | |
1160 | * any effect. | |
1161 | * | |
1162 | * Default: 0.25 | |
1163 | * | |
1164 | * @param blobGarbageCollectionAgeCutoff the new blob garbage collection age cutoff | |
1165 | * | |
1166 | * @return the reference to the current options. | |
1167 | */ | |
1168 | @Override | |
1169 | public ColumnFamilyOptions setBlobGarbageCollectionAgeCutoff( | |
1170 | final double blobGarbageCollectionAgeCutoff) { | |
1171 | setBlobGarbageCollectionAgeCutoff(nativeHandle_, blobGarbageCollectionAgeCutoff); | |
1172 | return this; | |
1173 | } | |
1174 | ||
1175 | /** | |
1176 | * Get the cutoff in terms of blob file age for garbage collection. Blobs in the | |
1177 | * oldest N blob files will be relocated when encountered during compaction, | |
1178 | * where N = garbage_collection_cutoff * number_of_blob_files. Note that | |
1179 | * enable_blob_garbage_collection has to be set in order for this option to have | |
1180 | * any effect. | |
1181 | * | |
1182 | * Default: 0.25 | |
1183 | * | |
1184 | * @return the current blob garbage collection age cutoff | |
1185 | */ | |
1186 | @Override | |
1187 | public double blobGarbageCollectionAgeCutoff() { | |
1188 | return blobGarbageCollectionAgeCutoff(nativeHandle_); | |
1189 | } | |
1190 | ||
1191 | /** | |
1192 | * If the ratio of garbage in the oldest blob files exceeds this threshold, | |
1193 | * targeted compactions are scheduled in order to force garbage collecting | |
1194 | * the blob files in question, assuming they are all eligible based on the | |
1195 | * value of {@link #blobGarbageCollectionAgeCutoff} above. This option is | |
1196 | * currently only supported with leveled compactions. | |
1197 | * | |
1198 | * Note that {@link #enableBlobGarbageCollection} has to be set in order for this | |
1199 | * option to have any effect. | |
1200 | * | |
1201 | * Default: 1.0 | |
1202 | * | |
1203 | * Dynamically changeable through the SetOptions() API | |
1204 | * | |
1205 | * @param blobGarbageCollectionForceThreshold new value for the threshold | |
1206 | * @return the reference to the current options | |
1207 | */ | |
1208 | @Override | |
1209 | public ColumnFamilyOptions setBlobGarbageCollectionForceThreshold( | |
1210 | final double blobGarbageCollectionForceThreshold) { | |
1211 | setBlobGarbageCollectionForceThreshold(nativeHandle_, blobGarbageCollectionForceThreshold); | |
1212 | return this; | |
1213 | } | |
1214 | ||
1215 | /** | |
1216 | * Get the current value for the {@link #blobGarbageCollectionForceThreshold} | |
1217 | * @return the current threshold at which garbage collection of blobs is forced | |
1218 | */ | |
1219 | @Override | |
1220 | public double blobGarbageCollectionForceThreshold() { | |
1221 | return blobGarbageCollectionForceThreshold(nativeHandle_); | |
1222 | } | |
1223 | ||
1224 | /** | |
1225 | * Set compaction readahead for blob files. | |
1226 | * | |
1227 | * Default: 0 | |
1228 | * | |
1229 | * Dynamically changeable through | |
1230 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1231 | * | |
1232 | * @param blobCompactionReadaheadSize the compaction readahead for blob files | |
1233 | * | |
1234 | * @return the reference to the current options. | |
1235 | */ | |
1236 | @Override | |
1237 | public ColumnFamilyOptions setBlobCompactionReadaheadSize( | |
1238 | final long blobCompactionReadaheadSize) { | |
1239 | setBlobCompactionReadaheadSize(nativeHandle_, blobCompactionReadaheadSize); | |
1240 | return this; | |
1241 | } | |
1242 | ||
1243 | /** | |
1244 | * Get compaction readahead for blob files. | |
1245 | * | |
1246 | * @return the current compaction readahead for blob files | |
1247 | */ | |
1248 | @Override | |
1249 | public long blobCompactionReadaheadSize() { | |
1250 | return blobCompactionReadaheadSize(nativeHandle_); | |
1251 | } | |
1252 | ||
1253 | /** | |
1254 | * Set a certain LSM tree level to enable blob files. | |
1255 | * | |
1256 | * Default: 0 | |
1257 | * | |
1258 | * Dynamically changeable through | |
1259 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1260 | * | |
1261 | * @param blobFileStartingLevel the starting level to enable blob files | |
1262 | * | |
1263 | * @return the reference to the current options. | |
1264 | */ | |
1265 | @Override | |
1266 | public ColumnFamilyOptions setBlobFileStartingLevel(final int blobFileStartingLevel) { | |
1267 | setBlobFileStartingLevel(nativeHandle_, blobFileStartingLevel); | |
1268 | return this; | |
1269 | } | |
1270 | ||
1271 | /** | |
1272 | * Get the starting LSM tree level to enable blob files. | |
1273 | * | |
1274 | * Default: 0 | |
1275 | * | |
1276 | * @return the current LSM tree level to enable blob files. | |
1277 | */ | |
1278 | @Override | |
1279 | public int blobFileStartingLevel() { | |
1280 | return blobFileStartingLevel(nativeHandle_); | |
1281 | } | |
1282 | ||
1283 | /** | |
1284 | * Set a certain prepopulate blob cache option. | |
1285 | * | |
1286 | * Default: 0 | |
1287 | * | |
1288 | * Dynamically changeable through | |
1289 | * {@link RocksDB#setOptions(ColumnFamilyHandle, MutableColumnFamilyOptions)}. | |
1290 | * | |
1291 | * @param prepopulateBlobCache the prepopulate blob cache option | |
1292 | * | |
1293 | * @return the reference to the current options. | |
1294 | */ | |
1295 | @Override | |
1296 | public ColumnFamilyOptions setPrepopulateBlobCache( | |
1297 | final PrepopulateBlobCache prepopulateBlobCache) { | |
1298 | setPrepopulateBlobCache(nativeHandle_, prepopulateBlobCache.getValue()); | |
1299 | return this; | |
1300 | } | |
1301 | ||
1302 | /** | |
1303 | * Get the prepopulate blob cache option. | |
1304 | * | |
1305 | * Default: 0 | |
1306 | * | |
1307 | * @return the current prepopulate blob cache option. | |
1308 | */ | |
1309 | @Override | |
1310 | public PrepopulateBlobCache prepopulateBlobCache() { | |
1311 | return PrepopulateBlobCache.getPrepopulateBlobCache(prepopulateBlobCache(nativeHandle_)); | |
1312 | } | |
1313 | ||
1314 | // | |
1315 | // END options for blobs (integrated BlobDB) | |
1316 | // | |
1317 | ||
7c673cae | 1318 | private static native long getColumnFamilyOptionsFromProps( |
20effc67 TL |
1319 | final long cfgHandle, String optString); |
1320 | private static native long getColumnFamilyOptionsFromProps(final String optString); | |
7c673cae FG |
1321 | |
1322 | private static native long newColumnFamilyOptions(); | |
494da23a TL |
1323 | private static native long copyColumnFamilyOptions(final long handle); |
1324 | private static native long newColumnFamilyOptionsFromOptions( | |
1325 | final long optionsHandle); | |
7c673cae FG |
1326 | @Override protected final native void disposeInternal(final long handle); |
1327 | ||
20effc67 TL |
1328 | private static native void oldDefaults( |
1329 | final long handle, final int majorVersion, final int minorVersion); | |
7c673cae | 1330 | private native void optimizeForSmallDb(final long handle); |
20effc67 | 1331 | private static native void optimizeForSmallDb(final long handle, final long cacheHandle); |
7c673cae FG |
1332 | private native void optimizeForPointLookup(long handle, |
1333 | long blockCacheSizeMb); | |
1334 | private native void optimizeLevelStyleCompaction(long handle, | |
1335 | long memtableMemoryBudget); | |
1336 | private native void optimizeUniversalStyleCompaction(long handle, | |
1337 | long memtableMemoryBudget); | |
1338 | private native void setComparatorHandle(long handle, int builtinComparator); | |
1339 | private native void setComparatorHandle(long optHandle, | |
11fdf7f2 | 1340 | long comparatorHandle, byte comparatorType); |
7c673cae FG |
1341 | private native void setMergeOperatorName(long handle, String name); |
1342 | private native void setMergeOperator(long handle, long mergeOperatorHandle); | |
1343 | private native void setCompactionFilterHandle(long handle, | |
1344 | long compactionFilterHandle); | |
11fdf7f2 TL |
1345 | private native void setCompactionFilterFactoryHandle(long handle, |
1346 | long compactionFilterFactoryHandle); | |
7c673cae FG |
1347 | private native void setWriteBufferSize(long handle, long writeBufferSize) |
1348 | throws IllegalArgumentException; | |
1349 | private native long writeBufferSize(long handle); | |
1350 | private native void setMaxWriteBufferNumber( | |
1351 | long handle, int maxWriteBufferNumber); | |
1352 | private native int maxWriteBufferNumber(long handle); | |
1353 | private native void setMinWriteBufferNumberToMerge( | |
1354 | long handle, int minWriteBufferNumberToMerge); | |
1355 | private native int minWriteBufferNumberToMerge(long handle); | |
1356 | private native void setCompressionType(long handle, byte compressionType); | |
1357 | private native byte compressionType(long handle); | |
1358 | private native void setCompressionPerLevel(long handle, | |
1359 | byte[] compressionLevels); | |
1360 | private native byte[] compressionPerLevel(long handle); | |
1361 | private native void setBottommostCompressionType(long handle, | |
1362 | byte bottommostCompressionType); | |
1363 | private native byte bottommostCompressionType(long handle); | |
494da23a TL |
1364 | private native void setBottommostCompressionOptions(final long handle, |
1365 | final long bottommostCompressionOptionsHandle); | |
7c673cae FG |
1366 | private native void setCompressionOptions(long handle, |
1367 | long compressionOptionsHandle); | |
1368 | private native void useFixedLengthPrefixExtractor( | |
1369 | long handle, int prefixLength); | |
1370 | private native void useCappedPrefixExtractor( | |
1371 | long handle, int prefixLength); | |
1372 | private native void setNumLevels( | |
1373 | long handle, int numLevels); | |
1374 | private native int numLevels(long handle); | |
1375 | private native void setLevelZeroFileNumCompactionTrigger( | |
1376 | long handle, int numFiles); | |
1377 | private native int levelZeroFileNumCompactionTrigger(long handle); | |
1378 | private native void setLevelZeroSlowdownWritesTrigger( | |
1379 | long handle, int numFiles); | |
1380 | private native int levelZeroSlowdownWritesTrigger(long handle); | |
1381 | private native void setLevelZeroStopWritesTrigger( | |
1382 | long handle, int numFiles); | |
1383 | private native int levelZeroStopWritesTrigger(long handle); | |
1384 | private native void setTargetFileSizeBase( | |
1385 | long handle, long targetFileSizeBase); | |
1386 | private native long targetFileSizeBase(long handle); | |
1387 | private native void setTargetFileSizeMultiplier( | |
1388 | long handle, int multiplier); | |
1389 | private native int targetFileSizeMultiplier(long handle); | |
1390 | private native void setMaxBytesForLevelBase( | |
1391 | long handle, long maxBytesForLevelBase); | |
1392 | private native long maxBytesForLevelBase(long handle); | |
1393 | private native void setLevelCompactionDynamicLevelBytes( | |
1394 | long handle, boolean enableLevelCompactionDynamicLevelBytes); | |
1395 | private native boolean levelCompactionDynamicLevelBytes( | |
1396 | long handle); | |
1397 | private native void setMaxBytesForLevelMultiplier(long handle, double multiplier); | |
1398 | private native double maxBytesForLevelMultiplier(long handle); | |
1399 | private native void setMaxCompactionBytes(long handle, long maxCompactionBytes); | |
1400 | private native long maxCompactionBytes(long handle); | |
1401 | private native void setArenaBlockSize( | |
1402 | long handle, long arenaBlockSize) | |
1403 | throws IllegalArgumentException; | |
1404 | private native long arenaBlockSize(long handle); | |
1405 | private native void setDisableAutoCompactions( | |
1406 | long handle, boolean disableAutoCompactions); | |
1407 | private native boolean disableAutoCompactions(long handle); | |
1408 | private native void setCompactionStyle(long handle, byte compactionStyle); | |
1409 | private native byte compactionStyle(long handle); | |
1410 | private native void setMaxTableFilesSizeFIFO( | |
1411 | long handle, long max_table_files_size); | |
1412 | private native long maxTableFilesSizeFIFO(long handle); | |
1413 | private native void setMaxSequentialSkipInIterations( | |
1414 | long handle, long maxSequentialSkipInIterations); | |
1415 | private native long maxSequentialSkipInIterations(long handle); | |
1416 | private native void setMemTableFactory(long handle, long factoryHandle); | |
1417 | private native String memTableFactoryName(long handle); | |
1418 | private native void setTableFactory(long handle, long factoryHandle); | |
1419 | private native String tableFactoryName(long handle); | |
20effc67 TL |
1420 | private static native void setCfPaths( |
1421 | final long handle, final String[] paths, final long[] targetSizes); | |
1422 | private static native long cfPathsLen(final long handle); | |
1423 | private static native void cfPaths( | |
1424 | final long handle, final String[] paths, final long[] targetSizes); | |
7c673cae FG |
1425 | private native void setInplaceUpdateSupport( |
1426 | long handle, boolean inplaceUpdateSupport); | |
1427 | private native boolean inplaceUpdateSupport(long handle); | |
1428 | private native void setInplaceUpdateNumLocks( | |
1429 | long handle, long inplaceUpdateNumLocks) | |
1430 | throws IllegalArgumentException; | |
1431 | private native long inplaceUpdateNumLocks(long handle); | |
1432 | private native void setMemtablePrefixBloomSizeRatio( | |
1433 | long handle, double memtablePrefixBloomSizeRatio); | |
1434 | private native double memtablePrefixBloomSizeRatio(long handle); | |
1e59de90 TL |
1435 | private native void setExperimentalMempurgeThreshold( |
1436 | long handle, double experimentalMempurgeThreshold); | |
1437 | private native double experimentalMempurgeThreshold(long handle); | |
1438 | private native void setMemtableWholeKeyFiltering(long handle, boolean memtableWholeKeyFiltering); | |
1439 | private native boolean memtableWholeKeyFiltering(long handle); | |
7c673cae FG |
1440 | private native void setBloomLocality( |
1441 | long handle, int bloomLocality); | |
1442 | private native int bloomLocality(long handle); | |
1443 | private native void setMaxSuccessiveMerges( | |
1444 | long handle, long maxSuccessiveMerges) | |
1445 | throws IllegalArgumentException; | |
1446 | private native long maxSuccessiveMerges(long handle); | |
1447 | private native void setOptimizeFiltersForHits(long handle, | |
1448 | boolean optimizeFiltersForHits); | |
1449 | private native boolean optimizeFiltersForHits(long handle); | |
1450 | private native void setMemtableHugePageSize(long handle, | |
1451 | long memtableHugePageSize); | |
1452 | private native long memtableHugePageSize(long handle); | |
1453 | private native void setSoftPendingCompactionBytesLimit(long handle, | |
1454 | long softPendingCompactionBytesLimit); | |
1455 | private native long softPendingCompactionBytesLimit(long handle); | |
1456 | private native void setHardPendingCompactionBytesLimit(long handle, | |
1457 | long hardPendingCompactionBytesLimit); | |
1458 | private native long hardPendingCompactionBytesLimit(long handle); | |
1459 | private native void setLevel0FileNumCompactionTrigger(long handle, | |
1460 | int level0FileNumCompactionTrigger); | |
1461 | private native int level0FileNumCompactionTrigger(long handle); | |
1462 | private native void setLevel0SlowdownWritesTrigger(long handle, | |
1463 | int level0SlowdownWritesTrigger); | |
1464 | private native int level0SlowdownWritesTrigger(long handle); | |
1465 | private native void setLevel0StopWritesTrigger(long handle, | |
1466 | int level0StopWritesTrigger); | |
1467 | private native int level0StopWritesTrigger(long handle); | |
1468 | private native void setMaxBytesForLevelMultiplierAdditional(long handle, | |
1469 | int[] maxBytesForLevelMultiplierAdditional); | |
1470 | private native int[] maxBytesForLevelMultiplierAdditional(long handle); | |
1471 | private native void setParanoidFileChecks(long handle, | |
1472 | boolean paranoidFileChecks); | |
1473 | private native boolean paranoidFileChecks(long handle); | |
1474 | private native void setMaxWriteBufferNumberToMaintain(final long handle, | |
1475 | final int maxWriteBufferNumberToMaintain); | |
1476 | private native int maxWriteBufferNumberToMaintain(final long handle); | |
1477 | private native void setCompactionPriority(final long handle, | |
1478 | final byte compactionPriority); | |
1479 | private native byte compactionPriority(final long handle); | |
1480 | private native void setReportBgIoStats(final long handle, | |
1481 | final boolean reportBgIoStats); | |
1482 | private native boolean reportBgIoStats(final long handle); | |
494da23a TL |
1483 | private native void setTtl(final long handle, final long ttl); |
1484 | private native long ttl(final long handle); | |
1e59de90 TL |
1485 | private native void setPeriodicCompactionSeconds( |
1486 | final long handle, final long periodicCompactionSeconds); | |
1487 | private native long periodicCompactionSeconds(final long handle); | |
7c673cae FG |
1488 | private native void setCompactionOptionsUniversal(final long handle, |
1489 | final long compactionOptionsUniversalHandle); | |
1490 | private native void setCompactionOptionsFIFO(final long handle, | |
1491 | final long compactionOptionsFIFOHandle); | |
1492 | private native void setForceConsistencyChecks(final long handle, | |
1493 | final boolean forceConsistencyChecks); | |
1494 | private native boolean forceConsistencyChecks(final long handle); | |
20effc67 TL |
1495 | private native void setSstPartitionerFactory(long nativeHandle_, long newFactoryHandle); |
1496 | private static native void setCompactionThreadLimiter( | |
1497 | final long nativeHandle_, final long compactionThreadLimiterHandle); | |
7c673cae | 1498 | |
1e59de90 TL |
1499 | private native void setEnableBlobFiles(final long nativeHandle_, final boolean enableBlobFiles); |
1500 | private native boolean enableBlobFiles(final long nativeHandle_); | |
1501 | private native void setMinBlobSize(final long nativeHandle_, final long minBlobSize); | |
1502 | private native long minBlobSize(final long nativeHandle_); | |
1503 | private native void setBlobFileSize(final long nativeHandle_, final long blobFileSize); | |
1504 | private native long blobFileSize(final long nativeHandle_); | |
1505 | private native void setBlobCompressionType(final long nativeHandle_, final byte compressionType); | |
1506 | private native byte blobCompressionType(final long nativeHandle_); | |
1507 | private native void setEnableBlobGarbageCollection( | |
1508 | final long nativeHandle_, final boolean enableBlobGarbageCollection); | |
1509 | private native boolean enableBlobGarbageCollection(final long nativeHandle_); | |
1510 | private native void setBlobGarbageCollectionAgeCutoff( | |
1511 | final long nativeHandle_, final double blobGarbageCollectionAgeCutoff); | |
1512 | private native double blobGarbageCollectionAgeCutoff(final long nativeHandle_); | |
1513 | private native void setBlobGarbageCollectionForceThreshold( | |
1514 | final long nativeHandle_, final double blobGarbageCollectionForceThreshold); | |
1515 | private native double blobGarbageCollectionForceThreshold(final long nativeHandle_); | |
1516 | private native void setBlobCompactionReadaheadSize( | |
1517 | final long nativeHandle_, final long blobCompactionReadaheadSize); | |
1518 | private native long blobCompactionReadaheadSize(final long nativeHandle_); | |
1519 | private native void setBlobFileStartingLevel( | |
1520 | final long nativeHandle_, final int blobFileStartingLevel); | |
1521 | private native int blobFileStartingLevel(final long nativeHandle_); | |
1522 | private native void setPrepopulateBlobCache( | |
1523 | final long nativeHandle_, final byte prepopulateBlobCache); | |
1524 | private native byte prepopulateBlobCache(final long nativeHandle_); | |
1525 | ||
7c673cae | 1526 | // instance variables |
11fdf7f2 | 1527 | // NOTE: If you add new member variables, please update the copy constructor above! |
7c673cae FG |
1528 | private MemTableConfig memTableConfig_; |
1529 | private TableFormatConfig tableFormatConfig_; | |
f67539c2 | 1530 | private AbstractComparator comparator_; |
7c673cae | 1531 | private AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter_; |
494da23a | 1532 | private AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> |
11fdf7f2 | 1533 | compactionFilterFactory_; |
7c673cae FG |
1534 | private CompactionOptionsUniversal compactionOptionsUniversal_; |
1535 | private CompactionOptionsFIFO compactionOptionsFIFO_; | |
494da23a | 1536 | private CompressionOptions bottommostCompressionOptions_; |
7c673cae | 1537 | private CompressionOptions compressionOptions_; |
20effc67 TL |
1538 | private SstPartitionerFactory sstPartitionerFactory_; |
1539 | private ConcurrentTaskLimiter compactionThreadLimiter_; | |
7c673cae | 1540 | } |