]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/java/src/main/java/org/rocksdb/BloomFilter.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.
9 * Bloom filter policy that uses a bloom filter with approximately
10 * the specified number of bits per key.
13 * Note: if you are using a custom comparator that ignores some parts
14 * of the keys being compared, you must not use this {@code BloomFilter}
15 * and must provide your own FilterPolicy that also ignores the
16 * corresponding parts of the keys. For example, if the comparator
17 * ignores trailing spaces, it would be incorrect to use a
18 * FilterPolicy (like {@code BloomFilter}) that does not ignore
19 * trailing spaces in keys.</p>
21 public class BloomFilter
extends Filter
{
23 private static final int DEFAULT_BITS_PER_KEY
= 10;
24 private static final boolean DEFAULT_MODE
= true;
27 * BloomFilter constructor
30 * Callers must delete the result after any database that is using the
31 * result has been closed.</p>
33 public BloomFilter() {
34 this(DEFAULT_BITS_PER_KEY
, DEFAULT_MODE
);
38 * BloomFilter constructor
41 * bits_per_key: bits per key in bloom filter. A good value for bits_per_key
42 * is 10, which yields a filter with ~ 1% false positive rate.
45 * Callers must delete the result after any database that is using the
46 * result has been closed.</p>
48 * @param bitsPerKey number of bits to use
50 public BloomFilter(final int bitsPerKey
) {
51 this(bitsPerKey
, DEFAULT_MODE
);
55 * BloomFilter constructor
58 * bits_per_key: bits per key in bloom filter. A good value for bits_per_key
59 * is 10, which yields a filter with ~ 1% false positive rate.
60 * <p><strong>default bits_per_key</strong>: 10</p>
62 * <p>use_block_based_builder: use block based filter rather than full filter.
63 * If you want to builder full filter, it needs to be set to false.
65 * <p><strong>default mode: block based filter</strong></p>
67 * Callers must delete the result after any database that is using the
68 * result has been closed.</p>
70 * @param bitsPerKey number of bits to use
71 * @param useBlockBasedMode use block based mode or full filter mode
73 public BloomFilter(final int bitsPerKey
, final boolean useBlockBasedMode
) {
74 super(createNewBloomFilter(bitsPerKey
, useBlockBasedMode
));
77 private native static long createNewBloomFilter(final int bitsKeyKey
,
78 final boolean useBlockBasedMode
);