# parquet.bloom

> A module of parquet's API.

Split-block bloom filters — `might_contain` for equality predicates.

Parquet's bloom filter is the "split block" design: the bit set is a sequence
of 32-byte blocks of eight 32-bit words, a value picks one block from the top
32 bits of its XXH64 hash, and eight salts turn the bottom 32 bits into one bit
per word. A value is definitely absent if any of those eight bits is clear.

```mojo
var bf = read_bloom_filter(Span(file_bytes), cm)
if bf and not bf.value().might_contain_string("alice"):
    ...  # this row group cannot contain it
```

## Structs

### `BloomFilter`

```mojo
struct BloomFilter
```

One column chunk's split-block bloom filter bit set.

Implements: `Copyable`, `Defaultable`, `Movable`

Fields:

- `bits: List[UInt8]`

#### `__init__`

```mojo
def __init__(out self)
```

```mojo
def __init__(out self, var bits: List[UInt8])
```

#### `num_blocks`

```mojo
def num_blocks(self) -> Int
```

#### `might_contain_hash`

```mojo
def might_contain_hash(self, hash: UInt64) -> Bool
```

#### `might_contain_bytes`

```mojo
def might_contain_bytes(self, data: Span[UInt8]) -> Bool
```

#### `might_contain_string`

```mojo
def might_contain_string(self, text: StringSpan) -> Bool
```

#### `might_contain_i32`

```mojo
def might_contain_i32(self, v: Int32) -> Bool
```

#### `might_contain_i64`

```mojo
def might_contain_i64(self, v: Int64) -> Bool
```

#### `might_contain_f32`

```mojo
def might_contain_f32(self, v: Float32) -> Bool
```

#### `might_contain_f64`

```mojo
def might_contain_f64(self, v: Float64) -> Bool
```

#### `might_contain`

```mojo
def might_contain(self, value: ScalarValue) -> Bool
```

Hash a `ScalarValue` the way Parquet's PLAIN encoding would.

## Functions

### `read_bloom_filter`

```mojo
def read_bloom_filter(file: Span[UInt8], cm: ColumnMetaData) -> Optional[BloomFilter]
```

Read the bloom filter of one column chunk, or `None` if it has none.

## Aliases

### `BLOOM_BLOCK_BYTES`

```mojo
comptime BLOOM_BLOCK_BYTES = 32
```

### `SALT0`

```mojo
comptime SALT0 = UInt32(1203114875)
```

### `SALT1`

```mojo
comptime SALT1 = UInt32(1150766481)
```

### `SALT2`

```mojo
comptime SALT2 = UInt32(2284105051)
```

### `SALT3`

```mojo
comptime SALT3 = UInt32(2729912477)
```

### `SALT4`

```mojo
comptime SALT4 = UInt32(1884591559)
```

### `SALT5`

```mojo
comptime SALT5 = UInt32(770785867)
```

### `SALT6`

```mojo
comptime SALT6 = UInt32(2667333959)
```

### `SALT7`

```mojo
comptime SALT7 = UInt32(1550580529)
```
