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.
8 import org
.junit
.ClassRule
;
10 import org
.junit
.Test
;
11 import org
.junit
.rules
.TemporaryFolder
;
13 import java
.io
.IOException
;
14 import java
.nio
.file
.FileSystems
;
16 public class DirectComparatorTest
{
18 public static final RocksMemoryResource rocksMemoryResource
=
19 new RocksMemoryResource();
22 public TemporaryFolder dbFolder
= new TemporaryFolder();
25 public void directComparator() throws IOException
, RocksDBException
{
27 final AbstractComparatorTest comparatorTest
= new AbstractComparatorTest() {
29 public AbstractComparator
getAscendingIntKeyComparator() {
30 return new DirectComparator(new ComparatorOptions()) {
33 public String
name() {
34 return "test.AscendingIntKeyDirectComparator";
38 public int compare(final DirectSlice a
, final DirectSlice b
) {
39 final byte ax
[] = new byte[4], bx
[] = new byte[4];
42 return compareIntKeys(ax
, bx
);
48 // test the round-tripability of keys written and read with the DirectComparator
49 comparatorTest
.testRoundtrip(FileSystems
.getDefault().getPath(
50 dbFolder
.getRoot().getAbsolutePath()));