# Bloom Filter

A Bloom Filter (located in `Pronghorn`) is a space-efficient probabilistic data structure used in Pronghorn for fast data lookup.

Pronghorn uses [MurmurHash](https://en.wikipedia.org/wiki/MurmurHash) for its hash-based lookups.

### Usage <a href="#usage" id="usage"></a>

```java
BloomFilter filter = new BloomFilter(n, p);
BloomFilter filter = new BloomFilter(template); // alternative
BloomFilter filter = new BloomFilter(a, b, intersection); // alternative
```

* `n` is the number of items in the filter
* `p` is the probability of false positives, float between 0 and 1 or a number indicating 1-in-p
* `template` is a previous BloomFilter that you can re-use
* `a` and `b` are previous bloom filters for intersection checking
* `intersection` determines if there is an intersection

### Example <a href="#example" id="example"></a>

```java
String[] messages = new String[] { "Moe", "Larry", "Curley" };
BloomFilter filter = new BloomFilter(1000, .00000001);

//build up the filter with the known values.
int i = messages.length;
while (--i>=0) {
    filter.addValue(messages[i]);
}

//check if it contains
if(filter.mayContain(messages[0])) {
    //do something
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://oci-pronghorn.gitbook.io/pronghorn/chapter-5-utility-classes/bloom-filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
