mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 08:46:46 +00:00
Refactor filter impl
This commit is contained in:
23
java/org/rocksdb/BloomFilter.java
Normal file
23
java/org/rocksdb/BloomFilter.java
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
||||
// This source code is licensed under the BSD-style license found in the
|
||||
// LICENSE file in the root directory of this source tree. An additional grant
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
package org.rocksdb;
|
||||
|
||||
public class BloomFilter extends Filter {
|
||||
private final int bitsPerKey_;
|
||||
|
||||
public BloomFilter(int bitsPerKey) {
|
||||
super();
|
||||
bitsPerKey_ = bitsPerKey;
|
||||
createNewFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createNewFilter() {
|
||||
createNewFilter0(bitsPerKey_);
|
||||
}
|
||||
|
||||
private native void createNewFilter0(int bitsKeyKey);
|
||||
}
|
||||
@@ -17,12 +17,10 @@ package org.rocksdb;
|
||||
* A good value for bitsPerKey is 10, which yields a filter
|
||||
* with ~ 1% false positive rate.
|
||||
*/
|
||||
public class Filter {
|
||||
private long nativeHandle_;
|
||||
|
||||
public Filter(int bitsPerKey) {
|
||||
newFilter(bitsPerKey);
|
||||
}
|
||||
public abstract class Filter {
|
||||
protected long nativeHandle_ = 0;
|
||||
|
||||
protected abstract void createNewFilter();
|
||||
|
||||
/**
|
||||
* Deletes underlying C++ filter pointer.
|
||||
@@ -37,10 +35,9 @@ public class Filter {
|
||||
dispose();
|
||||
}
|
||||
|
||||
private boolean isInitialized() {
|
||||
protected boolean isInitialized() {
|
||||
return (nativeHandle_ != 0);
|
||||
}
|
||||
|
||||
private native void newFilter(int bitsPerKey);
|
||||
private native void dispose0(long handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user