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