1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
8 import static org
.assertj
.core
.api
.Assertions
.assertThat
;
10 import java
.util
.Random
;
11 import org
.junit
.ClassRule
;
12 import org
.junit
.Test
;
14 public class WriteOptionsTest
{
17 public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE
=
18 new RocksNativeLibraryResource();
20 public static final Random rand
= PlatformRandomHelper
.
21 getPlatformSpecificRandomFactory();
24 public void writeOptions() {
25 try (final WriteOptions writeOptions
= new WriteOptions()) {
27 writeOptions
.setSync(true);
28 assertThat(writeOptions
.sync()).isTrue();
29 writeOptions
.setSync(false);
30 assertThat(writeOptions
.sync()).isFalse();
32 writeOptions
.setDisableWAL(true);
33 assertThat(writeOptions
.disableWAL()).isTrue();
34 writeOptions
.setDisableWAL(false);
35 assertThat(writeOptions
.disableWAL()).isFalse();
38 writeOptions
.setIgnoreMissingColumnFamilies(true);
39 assertThat(writeOptions
.ignoreMissingColumnFamilies()).isTrue();
40 writeOptions
.setIgnoreMissingColumnFamilies(false);
41 assertThat(writeOptions
.ignoreMissingColumnFamilies()).isFalse();
43 writeOptions
.setNoSlowdown(true);
44 assertThat(writeOptions
.noSlowdown()).isTrue();
45 writeOptions
.setNoSlowdown(false);
46 assertThat(writeOptions
.noSlowdown()).isFalse();
48 writeOptions
.setLowPri(true);
49 assertThat(writeOptions
.lowPri()).isTrue();
50 writeOptions
.setLowPri(false);
51 assertThat(writeOptions
.lowPri()).isFalse();
53 writeOptions
.setMemtableInsertHintPerBatch(true);
54 assertThat(writeOptions
.memtableInsertHintPerBatch()).isTrue();
55 writeOptions
.setMemtableInsertHintPerBatch(false);
56 assertThat(writeOptions
.memtableInsertHintPerBatch()).isFalse();
61 public void copyConstructor() {
62 WriteOptions origOpts
= new WriteOptions();
63 origOpts
.setDisableWAL(rand
.nextBoolean());
64 origOpts
.setIgnoreMissingColumnFamilies(rand
.nextBoolean());
65 origOpts
.setSync(rand
.nextBoolean());
66 origOpts
.setMemtableInsertHintPerBatch(true);
67 WriteOptions copyOpts
= new WriteOptions(origOpts
);
68 assertThat(origOpts
.disableWAL()).isEqualTo(copyOpts
.disableWAL());
69 assertThat(origOpts
.ignoreMissingColumnFamilies()).isEqualTo(
70 copyOpts
.ignoreMissingColumnFamilies());
71 assertThat(origOpts
.sync()).isEqualTo(copyOpts
.sync());
72 assertThat(origOpts
.memtableInsertHintPerBatch())
73 .isEqualTo(copyOpts
.memtableInsertHintPerBatch());