All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rocksdb.BloomFilter Maven / Gradle / Ivy

The newest version!
// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under both the GPLv2 (found in the
//  COPYING file in the root directory) and Apache 2.0 License
//  (found in the LICENSE.Apache file in the root directory).

package org.rocksdb;

/**
 * Bloom filter policy that uses a bloom filter with approximately
 * the specified number of bits per key.
 *
 * 

* Note: if you are using a custom comparator that ignores some parts * of the keys being compared, you must not use this {@code BloomFilter} * and must provide your own FilterPolicy that also ignores the * corresponding parts of the keys. For example, if the comparator * ignores trailing spaces, it would be incorrect to use a * FilterPolicy (like {@code BloomFilter}) that does not ignore * trailing spaces in keys.

*/ public class BloomFilter extends Filter { private static final int DEFAULT_BITS_PER_KEY = 10; private static final boolean DEFAULT_MODE = true; /** * BloomFilter constructor * *

* Callers must delete the result after any database that is using the * result has been closed.

*/ public BloomFilter() { this(DEFAULT_BITS_PER_KEY, DEFAULT_MODE); } /** * BloomFilter constructor * *

* bits_per_key: bits per key in bloom filter. A good value for bits_per_key * is 10, which yields a filter with ~ 1% false positive rate. *

*

* Callers must delete the result after any database that is using the * result has been closed.

* * @param bitsPerKey number of bits to use */ public BloomFilter(final int bitsPerKey) { this(bitsPerKey, DEFAULT_MODE); } /** * BloomFilter constructor * *

* bits_per_key: bits per key in bloom filter. A good value for bits_per_key * is 10, which yields a filter with ~ 1% false positive rate. *

default bits_per_key: 10

* *

use_block_based_builder: use block based filter rather than full filter. * If you want to builder full filter, it needs to be set to false. *

*

default mode: block based filter

*

* Callers must delete the result after any database that is using the * result has been closed.

* * @param bitsPerKey number of bits to use * @param useBlockBasedMode use block based mode or full filter mode */ public BloomFilter(final int bitsPerKey, final boolean useBlockBasedMode) { super(createNewBloomFilter(bitsPerKey, useBlockBasedMode)); } private native static long createNewBloomFilter(final int bitsKeyKey, final boolean useBlockBasedMode); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy