]>
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 | ||
8 | import java.util.ArrayList; | |
9 | import java.util.List; | |
10 | import java.util.Properties; | |
11 | ||
12 | /** | |
13 | * ColumnFamilyOptions to control the behavior of a database. It will be used | |
14 | * during the creation of a {@link org.rocksdb.RocksDB} (i.e., RocksDB.open()). | |
15 | * | |
16 | * If {@link #dispose()} function is not called, then it will be GC'd | |
17 | * automatically and native resources will be released as part of the process. | |
18 | */ | |
19 | public class ColumnFamilyOptions extends RocksObject | |
20 | implements ColumnFamilyOptionsInterface<ColumnFamilyOptions>, | |
21 | MutableColumnFamilyOptionsInterface<ColumnFamilyOptions> { | |
22 | static { | |
23 | RocksDB.loadLibrary(); | |
24 | } | |
25 | ||
26 | /** | |
27 | * Construct ColumnFamilyOptions. | |
28 | * | |
29 | * This constructor will create (by allocating a block of memory) | |
11fdf7f2 | 30 | * an {@code rocksdb::ColumnFamilyOptions} in the c++ side. |
7c673cae FG |
31 | */ |
32 | public ColumnFamilyOptions() { | |
33 | super(newColumnFamilyOptions()); | |
34 | } | |
35 | ||
11fdf7f2 TL |
36 | /** |
37 | * Copy constructor for ColumnFamilyOptions. | |
38 | * | |
39 | * NOTE: This does a shallow copy, which means comparator, merge_operator, compaction_filter, | |
40 | * compaction_filter_factory and other pointers will be cloned! | |
41 | * | |
42 | * @param other The ColumnFamilyOptions to copy. | |
43 | */ | |
44 | public ColumnFamilyOptions(ColumnFamilyOptions other) { | |
45 | super(copyColumnFamilyOptions(other.nativeHandle_)); | |
46 | this.memTableConfig_ = other.memTableConfig_; | |
47 | this.tableFormatConfig_ = other.tableFormatConfig_; | |
48 | this.comparator_ = other.comparator_; | |
49 | this.compactionFilter_ = other.compactionFilter_; | |
50 | this.compactionFilterFactory_ = other.compactionFilterFactory_; | |
51 | this.compactionOptionsUniversal_ = other.compactionOptionsUniversal_; | |
52 | this.compactionOptionsFIFO_ = other.compactionOptionsFIFO_; | |
494da23a | 53 | this.bottommostCompressionOptions_ = other.bottommostCompressionOptions_; |
11fdf7f2 TL |
54 | this.compressionOptions_ = other.compressionOptions_; |
55 | } | |
56 | ||
494da23a TL |
57 | /** |
58 | * Constructor from Options | |
59 | * | |
60 | * @param options The options. | |
61 | */ | |
62 | public ColumnFamilyOptions(final Options options) { | |
63 | super(newColumnFamilyOptionsFromOptions(options.nativeHandle_)); | |
64 | } | |
65 | ||
11fdf7f2 TL |
66 | /** |
67 | * <p>Constructor to be used by | |
68 | * {@link #getColumnFamilyOptionsFromProps(java.util.Properties)}, | |
69 | * {@link ColumnFamilyDescriptor#columnFamilyOptions()} | |
70 | * and also called via JNI.</p> | |
71 | * | |
72 | * @param handle native handle to ColumnFamilyOptions instance. | |
73 | */ | |
74 | ColumnFamilyOptions(final long handle) { | |
75 | super(handle); | |
76 | } | |
77 | ||
7c673cae FG |
78 | /** |
79 | * <p>Method to get a options instance by using pre-configured | |
80 | * property values. If one or many values are undefined in | |
81 | * the context of RocksDB the method will return a null | |
82 | * value.</p> | |
83 | * | |
84 | * <p><strong>Note</strong>: Property keys can be derived from | |
85 | * getter methods within the options class. Example: the method | |
86 | * {@code writeBufferSize()} has a property key: | |
87 | * {@code write_buffer_size}.</p> | |
88 | * | |
89 | * @param properties {@link java.util.Properties} instance. | |
90 | * | |
91 | * @return {@link org.rocksdb.ColumnFamilyOptions instance} | |
92 | * or null. | |
93 | * | |
94 | * @throws java.lang.IllegalArgumentException if null or empty | |
95 | * {@link Properties} instance is passed to the method call. | |
96 | */ | |
97 | public static ColumnFamilyOptions getColumnFamilyOptionsFromProps( | |
98 | final Properties properties) { | |
99 | if (properties == null || properties.size() == 0) { | |
100 | throw new IllegalArgumentException( | |
101 | "Properties value must contain at least one value."); | |
102 | } | |
103 | ColumnFamilyOptions columnFamilyOptions = null; | |
104 | StringBuilder stringBuilder = new StringBuilder(); | |
105 | for (final String name : properties.stringPropertyNames()){ | |
106 | stringBuilder.append(name); | |
107 | stringBuilder.append("="); | |
108 | stringBuilder.append(properties.getProperty(name)); | |
109 | stringBuilder.append(";"); | |
110 | } | |
111 | long handle = getColumnFamilyOptionsFromProps( | |
112 | stringBuilder.toString()); | |
113 | if (handle != 0){ | |
114 | columnFamilyOptions = new ColumnFamilyOptions(handle); | |
115 | } | |
116 | return columnFamilyOptions; | |
117 | } | |
118 | ||
119 | @Override | |
120 | public ColumnFamilyOptions optimizeForSmallDb() { | |
121 | optimizeForSmallDb(nativeHandle_); | |
122 | return this; | |
123 | } | |
124 | ||
125 | @Override | |
126 | public ColumnFamilyOptions optimizeForPointLookup( | |
127 | final long blockCacheSizeMb) { | |
128 | optimizeForPointLookup(nativeHandle_, | |
129 | blockCacheSizeMb); | |
130 | return this; | |
131 | } | |
132 | ||
133 | @Override | |
134 | public ColumnFamilyOptions optimizeLevelStyleCompaction() { | |
135 | optimizeLevelStyleCompaction(nativeHandle_, | |
136 | DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET); | |
137 | return this; | |
138 | } | |
139 | ||
140 | @Override | |
141 | public ColumnFamilyOptions optimizeLevelStyleCompaction( | |
142 | final long memtableMemoryBudget) { | |
143 | optimizeLevelStyleCompaction(nativeHandle_, | |
144 | memtableMemoryBudget); | |
145 | return this; | |
146 | } | |
147 | ||
148 | @Override | |
149 | public ColumnFamilyOptions optimizeUniversalStyleCompaction() { | |
150 | optimizeUniversalStyleCompaction(nativeHandle_, | |
151 | DEFAULT_COMPACTION_MEMTABLE_MEMORY_BUDGET); | |
152 | return this; | |
153 | } | |
154 | ||
155 | @Override | |
156 | public ColumnFamilyOptions optimizeUniversalStyleCompaction( | |
157 | final long memtableMemoryBudget) { | |
158 | optimizeUniversalStyleCompaction(nativeHandle_, | |
159 | memtableMemoryBudget); | |
160 | return this; | |
161 | } | |
162 | ||
163 | @Override | |
164 | public ColumnFamilyOptions setComparator( | |
165 | final BuiltinComparator builtinComparator) { | |
166 | assert(isOwningHandle()); | |
167 | setComparatorHandle(nativeHandle_, builtinComparator.ordinal()); | |
168 | return this; | |
169 | } | |
170 | ||
171 | @Override | |
172 | public ColumnFamilyOptions setComparator( | |
173 | final AbstractComparator<? extends AbstractSlice<?>> comparator) { | |
174 | assert (isOwningHandle()); | |
11fdf7f2 TL |
175 | setComparatorHandle(nativeHandle_, comparator.nativeHandle_, |
176 | comparator.getComparatorType().getValue()); | |
7c673cae FG |
177 | comparator_ = comparator; |
178 | return this; | |
179 | } | |
180 | ||
181 | @Override | |
182 | public ColumnFamilyOptions setMergeOperatorName(final String name) { | |
183 | assert (isOwningHandle()); | |
184 | if (name == null) { | |
185 | throw new IllegalArgumentException( | |
186 | "Merge operator name must not be null."); | |
187 | } | |
188 | setMergeOperatorName(nativeHandle_, name); | |
189 | return this; | |
190 | } | |
191 | ||
192 | @Override | |
193 | public ColumnFamilyOptions setMergeOperator( | |
194 | final MergeOperator mergeOperator) { | |
195 | setMergeOperator(nativeHandle_, mergeOperator.nativeHandle_); | |
196 | return this; | |
197 | } | |
198 | ||
494da23a | 199 | @Override |
7c673cae FG |
200 | public ColumnFamilyOptions setCompactionFilter( |
201 | final AbstractCompactionFilter<? extends AbstractSlice<?>> | |
202 | compactionFilter) { | |
203 | setCompactionFilterHandle(nativeHandle_, compactionFilter.nativeHandle_); | |
204 | compactionFilter_ = compactionFilter; | |
205 | return this; | |
206 | } | |
207 | ||
494da23a TL |
208 | @Override |
209 | public AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter() { | |
210 | assert (isOwningHandle()); | |
211 | return compactionFilter_; | |
212 | } | |
213 | ||
214 | @Override | |
11fdf7f2 TL |
215 | public ColumnFamilyOptions setCompactionFilterFactory(final AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> compactionFilterFactory) { |
216 | assert (isOwningHandle()); | |
217 | setCompactionFilterFactoryHandle(nativeHandle_, compactionFilterFactory.nativeHandle_); | |
218 | compactionFilterFactory_ = compactionFilterFactory; | |
219 | return this; | |
220 | } | |
221 | ||
494da23a TL |
222 | @Override |
223 | public AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> compactionFilterFactory() { | |
224 | assert (isOwningHandle()); | |
225 | return compactionFilterFactory_; | |
226 | } | |
227 | ||
7c673cae FG |
228 | @Override |
229 | public ColumnFamilyOptions setWriteBufferSize(final long writeBufferSize) { | |
230 | assert(isOwningHandle()); | |
231 | setWriteBufferSize(nativeHandle_, writeBufferSize); | |
232 | return this; | |
233 | } | |
234 | ||
235 | @Override | |
236 | public long writeBufferSize() { | |
237 | assert(isOwningHandle()); | |
238 | return writeBufferSize(nativeHandle_); | |
239 | } | |
240 | ||
241 | @Override | |
242 | public ColumnFamilyOptions setMaxWriteBufferNumber( | |
243 | final int maxWriteBufferNumber) { | |
244 | assert(isOwningHandle()); | |
245 | setMaxWriteBufferNumber(nativeHandle_, maxWriteBufferNumber); | |
246 | return this; | |
247 | } | |
248 | ||
249 | @Override | |
250 | public int maxWriteBufferNumber() { | |
251 | assert(isOwningHandle()); | |
252 | return maxWriteBufferNumber(nativeHandle_); | |
253 | } | |
254 | ||
255 | @Override | |
256 | public ColumnFamilyOptions setMinWriteBufferNumberToMerge( | |
257 | final int minWriteBufferNumberToMerge) { | |
258 | setMinWriteBufferNumberToMerge(nativeHandle_, minWriteBufferNumberToMerge); | |
259 | return this; | |
260 | } | |
261 | ||
262 | @Override | |
263 | public int minWriteBufferNumberToMerge() { | |
264 | return minWriteBufferNumberToMerge(nativeHandle_); | |
265 | } | |
266 | ||
267 | @Override | |
268 | public ColumnFamilyOptions useFixedLengthPrefixExtractor(final int n) { | |
269 | assert(isOwningHandle()); | |
270 | useFixedLengthPrefixExtractor(nativeHandle_, n); | |
271 | return this; | |
272 | } | |
273 | ||
274 | @Override | |
275 | public ColumnFamilyOptions useCappedPrefixExtractor(final int n) { | |
276 | assert(isOwningHandle()); | |
277 | useCappedPrefixExtractor(nativeHandle_, n); | |
278 | return this; | |
279 | } | |
280 | ||
281 | @Override | |
282 | public ColumnFamilyOptions setCompressionType( | |
283 | final CompressionType compressionType) { | |
284 | setCompressionType(nativeHandle_, compressionType.getValue()); | |
285 | return this; | |
286 | } | |
287 | ||
288 | @Override | |
289 | public CompressionType compressionType() { | |
290 | return CompressionType.getCompressionType(compressionType(nativeHandle_)); | |
291 | } | |
292 | ||
293 | @Override | |
294 | public ColumnFamilyOptions setCompressionPerLevel( | |
295 | final List<CompressionType> compressionLevels) { | |
296 | final byte[] byteCompressionTypes = new byte[ | |
297 | compressionLevels.size()]; | |
298 | for (int i = 0; i < compressionLevels.size(); i++) { | |
299 | byteCompressionTypes[i] = compressionLevels.get(i).getValue(); | |
300 | } | |
301 | setCompressionPerLevel(nativeHandle_, byteCompressionTypes); | |
302 | return this; | |
303 | } | |
304 | ||
305 | @Override | |
306 | public List<CompressionType> compressionPerLevel() { | |
307 | final byte[] byteCompressionTypes = | |
308 | compressionPerLevel(nativeHandle_); | |
309 | final List<CompressionType> compressionLevels = new ArrayList<>(); | |
310 | for (final Byte byteCompressionType : byteCompressionTypes) { | |
311 | compressionLevels.add(CompressionType.getCompressionType( | |
312 | byteCompressionType)); | |
313 | } | |
314 | return compressionLevels; | |
315 | } | |
316 | ||
317 | @Override | |
318 | public ColumnFamilyOptions setBottommostCompressionType( | |
319 | final CompressionType bottommostCompressionType) { | |
320 | setBottommostCompressionType(nativeHandle_, | |
321 | bottommostCompressionType.getValue()); | |
322 | return this; | |
323 | } | |
324 | ||
325 | @Override | |
326 | public CompressionType bottommostCompressionType() { | |
327 | return CompressionType.getCompressionType( | |
328 | bottommostCompressionType(nativeHandle_)); | |
329 | } | |
330 | ||
494da23a TL |
331 | @Override |
332 | public ColumnFamilyOptions setBottommostCompressionOptions( | |
333 | final CompressionOptions bottommostCompressionOptions) { | |
334 | setBottommostCompressionOptions(nativeHandle_, | |
335 | bottommostCompressionOptions.nativeHandle_); | |
336 | this.bottommostCompressionOptions_ = bottommostCompressionOptions; | |
337 | return this; | |
338 | } | |
339 | ||
340 | @Override | |
341 | public CompressionOptions bottommostCompressionOptions() { | |
342 | return this.bottommostCompressionOptions_; | |
343 | } | |
344 | ||
7c673cae FG |
345 | @Override |
346 | public ColumnFamilyOptions setCompressionOptions( | |
347 | final CompressionOptions compressionOptions) { | |
348 | setCompressionOptions(nativeHandle_, compressionOptions.nativeHandle_); | |
349 | this.compressionOptions_ = compressionOptions; | |
350 | return this; | |
351 | } | |
352 | ||
353 | @Override | |
354 | public CompressionOptions compressionOptions() { | |
355 | return this.compressionOptions_; | |
356 | } | |
357 | ||
358 | @Override | |
359 | public ColumnFamilyOptions setNumLevels(final int numLevels) { | |
360 | setNumLevels(nativeHandle_, numLevels); | |
361 | return this; | |
362 | } | |
363 | ||
364 | @Override | |
365 | public int numLevels() { | |
366 | return numLevels(nativeHandle_); | |
367 | } | |
368 | ||
369 | @Override | |
370 | public ColumnFamilyOptions setLevelZeroFileNumCompactionTrigger( | |
371 | final int numFiles) { | |
372 | setLevelZeroFileNumCompactionTrigger( | |
373 | nativeHandle_, numFiles); | |
374 | return this; | |
375 | } | |
376 | ||
377 | @Override | |
378 | public int levelZeroFileNumCompactionTrigger() { | |
379 | return levelZeroFileNumCompactionTrigger(nativeHandle_); | |
380 | } | |
381 | ||
382 | @Override | |
383 | public ColumnFamilyOptions setLevelZeroSlowdownWritesTrigger( | |
384 | final int numFiles) { | |
385 | setLevelZeroSlowdownWritesTrigger(nativeHandle_, numFiles); | |
386 | return this; | |
387 | } | |
388 | ||
389 | @Override | |
390 | public int levelZeroSlowdownWritesTrigger() { | |
391 | return levelZeroSlowdownWritesTrigger(nativeHandle_); | |
392 | } | |
393 | ||
394 | @Override | |
395 | public ColumnFamilyOptions setLevelZeroStopWritesTrigger(final int numFiles) { | |
396 | setLevelZeroStopWritesTrigger(nativeHandle_, numFiles); | |
397 | return this; | |
398 | } | |
399 | ||
400 | @Override | |
401 | public int levelZeroStopWritesTrigger() { | |
402 | return levelZeroStopWritesTrigger(nativeHandle_); | |
403 | } | |
404 | ||
405 | @Override | |
406 | public ColumnFamilyOptions setTargetFileSizeBase( | |
407 | final long targetFileSizeBase) { | |
408 | setTargetFileSizeBase(nativeHandle_, targetFileSizeBase); | |
409 | return this; | |
410 | } | |
411 | ||
412 | @Override | |
413 | public long targetFileSizeBase() { | |
414 | return targetFileSizeBase(nativeHandle_); | |
415 | } | |
416 | ||
417 | @Override | |
418 | public ColumnFamilyOptions setTargetFileSizeMultiplier( | |
419 | final int multiplier) { | |
420 | setTargetFileSizeMultiplier(nativeHandle_, multiplier); | |
421 | return this; | |
422 | } | |
423 | ||
424 | @Override | |
425 | public int targetFileSizeMultiplier() { | |
426 | return targetFileSizeMultiplier(nativeHandle_); | |
427 | } | |
428 | ||
429 | @Override | |
430 | public ColumnFamilyOptions setMaxBytesForLevelBase( | |
431 | final long maxBytesForLevelBase) { | |
432 | setMaxBytesForLevelBase(nativeHandle_, maxBytesForLevelBase); | |
433 | return this; | |
434 | } | |
435 | ||
436 | @Override | |
437 | public long maxBytesForLevelBase() { | |
438 | return maxBytesForLevelBase(nativeHandle_); | |
439 | } | |
440 | ||
441 | @Override | |
442 | public ColumnFamilyOptions setLevelCompactionDynamicLevelBytes( | |
443 | final boolean enableLevelCompactionDynamicLevelBytes) { | |
444 | setLevelCompactionDynamicLevelBytes(nativeHandle_, | |
445 | enableLevelCompactionDynamicLevelBytes); | |
446 | return this; | |
447 | } | |
448 | ||
449 | @Override | |
450 | public boolean levelCompactionDynamicLevelBytes() { | |
451 | return levelCompactionDynamicLevelBytes(nativeHandle_); | |
452 | } | |
453 | ||
454 | @Override | |
455 | public ColumnFamilyOptions setMaxBytesForLevelMultiplier(final double multiplier) { | |
456 | setMaxBytesForLevelMultiplier(nativeHandle_, multiplier); | |
457 | return this; | |
458 | } | |
459 | ||
460 | @Override | |
461 | public double maxBytesForLevelMultiplier() { | |
462 | return maxBytesForLevelMultiplier(nativeHandle_); | |
463 | } | |
464 | ||
465 | @Override | |
466 | public ColumnFamilyOptions setMaxCompactionBytes(final long maxCompactionBytes) { | |
467 | setMaxCompactionBytes(nativeHandle_, maxCompactionBytes); | |
468 | return this; | |
469 | } | |
470 | ||
471 | @Override | |
472 | public long maxCompactionBytes() { | |
473 | return maxCompactionBytes(nativeHandle_); | |
474 | } | |
475 | ||
476 | @Override | |
477 | public ColumnFamilyOptions setArenaBlockSize( | |
478 | final long arenaBlockSize) { | |
479 | setArenaBlockSize(nativeHandle_, arenaBlockSize); | |
480 | return this; | |
481 | } | |
482 | ||
483 | @Override | |
484 | public long arenaBlockSize() { | |
485 | return arenaBlockSize(nativeHandle_); | |
486 | } | |
487 | ||
488 | @Override | |
489 | public ColumnFamilyOptions setDisableAutoCompactions( | |
490 | final boolean disableAutoCompactions) { | |
491 | setDisableAutoCompactions(nativeHandle_, disableAutoCompactions); | |
492 | return this; | |
493 | } | |
494 | ||
495 | @Override | |
496 | public boolean disableAutoCompactions() { | |
497 | return disableAutoCompactions(nativeHandle_); | |
498 | } | |
499 | ||
500 | @Override | |
501 | public ColumnFamilyOptions setCompactionStyle( | |
502 | final CompactionStyle compactionStyle) { | |
503 | setCompactionStyle(nativeHandle_, compactionStyle.getValue()); | |
504 | return this; | |
505 | } | |
506 | ||
507 | @Override | |
508 | public CompactionStyle compactionStyle() { | |
494da23a | 509 | return CompactionStyle.fromValue(compactionStyle(nativeHandle_)); |
7c673cae FG |
510 | } |
511 | ||
512 | @Override | |
513 | public ColumnFamilyOptions setMaxTableFilesSizeFIFO( | |
514 | final long maxTableFilesSize) { | |
515 | assert(maxTableFilesSize > 0); // unsigned native type | |
516 | assert(isOwningHandle()); | |
517 | setMaxTableFilesSizeFIFO(nativeHandle_, maxTableFilesSize); | |
518 | return this; | |
519 | } | |
520 | ||
521 | @Override | |
522 | public long maxTableFilesSizeFIFO() { | |
523 | return maxTableFilesSizeFIFO(nativeHandle_); | |
524 | } | |
525 | ||
526 | @Override | |
527 | public ColumnFamilyOptions setMaxSequentialSkipInIterations( | |
528 | final long maxSequentialSkipInIterations) { | |
529 | setMaxSequentialSkipInIterations(nativeHandle_, | |
530 | maxSequentialSkipInIterations); | |
531 | return this; | |
532 | } | |
533 | ||
534 | @Override | |
535 | public long maxSequentialSkipInIterations() { | |
536 | return maxSequentialSkipInIterations(nativeHandle_); | |
537 | } | |
538 | ||
539 | @Override | |
540 | public MemTableConfig memTableConfig() { | |
541 | return this.memTableConfig_; | |
542 | } | |
543 | ||
544 | @Override | |
545 | public ColumnFamilyOptions setMemTableConfig( | |
546 | final MemTableConfig memTableConfig) { | |
547 | setMemTableFactory( | |
548 | nativeHandle_, memTableConfig.newMemTableFactoryHandle()); | |
549 | this.memTableConfig_ = memTableConfig; | |
550 | return this; | |
551 | } | |
552 | ||
553 | @Override | |
554 | public String memTableFactoryName() { | |
555 | assert(isOwningHandle()); | |
556 | return memTableFactoryName(nativeHandle_); | |
557 | } | |
558 | ||
559 | @Override | |
560 | public TableFormatConfig tableFormatConfig() { | |
561 | return this.tableFormatConfig_; | |
562 | } | |
563 | ||
564 | @Override | |
565 | public ColumnFamilyOptions setTableFormatConfig( | |
566 | final TableFormatConfig tableFormatConfig) { | |
567 | setTableFactory(nativeHandle_, tableFormatConfig.newTableFactoryHandle()); | |
568 | this.tableFormatConfig_ = tableFormatConfig; | |
569 | return this; | |
570 | } | |
571 | ||
572 | @Override | |
573 | public String tableFactoryName() { | |
574 | assert(isOwningHandle()); | |
575 | return tableFactoryName(nativeHandle_); | |
576 | } | |
577 | ||
578 | @Override | |
579 | public ColumnFamilyOptions setInplaceUpdateSupport( | |
580 | final boolean inplaceUpdateSupport) { | |
581 | setInplaceUpdateSupport(nativeHandle_, inplaceUpdateSupport); | |
582 | return this; | |
583 | } | |
584 | ||
585 | @Override | |
586 | public boolean inplaceUpdateSupport() { | |
587 | return inplaceUpdateSupport(nativeHandle_); | |
588 | } | |
589 | ||
590 | @Override | |
591 | public ColumnFamilyOptions setInplaceUpdateNumLocks( | |
592 | final long inplaceUpdateNumLocks) { | |
593 | setInplaceUpdateNumLocks(nativeHandle_, inplaceUpdateNumLocks); | |
594 | return this; | |
595 | } | |
596 | ||
597 | @Override | |
598 | public long inplaceUpdateNumLocks() { | |
599 | return inplaceUpdateNumLocks(nativeHandle_); | |
600 | } | |
601 | ||
602 | @Override | |
603 | public ColumnFamilyOptions setMemtablePrefixBloomSizeRatio( | |
604 | final double memtablePrefixBloomSizeRatio) { | |
605 | setMemtablePrefixBloomSizeRatio(nativeHandle_, memtablePrefixBloomSizeRatio); | |
606 | return this; | |
607 | } | |
608 | ||
609 | @Override | |
610 | public double memtablePrefixBloomSizeRatio() { | |
611 | return memtablePrefixBloomSizeRatio(nativeHandle_); | |
612 | } | |
613 | ||
614 | @Override | |
615 | public ColumnFamilyOptions setBloomLocality(int bloomLocality) { | |
616 | setBloomLocality(nativeHandle_, bloomLocality); | |
617 | return this; | |
618 | } | |
619 | ||
620 | @Override | |
621 | public int bloomLocality() { | |
622 | return bloomLocality(nativeHandle_); | |
623 | } | |
624 | ||
625 | @Override | |
626 | public ColumnFamilyOptions setMaxSuccessiveMerges( | |
627 | final long maxSuccessiveMerges) { | |
628 | setMaxSuccessiveMerges(nativeHandle_, maxSuccessiveMerges); | |
629 | return this; | |
630 | } | |
631 | ||
632 | @Override | |
633 | public long maxSuccessiveMerges() { | |
634 | return maxSuccessiveMerges(nativeHandle_); | |
635 | } | |
636 | ||
637 | @Override | |
638 | public ColumnFamilyOptions setOptimizeFiltersForHits( | |
639 | final boolean optimizeFiltersForHits) { | |
640 | setOptimizeFiltersForHits(nativeHandle_, optimizeFiltersForHits); | |
641 | return this; | |
642 | } | |
643 | ||
644 | @Override | |
645 | public boolean optimizeFiltersForHits() { | |
646 | return optimizeFiltersForHits(nativeHandle_); | |
647 | } | |
648 | ||
649 | @Override | |
650 | public ColumnFamilyOptions | |
651 | setMemtableHugePageSize( | |
652 | long memtableHugePageSize) { | |
653 | setMemtableHugePageSize(nativeHandle_, | |
654 | memtableHugePageSize); | |
655 | return this; | |
656 | } | |
657 | ||
658 | @Override | |
659 | public long memtableHugePageSize() { | |
660 | return memtableHugePageSize(nativeHandle_); | |
661 | } | |
662 | ||
663 | @Override | |
664 | public ColumnFamilyOptions setSoftPendingCompactionBytesLimit(long softPendingCompactionBytesLimit) { | |
665 | setSoftPendingCompactionBytesLimit(nativeHandle_, | |
666 | softPendingCompactionBytesLimit); | |
667 | return this; | |
668 | } | |
669 | ||
670 | @Override | |
671 | public long softPendingCompactionBytesLimit() { | |
672 | return softPendingCompactionBytesLimit(nativeHandle_); | |
673 | } | |
674 | ||
675 | @Override | |
676 | public ColumnFamilyOptions setHardPendingCompactionBytesLimit(long hardPendingCompactionBytesLimit) { | |
677 | setHardPendingCompactionBytesLimit(nativeHandle_, hardPendingCompactionBytesLimit); | |
678 | return this; | |
679 | } | |
680 | ||
681 | @Override | |
682 | public long hardPendingCompactionBytesLimit() { | |
683 | return hardPendingCompactionBytesLimit(nativeHandle_); | |
684 | } | |
685 | ||
686 | @Override | |
687 | public ColumnFamilyOptions setLevel0FileNumCompactionTrigger(int level0FileNumCompactionTrigger) { | |
688 | setLevel0FileNumCompactionTrigger(nativeHandle_, level0FileNumCompactionTrigger); | |
689 | return this; | |
690 | } | |
691 | ||
692 | @Override | |
693 | public int level0FileNumCompactionTrigger() { | |
694 | return level0FileNumCompactionTrigger(nativeHandle_); | |
695 | } | |
696 | ||
697 | @Override | |
698 | public ColumnFamilyOptions setLevel0SlowdownWritesTrigger(int level0SlowdownWritesTrigger) { | |
699 | setLevel0SlowdownWritesTrigger(nativeHandle_, level0SlowdownWritesTrigger); | |
700 | return this; | |
701 | } | |
702 | ||
703 | @Override | |
704 | public int level0SlowdownWritesTrigger() { | |
705 | return level0SlowdownWritesTrigger(nativeHandle_); | |
706 | } | |
707 | ||
708 | @Override | |
709 | public ColumnFamilyOptions setLevel0StopWritesTrigger(int level0StopWritesTrigger) { | |
710 | setLevel0StopWritesTrigger(nativeHandle_, level0StopWritesTrigger); | |
711 | return this; | |
712 | } | |
713 | ||
714 | @Override | |
715 | public int level0StopWritesTrigger() { | |
716 | return level0StopWritesTrigger(nativeHandle_); | |
717 | } | |
718 | ||
719 | @Override | |
720 | public ColumnFamilyOptions setMaxBytesForLevelMultiplierAdditional(int[] maxBytesForLevelMultiplierAdditional) { | |
721 | setMaxBytesForLevelMultiplierAdditional(nativeHandle_, maxBytesForLevelMultiplierAdditional); | |
722 | return this; | |
723 | } | |
724 | ||
725 | @Override | |
726 | public int[] maxBytesForLevelMultiplierAdditional() { | |
727 | return maxBytesForLevelMultiplierAdditional(nativeHandle_); | |
728 | } | |
729 | ||
730 | @Override | |
731 | public ColumnFamilyOptions setParanoidFileChecks(boolean paranoidFileChecks) { | |
732 | setParanoidFileChecks(nativeHandle_, paranoidFileChecks); | |
733 | return this; | |
734 | } | |
735 | ||
736 | @Override | |
737 | public boolean paranoidFileChecks() { | |
738 | return paranoidFileChecks(nativeHandle_); | |
739 | } | |
740 | ||
741 | @Override | |
742 | public ColumnFamilyOptions setMaxWriteBufferNumberToMaintain( | |
743 | final int maxWriteBufferNumberToMaintain) { | |
744 | setMaxWriteBufferNumberToMaintain( | |
745 | nativeHandle_, maxWriteBufferNumberToMaintain); | |
746 | return this; | |
747 | } | |
748 | ||
749 | @Override | |
750 | public int maxWriteBufferNumberToMaintain() { | |
751 | return maxWriteBufferNumberToMaintain(nativeHandle_); | |
752 | } | |
753 | ||
754 | @Override | |
755 | public ColumnFamilyOptions setCompactionPriority( | |
756 | final CompactionPriority compactionPriority) { | |
757 | setCompactionPriority(nativeHandle_, compactionPriority.getValue()); | |
758 | return this; | |
759 | } | |
760 | ||
761 | @Override | |
762 | public CompactionPriority compactionPriority() { | |
763 | return CompactionPriority.getCompactionPriority( | |
764 | compactionPriority(nativeHandle_)); | |
765 | } | |
766 | ||
767 | @Override | |
768 | public ColumnFamilyOptions setReportBgIoStats(final boolean reportBgIoStats) { | |
769 | setReportBgIoStats(nativeHandle_, reportBgIoStats); | |
770 | return this; | |
771 | } | |
772 | ||
773 | @Override | |
774 | public boolean reportBgIoStats() { | |
775 | return reportBgIoStats(nativeHandle_); | |
776 | } | |
777 | ||
494da23a TL |
778 | @Override |
779 | public ColumnFamilyOptions setTtl(final long ttl) { | |
780 | setTtl(nativeHandle_, ttl); | |
781 | return this; | |
782 | } | |
783 | ||
784 | @Override | |
785 | public long ttl() { | |
786 | return ttl(nativeHandle_); | |
787 | } | |
788 | ||
7c673cae FG |
789 | @Override |
790 | public ColumnFamilyOptions setCompactionOptionsUniversal( | |
791 | final CompactionOptionsUniversal compactionOptionsUniversal) { | |
792 | setCompactionOptionsUniversal(nativeHandle_, | |
793 | compactionOptionsUniversal.nativeHandle_); | |
794 | this.compactionOptionsUniversal_ = compactionOptionsUniversal; | |
795 | return this; | |
796 | } | |
797 | ||
798 | @Override | |
799 | public CompactionOptionsUniversal compactionOptionsUniversal() { | |
800 | return this.compactionOptionsUniversal_; | |
801 | } | |
802 | ||
803 | @Override | |
804 | public ColumnFamilyOptions setCompactionOptionsFIFO(final CompactionOptionsFIFO compactionOptionsFIFO) { | |
805 | setCompactionOptionsFIFO(nativeHandle_, | |
806 | compactionOptionsFIFO.nativeHandle_); | |
807 | this.compactionOptionsFIFO_ = compactionOptionsFIFO; | |
808 | return this; | |
809 | } | |
810 | ||
811 | @Override | |
812 | public CompactionOptionsFIFO compactionOptionsFIFO() { | |
813 | return this.compactionOptionsFIFO_; | |
814 | } | |
815 | ||
816 | @Override | |
817 | public ColumnFamilyOptions setForceConsistencyChecks(final boolean forceConsistencyChecks) { | |
818 | setForceConsistencyChecks(nativeHandle_, forceConsistencyChecks); | |
819 | return this; | |
820 | } | |
821 | ||
822 | @Override | |
823 | public boolean forceConsistencyChecks() { | |
824 | return forceConsistencyChecks(nativeHandle_); | |
825 | } | |
826 | ||
7c673cae FG |
827 | private static native long getColumnFamilyOptionsFromProps( |
828 | String optString); | |
829 | ||
830 | private static native long newColumnFamilyOptions(); | |
494da23a TL |
831 | private static native long copyColumnFamilyOptions(final long handle); |
832 | private static native long newColumnFamilyOptionsFromOptions( | |
833 | final long optionsHandle); | |
7c673cae FG |
834 | @Override protected final native void disposeInternal(final long handle); |
835 | ||
836 | private native void optimizeForSmallDb(final long handle); | |
837 | private native void optimizeForPointLookup(long handle, | |
838 | long blockCacheSizeMb); | |
839 | private native void optimizeLevelStyleCompaction(long handle, | |
840 | long memtableMemoryBudget); | |
841 | private native void optimizeUniversalStyleCompaction(long handle, | |
842 | long memtableMemoryBudget); | |
843 | private native void setComparatorHandle(long handle, int builtinComparator); | |
844 | private native void setComparatorHandle(long optHandle, | |
11fdf7f2 | 845 | long comparatorHandle, byte comparatorType); |
7c673cae FG |
846 | private native void setMergeOperatorName(long handle, String name); |
847 | private native void setMergeOperator(long handle, long mergeOperatorHandle); | |
848 | private native void setCompactionFilterHandle(long handle, | |
849 | long compactionFilterHandle); | |
11fdf7f2 TL |
850 | private native void setCompactionFilterFactoryHandle(long handle, |
851 | long compactionFilterFactoryHandle); | |
7c673cae FG |
852 | private native void setWriteBufferSize(long handle, long writeBufferSize) |
853 | throws IllegalArgumentException; | |
854 | private native long writeBufferSize(long handle); | |
855 | private native void setMaxWriteBufferNumber( | |
856 | long handle, int maxWriteBufferNumber); | |
857 | private native int maxWriteBufferNumber(long handle); | |
858 | private native void setMinWriteBufferNumberToMerge( | |
859 | long handle, int minWriteBufferNumberToMerge); | |
860 | private native int minWriteBufferNumberToMerge(long handle); | |
861 | private native void setCompressionType(long handle, byte compressionType); | |
862 | private native byte compressionType(long handle); | |
863 | private native void setCompressionPerLevel(long handle, | |
864 | byte[] compressionLevels); | |
865 | private native byte[] compressionPerLevel(long handle); | |
866 | private native void setBottommostCompressionType(long handle, | |
867 | byte bottommostCompressionType); | |
868 | private native byte bottommostCompressionType(long handle); | |
494da23a TL |
869 | private native void setBottommostCompressionOptions(final long handle, |
870 | final long bottommostCompressionOptionsHandle); | |
7c673cae FG |
871 | private native void setCompressionOptions(long handle, |
872 | long compressionOptionsHandle); | |
873 | private native void useFixedLengthPrefixExtractor( | |
874 | long handle, int prefixLength); | |
875 | private native void useCappedPrefixExtractor( | |
876 | long handle, int prefixLength); | |
877 | private native void setNumLevels( | |
878 | long handle, int numLevels); | |
879 | private native int numLevels(long handle); | |
880 | private native void setLevelZeroFileNumCompactionTrigger( | |
881 | long handle, int numFiles); | |
882 | private native int levelZeroFileNumCompactionTrigger(long handle); | |
883 | private native void setLevelZeroSlowdownWritesTrigger( | |
884 | long handle, int numFiles); | |
885 | private native int levelZeroSlowdownWritesTrigger(long handle); | |
886 | private native void setLevelZeroStopWritesTrigger( | |
887 | long handle, int numFiles); | |
888 | private native int levelZeroStopWritesTrigger(long handle); | |
889 | private native void setTargetFileSizeBase( | |
890 | long handle, long targetFileSizeBase); | |
891 | private native long targetFileSizeBase(long handle); | |
892 | private native void setTargetFileSizeMultiplier( | |
893 | long handle, int multiplier); | |
894 | private native int targetFileSizeMultiplier(long handle); | |
895 | private native void setMaxBytesForLevelBase( | |
896 | long handle, long maxBytesForLevelBase); | |
897 | private native long maxBytesForLevelBase(long handle); | |
898 | private native void setLevelCompactionDynamicLevelBytes( | |
899 | long handle, boolean enableLevelCompactionDynamicLevelBytes); | |
900 | private native boolean levelCompactionDynamicLevelBytes( | |
901 | long handle); | |
902 | private native void setMaxBytesForLevelMultiplier(long handle, double multiplier); | |
903 | private native double maxBytesForLevelMultiplier(long handle); | |
904 | private native void setMaxCompactionBytes(long handle, long maxCompactionBytes); | |
905 | private native long maxCompactionBytes(long handle); | |
906 | private native void setArenaBlockSize( | |
907 | long handle, long arenaBlockSize) | |
908 | throws IllegalArgumentException; | |
909 | private native long arenaBlockSize(long handle); | |
910 | private native void setDisableAutoCompactions( | |
911 | long handle, boolean disableAutoCompactions); | |
912 | private native boolean disableAutoCompactions(long handle); | |
913 | private native void setCompactionStyle(long handle, byte compactionStyle); | |
914 | private native byte compactionStyle(long handle); | |
915 | private native void setMaxTableFilesSizeFIFO( | |
916 | long handle, long max_table_files_size); | |
917 | private native long maxTableFilesSizeFIFO(long handle); | |
918 | private native void setMaxSequentialSkipInIterations( | |
919 | long handle, long maxSequentialSkipInIterations); | |
920 | private native long maxSequentialSkipInIterations(long handle); | |
921 | private native void setMemTableFactory(long handle, long factoryHandle); | |
922 | private native String memTableFactoryName(long handle); | |
923 | private native void setTableFactory(long handle, long factoryHandle); | |
924 | private native String tableFactoryName(long handle); | |
925 | private native void setInplaceUpdateSupport( | |
926 | long handle, boolean inplaceUpdateSupport); | |
927 | private native boolean inplaceUpdateSupport(long handle); | |
928 | private native void setInplaceUpdateNumLocks( | |
929 | long handle, long inplaceUpdateNumLocks) | |
930 | throws IllegalArgumentException; | |
931 | private native long inplaceUpdateNumLocks(long handle); | |
932 | private native void setMemtablePrefixBloomSizeRatio( | |
933 | long handle, double memtablePrefixBloomSizeRatio); | |
934 | private native double memtablePrefixBloomSizeRatio(long handle); | |
935 | private native void setBloomLocality( | |
936 | long handle, int bloomLocality); | |
937 | private native int bloomLocality(long handle); | |
938 | private native void setMaxSuccessiveMerges( | |
939 | long handle, long maxSuccessiveMerges) | |
940 | throws IllegalArgumentException; | |
941 | private native long maxSuccessiveMerges(long handle); | |
942 | private native void setOptimizeFiltersForHits(long handle, | |
943 | boolean optimizeFiltersForHits); | |
944 | private native boolean optimizeFiltersForHits(long handle); | |
945 | private native void setMemtableHugePageSize(long handle, | |
946 | long memtableHugePageSize); | |
947 | private native long memtableHugePageSize(long handle); | |
948 | private native void setSoftPendingCompactionBytesLimit(long handle, | |
949 | long softPendingCompactionBytesLimit); | |
950 | private native long softPendingCompactionBytesLimit(long handle); | |
951 | private native void setHardPendingCompactionBytesLimit(long handle, | |
952 | long hardPendingCompactionBytesLimit); | |
953 | private native long hardPendingCompactionBytesLimit(long handle); | |
954 | private native void setLevel0FileNumCompactionTrigger(long handle, | |
955 | int level0FileNumCompactionTrigger); | |
956 | private native int level0FileNumCompactionTrigger(long handle); | |
957 | private native void setLevel0SlowdownWritesTrigger(long handle, | |
958 | int level0SlowdownWritesTrigger); | |
959 | private native int level0SlowdownWritesTrigger(long handle); | |
960 | private native void setLevel0StopWritesTrigger(long handle, | |
961 | int level0StopWritesTrigger); | |
962 | private native int level0StopWritesTrigger(long handle); | |
963 | private native void setMaxBytesForLevelMultiplierAdditional(long handle, | |
964 | int[] maxBytesForLevelMultiplierAdditional); | |
965 | private native int[] maxBytesForLevelMultiplierAdditional(long handle); | |
966 | private native void setParanoidFileChecks(long handle, | |
967 | boolean paranoidFileChecks); | |
968 | private native boolean paranoidFileChecks(long handle); | |
969 | private native void setMaxWriteBufferNumberToMaintain(final long handle, | |
970 | final int maxWriteBufferNumberToMaintain); | |
971 | private native int maxWriteBufferNumberToMaintain(final long handle); | |
972 | private native void setCompactionPriority(final long handle, | |
973 | final byte compactionPriority); | |
974 | private native byte compactionPriority(final long handle); | |
975 | private native void setReportBgIoStats(final long handle, | |
976 | final boolean reportBgIoStats); | |
977 | private native boolean reportBgIoStats(final long handle); | |
494da23a TL |
978 | private native void setTtl(final long handle, final long ttl); |
979 | private native long ttl(final long handle); | |
7c673cae FG |
980 | private native void setCompactionOptionsUniversal(final long handle, |
981 | final long compactionOptionsUniversalHandle); | |
982 | private native void setCompactionOptionsFIFO(final long handle, | |
983 | final long compactionOptionsFIFOHandle); | |
984 | private native void setForceConsistencyChecks(final long handle, | |
985 | final boolean forceConsistencyChecks); | |
986 | private native boolean forceConsistencyChecks(final long handle); | |
987 | ||
988 | // instance variables | |
11fdf7f2 | 989 | // NOTE: If you add new member variables, please update the copy constructor above! |
7c673cae FG |
990 | private MemTableConfig memTableConfig_; |
991 | private TableFormatConfig tableFormatConfig_; | |
992 | private AbstractComparator<? extends AbstractSlice<?>> comparator_; | |
993 | private AbstractCompactionFilter<? extends AbstractSlice<?>> compactionFilter_; | |
494da23a | 994 | private AbstractCompactionFilterFactory<? extends AbstractCompactionFilter<?>> |
11fdf7f2 | 995 | compactionFilterFactory_; |
7c673cae FG |
996 | private CompactionOptionsUniversal compactionOptionsUniversal_; |
997 | private CompactionOptionsFIFO compactionOptionsFIFO_; | |
494da23a | 998 | private CompressionOptions bottommostCompressionOptions_; |
7c673cae FG |
999 | private CompressionOptions compressionOptions_; |
1000 | ||
1001 | } |