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
.List
;
11 import org
.junit
.ClassRule
;
12 import org
.junit
.Rule
;
13 import org
.junit
.Test
;
14 import org
.junit
.rules
.TemporaryFolder
;
16 public class SstPartitionerTest
{
18 public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE
=
19 new RocksNativeLibraryResource();
21 @Rule public TemporaryFolder dbFolder
= new TemporaryFolder();
24 public void sstFixedPrefix() throws InterruptedException
, RocksDBException
{
25 try (SstPartitionerFixedPrefixFactory factory
= new SstPartitionerFixedPrefixFactory(4);
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());
34 db
.put("aaaa1".getBytes(), "A2".getBytes());
35 db
.flush(new FlushOptions());
39 List
<LiveFileMetaData
> metadata
= db
.getLiveFilesMetaData();
40 assertThat(metadata
.size()).isEqualTo(2);