1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 6 package org.rocksdb; 7 8 import org.junit.ClassRule; 9 import org.junit.Test; 10 import org.rocksdb.test.RemoveEmptyValueCompactionFilterFactory; 11 12 import java.util.ArrayList; 13 import java.util.List; 14 import java.util.Properties; 15 import java.util.Random; 16 17 import static org.assertj.core.api.Assertions.assertThat; 18 19 public class ColumnFamilyOptionsTest { 20 21 @ClassRule 22 public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE = 23 new RocksNativeLibraryResource(); 24 25 public static final Random rand = PlatformRandomHelper. 26 getPlatformSpecificRandomFactory(); 27 28 @Test copyConstructor()29 public void copyConstructor() { 30 ColumnFamilyOptions origOpts = new ColumnFamilyOptions(); 31 origOpts.setNumLevels(rand.nextInt(8)); 32 origOpts.setTargetFileSizeMultiplier(rand.nextInt(100)); 33 origOpts.setLevel0StopWritesTrigger(rand.nextInt(50)); 34 ColumnFamilyOptions copyOpts = new ColumnFamilyOptions(origOpts); 35 assertThat(origOpts.numLevels()).isEqualTo(copyOpts.numLevels()); 36 assertThat(origOpts.targetFileSizeMultiplier()).isEqualTo(copyOpts.targetFileSizeMultiplier()); 37 assertThat(origOpts.level0StopWritesTrigger()).isEqualTo(copyOpts.level0StopWritesTrigger()); 38 } 39 40 @Test getColumnFamilyOptionsFromProps()41 public void getColumnFamilyOptionsFromProps() { 42 Properties properties = new Properties(); 43 properties.put("write_buffer_size", "112"); 44 properties.put("max_write_buffer_number", "13"); 45 46 try (final ColumnFamilyOptions opt = ColumnFamilyOptions. 47 getColumnFamilyOptionsFromProps(properties)) { 48 // setup sample properties 49 assertThat(opt).isNotNull(); 50 assertThat(String.valueOf(opt.writeBufferSize())). 51 isEqualTo(properties.get("write_buffer_size")); 52 assertThat(String.valueOf(opt.maxWriteBufferNumber())). 53 isEqualTo(properties.get("max_write_buffer_number")); 54 } 55 } 56 57 @Test failColumnFamilyOptionsFromPropsWithIllegalValue()58 public void failColumnFamilyOptionsFromPropsWithIllegalValue() { 59 // setup sample properties 60 final Properties properties = new Properties(); 61 properties.put("tomato", "1024"); 62 properties.put("burger", "2"); 63 64 try (final ColumnFamilyOptions opt = 65 ColumnFamilyOptions.getColumnFamilyOptionsFromProps(properties)) { 66 assertThat(opt).isNull(); 67 } 68 } 69 70 @Test(expected = IllegalArgumentException.class) failColumnFamilyOptionsFromPropsWithNullValue()71 public void failColumnFamilyOptionsFromPropsWithNullValue() { 72 try (final ColumnFamilyOptions opt = 73 ColumnFamilyOptions.getColumnFamilyOptionsFromProps(null)) { 74 } 75 } 76 77 @Test(expected = IllegalArgumentException.class) failColumnFamilyOptionsFromPropsWithEmptyProps()78 public void failColumnFamilyOptionsFromPropsWithEmptyProps() { 79 try (final ColumnFamilyOptions opt = 80 ColumnFamilyOptions.getColumnFamilyOptionsFromProps( 81 new Properties())) { 82 } 83 } 84 85 @Test writeBufferSize()86 public void writeBufferSize() throws RocksDBException { 87 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 88 final long longValue = rand.nextLong(); 89 opt.setWriteBufferSize(longValue); 90 assertThat(opt.writeBufferSize()).isEqualTo(longValue); 91 } 92 } 93 94 @Test maxWriteBufferNumber()95 public void maxWriteBufferNumber() { 96 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 97 final int intValue = rand.nextInt(); 98 opt.setMaxWriteBufferNumber(intValue); 99 assertThat(opt.maxWriteBufferNumber()).isEqualTo(intValue); 100 } 101 } 102 103 @Test minWriteBufferNumberToMerge()104 public void minWriteBufferNumberToMerge() { 105 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 106 final int intValue = rand.nextInt(); 107 opt.setMinWriteBufferNumberToMerge(intValue); 108 assertThat(opt.minWriteBufferNumberToMerge()).isEqualTo(intValue); 109 } 110 } 111 112 @Test numLevels()113 public void numLevels() { 114 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 115 final int intValue = rand.nextInt(); 116 opt.setNumLevels(intValue); 117 assertThat(opt.numLevels()).isEqualTo(intValue); 118 } 119 } 120 121 @Test levelZeroFileNumCompactionTrigger()122 public void levelZeroFileNumCompactionTrigger() { 123 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 124 final int intValue = rand.nextInt(); 125 opt.setLevelZeroFileNumCompactionTrigger(intValue); 126 assertThat(opt.levelZeroFileNumCompactionTrigger()).isEqualTo(intValue); 127 } 128 } 129 130 @Test levelZeroSlowdownWritesTrigger()131 public void levelZeroSlowdownWritesTrigger() { 132 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 133 final int intValue = rand.nextInt(); 134 opt.setLevelZeroSlowdownWritesTrigger(intValue); 135 assertThat(opt.levelZeroSlowdownWritesTrigger()).isEqualTo(intValue); 136 } 137 } 138 139 @Test levelZeroStopWritesTrigger()140 public void levelZeroStopWritesTrigger() { 141 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 142 final int intValue = rand.nextInt(); 143 opt.setLevelZeroStopWritesTrigger(intValue); 144 assertThat(opt.levelZeroStopWritesTrigger()).isEqualTo(intValue); 145 } 146 } 147 148 @Test targetFileSizeBase()149 public void targetFileSizeBase() { 150 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 151 final long longValue = rand.nextLong(); 152 opt.setTargetFileSizeBase(longValue); 153 assertThat(opt.targetFileSizeBase()).isEqualTo(longValue); 154 } 155 } 156 157 @Test targetFileSizeMultiplier()158 public void targetFileSizeMultiplier() { 159 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 160 final int intValue = rand.nextInt(); 161 opt.setTargetFileSizeMultiplier(intValue); 162 assertThat(opt.targetFileSizeMultiplier()).isEqualTo(intValue); 163 } 164 } 165 166 @Test maxBytesForLevelBase()167 public void maxBytesForLevelBase() { 168 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 169 final long longValue = rand.nextLong(); 170 opt.setMaxBytesForLevelBase(longValue); 171 assertThat(opt.maxBytesForLevelBase()).isEqualTo(longValue); 172 } 173 } 174 175 @Test levelCompactionDynamicLevelBytes()176 public void levelCompactionDynamicLevelBytes() { 177 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 178 final boolean boolValue = rand.nextBoolean(); 179 opt.setLevelCompactionDynamicLevelBytes(boolValue); 180 assertThat(opt.levelCompactionDynamicLevelBytes()) 181 .isEqualTo(boolValue); 182 } 183 } 184 185 @Test maxBytesForLevelMultiplier()186 public void maxBytesForLevelMultiplier() { 187 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 188 final double doubleValue = rand.nextDouble(); 189 opt.setMaxBytesForLevelMultiplier(doubleValue); 190 assertThat(opt.maxBytesForLevelMultiplier()).isEqualTo(doubleValue); 191 } 192 } 193 194 @Test maxBytesForLevelMultiplierAdditional()195 public void maxBytesForLevelMultiplierAdditional() { 196 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 197 final int intValue1 = rand.nextInt(); 198 final int intValue2 = rand.nextInt(); 199 final int[] ints = new int[]{intValue1, intValue2}; 200 opt.setMaxBytesForLevelMultiplierAdditional(ints); 201 assertThat(opt.maxBytesForLevelMultiplierAdditional()).isEqualTo(ints); 202 } 203 } 204 205 @Test maxCompactionBytes()206 public void maxCompactionBytes() { 207 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 208 final long longValue = rand.nextLong(); 209 opt.setMaxCompactionBytes(longValue); 210 assertThat(opt.maxCompactionBytes()).isEqualTo(longValue); 211 } 212 } 213 214 @Test softPendingCompactionBytesLimit()215 public void softPendingCompactionBytesLimit() { 216 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 217 final long longValue = rand.nextLong(); 218 opt.setSoftPendingCompactionBytesLimit(longValue); 219 assertThat(opt.softPendingCompactionBytesLimit()).isEqualTo(longValue); 220 } 221 } 222 223 @Test hardPendingCompactionBytesLimit()224 public void hardPendingCompactionBytesLimit() { 225 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 226 final long longValue = rand.nextLong(); 227 opt.setHardPendingCompactionBytesLimit(longValue); 228 assertThat(opt.hardPendingCompactionBytesLimit()).isEqualTo(longValue); 229 } 230 } 231 232 @Test level0FileNumCompactionTrigger()233 public void level0FileNumCompactionTrigger() { 234 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 235 final int intValue = rand.nextInt(); 236 opt.setLevel0FileNumCompactionTrigger(intValue); 237 assertThat(opt.level0FileNumCompactionTrigger()).isEqualTo(intValue); 238 } 239 } 240 241 @Test level0SlowdownWritesTrigger()242 public void level0SlowdownWritesTrigger() { 243 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 244 final int intValue = rand.nextInt(); 245 opt.setLevel0SlowdownWritesTrigger(intValue); 246 assertThat(opt.level0SlowdownWritesTrigger()).isEqualTo(intValue); 247 } 248 } 249 250 @Test level0StopWritesTrigger()251 public void level0StopWritesTrigger() { 252 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 253 final int intValue = rand.nextInt(); 254 opt.setLevel0StopWritesTrigger(intValue); 255 assertThat(opt.level0StopWritesTrigger()).isEqualTo(intValue); 256 } 257 } 258 259 @Test arenaBlockSize()260 public void arenaBlockSize() throws RocksDBException { 261 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 262 final long longValue = rand.nextLong(); 263 opt.setArenaBlockSize(longValue); 264 assertThat(opt.arenaBlockSize()).isEqualTo(longValue); 265 } 266 } 267 268 @Test disableAutoCompactions()269 public void disableAutoCompactions() { 270 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 271 final boolean boolValue = rand.nextBoolean(); 272 opt.setDisableAutoCompactions(boolValue); 273 assertThat(opt.disableAutoCompactions()).isEqualTo(boolValue); 274 } 275 } 276 277 @Test maxSequentialSkipInIterations()278 public void maxSequentialSkipInIterations() { 279 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 280 final long longValue = rand.nextLong(); 281 opt.setMaxSequentialSkipInIterations(longValue); 282 assertThat(opt.maxSequentialSkipInIterations()).isEqualTo(longValue); 283 } 284 } 285 286 @Test inplaceUpdateSupport()287 public void inplaceUpdateSupport() { 288 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 289 final boolean boolValue = rand.nextBoolean(); 290 opt.setInplaceUpdateSupport(boolValue); 291 assertThat(opt.inplaceUpdateSupport()).isEqualTo(boolValue); 292 } 293 } 294 295 @Test inplaceUpdateNumLocks()296 public void inplaceUpdateNumLocks() throws RocksDBException { 297 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 298 final long longValue = rand.nextLong(); 299 opt.setInplaceUpdateNumLocks(longValue); 300 assertThat(opt.inplaceUpdateNumLocks()).isEqualTo(longValue); 301 } 302 } 303 304 @Test memtablePrefixBloomSizeRatio()305 public void memtablePrefixBloomSizeRatio() { 306 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 307 final double doubleValue = rand.nextDouble(); 308 opt.setMemtablePrefixBloomSizeRatio(doubleValue); 309 assertThat(opt.memtablePrefixBloomSizeRatio()).isEqualTo(doubleValue); 310 } 311 } 312 313 @Test memtableHugePageSize()314 public void memtableHugePageSize() { 315 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 316 final long longValue = rand.nextLong(); 317 opt.setMemtableHugePageSize(longValue); 318 assertThat(opt.memtableHugePageSize()).isEqualTo(longValue); 319 } 320 } 321 322 @Test bloomLocality()323 public void bloomLocality() { 324 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 325 final int intValue = rand.nextInt(); 326 opt.setBloomLocality(intValue); 327 assertThat(opt.bloomLocality()).isEqualTo(intValue); 328 } 329 } 330 331 @Test maxSuccessiveMerges()332 public void maxSuccessiveMerges() throws RocksDBException { 333 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 334 final long longValue = rand.nextLong(); 335 opt.setMaxSuccessiveMerges(longValue); 336 assertThat(opt.maxSuccessiveMerges()).isEqualTo(longValue); 337 } 338 } 339 340 @Test optimizeFiltersForHits()341 public void optimizeFiltersForHits() { 342 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 343 final boolean aBoolean = rand.nextBoolean(); 344 opt.setOptimizeFiltersForHits(aBoolean); 345 assertThat(opt.optimizeFiltersForHits()).isEqualTo(aBoolean); 346 } 347 } 348 349 @Test memTable()350 public void memTable() throws RocksDBException { 351 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 352 opt.setMemTableConfig(new HashLinkedListMemTableConfig()); 353 assertThat(opt.memTableFactoryName()). 354 isEqualTo("HashLinkedListRepFactory"); 355 } 356 } 357 358 @Test comparator()359 public void comparator() throws RocksDBException { 360 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 361 opt.setComparator(BuiltinComparator.BYTEWISE_COMPARATOR); 362 } 363 } 364 365 @Test linkageOfPrepMethods()366 public void linkageOfPrepMethods() { 367 try (final ColumnFamilyOptions options = new ColumnFamilyOptions()) { 368 options.optimizeUniversalStyleCompaction(); 369 options.optimizeUniversalStyleCompaction(4000); 370 options.optimizeLevelStyleCompaction(); 371 options.optimizeLevelStyleCompaction(3000); 372 options.optimizeForPointLookup(10); 373 options.optimizeForSmallDb(); 374 } 375 } 376 377 @Test shouldSetTestPrefixExtractor()378 public void shouldSetTestPrefixExtractor() { 379 try (final ColumnFamilyOptions options = new ColumnFamilyOptions()) { 380 options.useFixedLengthPrefixExtractor(100); 381 options.useFixedLengthPrefixExtractor(10); 382 } 383 } 384 385 @Test shouldSetTestCappedPrefixExtractor()386 public void shouldSetTestCappedPrefixExtractor() { 387 try (final ColumnFamilyOptions options = new ColumnFamilyOptions()) { 388 options.useCappedPrefixExtractor(100); 389 options.useCappedPrefixExtractor(10); 390 } 391 } 392 393 @Test compressionTypes()394 public void compressionTypes() { 395 try (final ColumnFamilyOptions columnFamilyOptions 396 = new ColumnFamilyOptions()) { 397 for (final CompressionType compressionType : 398 CompressionType.values()) { 399 columnFamilyOptions.setCompressionType(compressionType); 400 assertThat(columnFamilyOptions.compressionType()). 401 isEqualTo(compressionType); 402 assertThat(CompressionType.valueOf("NO_COMPRESSION")). 403 isEqualTo(CompressionType.NO_COMPRESSION); 404 } 405 } 406 } 407 408 @Test compressionPerLevel()409 public void compressionPerLevel() { 410 try (final ColumnFamilyOptions columnFamilyOptions 411 = new ColumnFamilyOptions()) { 412 assertThat(columnFamilyOptions.compressionPerLevel()).isEmpty(); 413 List<CompressionType> compressionTypeList = new ArrayList<>(); 414 for (int i = 0; i < columnFamilyOptions.numLevels(); i++) { 415 compressionTypeList.add(CompressionType.NO_COMPRESSION); 416 } 417 columnFamilyOptions.setCompressionPerLevel(compressionTypeList); 418 compressionTypeList = columnFamilyOptions.compressionPerLevel(); 419 for (CompressionType compressionType : compressionTypeList) { 420 assertThat(compressionType).isEqualTo( 421 CompressionType.NO_COMPRESSION); 422 } 423 } 424 } 425 426 @Test differentCompressionsPerLevel()427 public void differentCompressionsPerLevel() { 428 try (final ColumnFamilyOptions columnFamilyOptions 429 = new ColumnFamilyOptions()) { 430 columnFamilyOptions.setNumLevels(3); 431 432 assertThat(columnFamilyOptions.compressionPerLevel()).isEmpty(); 433 List<CompressionType> compressionTypeList = new ArrayList<>(); 434 435 compressionTypeList.add(CompressionType.BZLIB2_COMPRESSION); 436 compressionTypeList.add(CompressionType.SNAPPY_COMPRESSION); 437 compressionTypeList.add(CompressionType.LZ4_COMPRESSION); 438 439 columnFamilyOptions.setCompressionPerLevel(compressionTypeList); 440 compressionTypeList = columnFamilyOptions.compressionPerLevel(); 441 442 assertThat(compressionTypeList.size()).isEqualTo(3); 443 assertThat(compressionTypeList). 444 containsExactly( 445 CompressionType.BZLIB2_COMPRESSION, 446 CompressionType.SNAPPY_COMPRESSION, 447 CompressionType.LZ4_COMPRESSION); 448 449 } 450 } 451 452 @Test bottommostCompressionType()453 public void bottommostCompressionType() { 454 try (final ColumnFamilyOptions columnFamilyOptions 455 = new ColumnFamilyOptions()) { 456 assertThat(columnFamilyOptions.bottommostCompressionType()) 457 .isEqualTo(CompressionType.DISABLE_COMPRESSION_OPTION); 458 459 for (final CompressionType compressionType : CompressionType.values()) { 460 columnFamilyOptions.setBottommostCompressionType(compressionType); 461 assertThat(columnFamilyOptions.bottommostCompressionType()) 462 .isEqualTo(compressionType); 463 } 464 } 465 } 466 467 @Test bottommostCompressionOptions()468 public void bottommostCompressionOptions() { 469 try (final ColumnFamilyOptions columnFamilyOptions = 470 new ColumnFamilyOptions(); 471 final CompressionOptions bottommostCompressionOptions = 472 new CompressionOptions() 473 .setMaxDictBytes(123)) { 474 475 columnFamilyOptions.setBottommostCompressionOptions( 476 bottommostCompressionOptions); 477 assertThat(columnFamilyOptions.bottommostCompressionOptions()) 478 .isEqualTo(bottommostCompressionOptions); 479 assertThat(columnFamilyOptions.bottommostCompressionOptions() 480 .maxDictBytes()).isEqualTo(123); 481 } 482 } 483 484 @Test compressionOptions()485 public void compressionOptions() { 486 try (final ColumnFamilyOptions columnFamilyOptions 487 = new ColumnFamilyOptions(); 488 final CompressionOptions compressionOptions = new CompressionOptions() 489 .setMaxDictBytes(123)) { 490 491 columnFamilyOptions.setCompressionOptions(compressionOptions); 492 assertThat(columnFamilyOptions.compressionOptions()) 493 .isEqualTo(compressionOptions); 494 assertThat(columnFamilyOptions.compressionOptions().maxDictBytes()) 495 .isEqualTo(123); 496 } 497 } 498 499 @Test compactionStyles()500 public void compactionStyles() { 501 try (final ColumnFamilyOptions columnFamilyOptions 502 = new ColumnFamilyOptions()) { 503 for (final CompactionStyle compactionStyle : 504 CompactionStyle.values()) { 505 columnFamilyOptions.setCompactionStyle(compactionStyle); 506 assertThat(columnFamilyOptions.compactionStyle()). 507 isEqualTo(compactionStyle); 508 assertThat(CompactionStyle.valueOf("FIFO")). 509 isEqualTo(CompactionStyle.FIFO); 510 } 511 } 512 } 513 514 @Test maxTableFilesSizeFIFO()515 public void maxTableFilesSizeFIFO() { 516 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 517 long longValue = rand.nextLong(); 518 // Size has to be positive 519 longValue = (longValue < 0) ? -longValue : longValue; 520 longValue = (longValue == 0) ? longValue + 1 : longValue; 521 opt.setMaxTableFilesSizeFIFO(longValue); 522 assertThat(opt.maxTableFilesSizeFIFO()). 523 isEqualTo(longValue); 524 } 525 } 526 527 @Test maxWriteBufferNumberToMaintain()528 public void maxWriteBufferNumberToMaintain() { 529 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 530 int intValue = rand.nextInt(); 531 // Size has to be positive 532 intValue = (intValue < 0) ? -intValue : intValue; 533 intValue = (intValue == 0) ? intValue + 1 : intValue; 534 opt.setMaxWriteBufferNumberToMaintain(intValue); 535 assertThat(opt.maxWriteBufferNumberToMaintain()). 536 isEqualTo(intValue); 537 } 538 } 539 540 @Test compactionPriorities()541 public void compactionPriorities() { 542 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 543 for (final CompactionPriority compactionPriority : 544 CompactionPriority.values()) { 545 opt.setCompactionPriority(compactionPriority); 546 assertThat(opt.compactionPriority()). 547 isEqualTo(compactionPriority); 548 } 549 } 550 } 551 552 @Test reportBgIoStats()553 public void reportBgIoStats() { 554 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 555 final boolean booleanValue = true; 556 opt.setReportBgIoStats(booleanValue); 557 assertThat(opt.reportBgIoStats()). 558 isEqualTo(booleanValue); 559 } 560 } 561 562 @Test ttl()563 public void ttl() { 564 try (final ColumnFamilyOptions options = new ColumnFamilyOptions()) { 565 options.setTtl(1000 * 60); 566 assertThat(options.ttl()). 567 isEqualTo(1000 * 60); 568 } 569 } 570 571 @Test compactionOptionsUniversal()572 public void compactionOptionsUniversal() { 573 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions(); 574 final CompactionOptionsUniversal optUni = new CompactionOptionsUniversal() 575 .setCompressionSizePercent(7)) { 576 opt.setCompactionOptionsUniversal(optUni); 577 assertThat(opt.compactionOptionsUniversal()). 578 isEqualTo(optUni); 579 assertThat(opt.compactionOptionsUniversal().compressionSizePercent()) 580 .isEqualTo(7); 581 } 582 } 583 584 @Test compactionOptionsFIFO()585 public void compactionOptionsFIFO() { 586 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions(); 587 final CompactionOptionsFIFO optFifo = new CompactionOptionsFIFO() 588 .setMaxTableFilesSize(2000)) { 589 opt.setCompactionOptionsFIFO(optFifo); 590 assertThat(opt.compactionOptionsFIFO()). 591 isEqualTo(optFifo); 592 assertThat(opt.compactionOptionsFIFO().maxTableFilesSize()) 593 .isEqualTo(2000); 594 } 595 } 596 597 @Test forceConsistencyChecks()598 public void forceConsistencyChecks() { 599 try (final ColumnFamilyOptions opt = new ColumnFamilyOptions()) { 600 final boolean booleanValue = true; 601 opt.setForceConsistencyChecks(booleanValue); 602 assertThat(opt.forceConsistencyChecks()). 603 isEqualTo(booleanValue); 604 } 605 } 606 607 @Test compactionFilter()608 public void compactionFilter() { 609 try(final ColumnFamilyOptions options = new ColumnFamilyOptions(); 610 final RemoveEmptyValueCompactionFilter cf = new RemoveEmptyValueCompactionFilter()) { 611 options.setCompactionFilter(cf); 612 assertThat(options.compactionFilter()).isEqualTo(cf); 613 } 614 } 615 616 @Test compactionFilterFactory()617 public void compactionFilterFactory() { 618 try(final ColumnFamilyOptions options = new ColumnFamilyOptions(); 619 final RemoveEmptyValueCompactionFilterFactory cff = new RemoveEmptyValueCompactionFilterFactory()) { 620 options.setCompactionFilterFactory(cff); 621 assertThat(options.compactionFilterFactory()).isEqualTo(cff); 622 } 623 } 624 625 } 626