Repository navigation
Batch Bloom filter lookups for measurements on one device - #1143
Conversation
Probe measurements of one device together and return matches in input order. Reuse complete Murmur hash blocks from the device prefix while preserving compatibility with existing filters. This SDK lookup operates on an in-memory filter and requires no CLI option.
There was a problem hiding this comment.
🟡 Changes recommended
Batch Bloom-filter lookups can falsely exclude stored measurements for empty device IDs, while eager prefix hashing adds unnecessary work for small negative batches.
2 open issues
What changed in this PR
Adds a Java SDK API for batch Bloom-filter checks across measurements on one device, without changing the on-disk filter format.
Changes:
- Returns membership candidates in a
BitSetmatching input iteration order. - Reuses UTF-8 device-prefix hash state, with a fallback for other default charsets.
- Adds regression tests and Java SDK usage guidance.
| File | Description |
|---|---|
skills/tsfile/references/java.md |
Documents batch lookup usage and result interpretation. |
java/tsfile/src/test/java/org/apache/tsfile/utils/BloomFilterTest.java |
Adds ordering, boundary, non-ASCII, and existing-filter compatibility tests. |
java/tsfile/src/main/java/org/apache/tsfile/utils/Murmur128Hash.java |
Refactors hashing to support reusable prefix state. |
java/tsfile/src/main/java/org/apache/tsfile/utils/BloomFilter.java |
Adds batch membership checks and shared bit-index calculation. |
Review effort: Max
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
3 resolved since last review
Review effort: Lite
JackieTien97
left a comment
There was a problem hiding this comment.
Overall the batch lookup semantics, UTF-8 prefix boundary handling, empty-device fallback, and on-disk compatibility look solid. Left a few inline comments on Murmur128Hash.innerHash slice semantics / prefix buffer layout, null-argument consistency, hot-path allocations, and docs/tests.
JackieTien97
left a comment
There was a problem hiding this comment.
LGTM, thanks for the updates!



Summary
Add
BloomFilter.mightContainBatch(IDeviceID device, Collection<String> measurements)for callers that probe several measurements on one device, such as IoTDB's aligned time-series metadata cache. The returnedBitSetfollows the input's iteration order. A clear bit rules out the path. A set bit means the path may exist.For UTF-8 paths, the implementation reuses the hash state for complete 16-byte blocks of the device prefix within a single call. Other default charsets use the existing full-path lookup. Both paths work with filters written by existing TsFile versions.
Example
Bits 0 and 2 are set for the inserted measurement. Bit 1 has the same value as the individual lookup for
pressure. Passing an empty measurement name probes the device's time column.Performance
The benchmark measures the time to produce a candidate
BitSetfor one device with a preloaded Bloom filter and prepared inputs. Ondevelop(5db3d0c5), the caller loops overcontains(Path)with each full path string already cached. This PR (154ce991) callsmightContainBatch(device, measurements)once per request. Both produce identical bitsets.develop(µs/request)Times are medians of the per-request means from five independent JVM runs on macOS arm64 with OpenJDK 25.0.1, G1 and a fixed 1 GiB heap.
Tests
Regression tests compare batch results with individual lookups, cover block boundaries and non-ASCII names, and read bit patterns from existing writer versions. This is a Java SDK API for in-memory filters and requires no new CLI option.
Local validation on the new base passed:
clean verify -P with-java,with-python -Denable.lzma2=ONand the all-language Spotless check.Supersedes #1142. The change applies directly to
develop.