Repository navigation
Prune absent measurements in place with the Bloom filter - #1183
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1183 +/- ##
========================================
Coverage 69.48% 69.48%
========================================
Files 798 798
Lines 59120 59138 +18
Branches 9639 9642 +3
========================================
+ Hits 41077 41093 +16
- Misses 16254 16256 +2
Partials 1789 1789 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
3 open issues
The behavior fornullmeasurement entries is now part of the observable contract (they are… · NewremoveNotExistingMeasurementsis grammatically awkward for a public API. Consider renaming to… · New UsingTsFileConstant.PATH_SEPARATOR.equals(prefix)as the empty-device check makes the control… · New
What changed in this PR
Adds an in-place pruning API to BloomFilter so callers can efficiently remove definite-miss measurement candidates from a mutable set while receiving per-removal callbacks.
Changes:
- Introduces
BloomFilter.removeNotExistingMeasurements(...)and refactors shared path-matching logic behind helpers. - Expands
BloomFilterTestcoverage for in-place pruning behavior (including null / time column / empty-device path forms). - Updates Java SDK reference docs to describe the new mutable-set workflow.
| File | Description |
|---|---|
| skills/tsfile/references/java.md | Documents the new in-place pruning API for mutable candidate sets. |
| java/tsfile/src/main/java/org/apache/tsfile/utils/BloomFilter.java | Adds removeNotExistingMeasurements and factors out shared prefix/measurement matching logic. |
| java/tsfile/src/test/java/org/apache/tsfile/utils/BloomFilterTest.java | Adds tests validating pruning, callback timing/identity, and empty-device path behavior. |
Review effort: Lite
| public void removeNotExistingMeasurements( | ||
| IDeviceID device, Set<String> measurements, BiConsumer<IDeviceID, String> onAbsent) { |
| private boolean mightContainMeasurement( | ||
| String prefix, Murmur128Hash.PrefixHasher hasher, String measurement) { | ||
| if (measurement == null) { | ||
| return false; | ||
| } | ||
| boolean matchesFullPath = | ||
| hasher == null ? contains(prefix + measurement) : mightContain(hasher, measurement); | ||
| // For an empty device the prefix is just the separator. Also check the bare measurement. | ||
| return matchesFullPath | ||
| || (TsFileConstant.PATH_SEPARATOR.equals(prefix) && contains(measurement)); | ||
| } |


Summary
Add
BloomFilter.removeNotExistingMeasurements(IDeviceID, Set<String>, BiConsumer<IDeviceID, String>)for callers that already have a mutable set of metadata candidates. It reuses the device prefix across probes, removes each definite miss through the set iterator, and calls the consumer once per removal. The existingmightContainBatchAPI uses the same path matching logic.Example
Given candidates
{temperature, pressure}for one device, if the filter rules outpressure, the callback receives the device andpressure. The caller can pass the remaining set{temperature}directly to the metadata reader. IoTDB can use the callback to record a null entry for the missing column in its query result.This is a Java SDK operation on an in-memory candidate set. The TsFile CLI has no command that exposes a mutable metadata candidate set.
Verification
./mvnw -P with-java verifyThis PR continues #1181 from a branch in
apache/tsfileso same-repository CI can run.