]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/test/java/org/rocksdb/SstPartitionerTest.java
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / java / src / test / java / org / rocksdb / SstPartitionerTest.java
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 static org.assertj.core.api.Assertions.assertThat;
9
10 import java.util.List;
11 import org.junit.ClassRule;
12 import org.junit.Rule;
13 import org.junit.Test;
14 import org.junit.rules.TemporaryFolder;
15
16 public class SstPartitionerTest {
17 @ClassRule
18 public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
19 new RocksNativeLibraryResource();
20
21 @Rule public TemporaryFolder dbFolder = new TemporaryFolder();
22
23 @Test
24 public void sstFixedPrefix() throws InterruptedException, RocksDBException {
25 try (SstPartitionerFixedPrefixFactory factory = new SstPartitionerFixedPrefixFactory(4);
26 final Options opt =
27 new Options().setCreateIfMissing(true).setSstPartitionerFactory(factory);
28 final RocksDB db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath())) {
29 // writing (long)100 under key
30 db.put("aaaa1".getBytes(), "A".getBytes());
31 db.put("bbbb1".getBytes(), "B".getBytes());
32 db.flush(new FlushOptions());
33
34 db.put("aaaa1".getBytes(), "A2".getBytes());
35 db.flush(new FlushOptions());
36
37 db.compactRange();
38
39 List<LiveFileMetaData> metadata = db.getLiveFilesMetaData();
40 assertThat(metadata.size()).isEqualTo(2);
41 }
42 }
43 }