Skip to content

Prune absent measurements in place with the Bloom filter - #1183

Merged
ColinLeeo merged 3 commits into
developfrom
perf/bloom-prune-measurements
Dec 3, 2026
Merged

ColinLeeo merged 3 commits into
developfrom
perf/bloom-prune-measurements

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

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 existing mightContainBatch API uses the same path matching logic.

Example

Given candidates {temperature, pressure} for one device, if the filter rules out pressure, the callback receives the device and pressure. 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 verify
  • Covered callback timing and identity, missing and present names in the same batch, null names, the time column, and both path forms for an empty device ID.

This PR continues #1181 from a branch in apache/tsfile so same-repository CI can run.

@codecov-commenter

codecov-commenter commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.48%. Comparing base (42f03c6) to head (929c991).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...main/java/org/apache/tsfile/utils/BloomFilter.java 92.85% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ColinLeeo
ColinLeeo requested a balanced review from Copilot December 3, 2026 04:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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 BloomFilterTest coverage 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

Comment on lines +178 to +179
public void removeNotExistingMeasurements(
IDeviceID device, Set<String> measurements, BiConsumer<IDeviceID, String> onAbsent) {
Comment on lines +208 to +218
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));
}
@ColinLeeo
ColinLeeo merged commit 42168ea into develop Dec 3, 2026
27 checks passed
@JackieTien97
JackieTien97 deleted the perf/bloom-prune-measurements branch December 3, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants