]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/test/java/org/rocksdb/DirectComparatorTest.java
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / java / src / test / java / org / rocksdb / DirectComparatorTest.java
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 org.junit.ClassRule;
9 import org.junit.Rule;
10 import org.junit.Test;
11 import org.junit.rules.TemporaryFolder;
12
13 import java.io.IOException;
14 import java.nio.file.FileSystems;
15
16 public class DirectComparatorTest {
17 @ClassRule
18 public static final RocksMemoryResource rocksMemoryResource =
19 new RocksMemoryResource();
20
21 @Rule
22 public TemporaryFolder dbFolder = new TemporaryFolder();
23
24 @Test
25 public void directComparator() throws IOException, RocksDBException {
26
27 final AbstractComparatorTest comparatorTest = new AbstractComparatorTest() {
28 @Override
29 public AbstractComparator getAscendingIntKeyComparator() {
30 return new DirectComparator(new ComparatorOptions()) {
31
32 @Override
33 public String name() {
34 return "test.AscendingIntKeyDirectComparator";
35 }
36
37 @Override
38 public int compare(final DirectSlice a, final DirectSlice b) {
39 final byte ax[] = new byte[4], bx[] = new byte[4];
40 a.data().get(ax);
41 b.data().get(bx);
42 return compareIntKeys(ax, bx);
43 }
44 };
45 }
46 };
47
48 // test the round-tripability of keys written and read with the DirectComparator
49 comparatorTest.testRoundtrip(FileSystems.getDefault().getPath(
50 dbFolder.getRoot().getAbsolutePath()));
51 }
52 }