Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the shared TAG/FIELD predicate-tree refactor.
No open issues 🎉
What changed in this PR
Refactors C++ TAG and FIELD filters to share a predicate tree, separating the native changes from the Python binding work in #1169.
Changes:
- Shares comparison and logical operators while preserving distinct TAG and FIELD null semantics.
- Represents negation explicitly and retains TAG equality direct lookup.
- Adds regression tests and documents predicate behavior.
| File | Description |
|---|---|
| skills/tsfile/references/properties-filters.md | Documents shared predicates and null semantics. |
| cpp/test/reader/filter/tag_filter_test.cc | Tests tree shapes, null handling, and rejected-operand ownership. |
| cpp/test/reader/filter/aligned_field_filter_test.cc | Tests nested negation after binding. |
| cpp/src/reader/filter/tag_filter.h | Derives TAG filters from the shared tree. |
| cpp/src/reader/filter/tag_filter.cc | Centralizes TAG evaluation and validates combinator operands. |
| cpp/src/reader/filter/table_predicate.h | Introduces shared operators and tree ownership. |
| cpp/src/reader/filter/aligned_field_filter.h | Adopts the shared tree for FIELD filters. |
| cpp/src/reader/filter/aligned_field_filter.cc | Unifies evaluation traversal and handles explicit negation. |
| cpp/src/reader/device_meta_iterator.cc | Recognizes shared-tree TAG equality for direct lookup. |
Review effort: Balanced
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * License); you may not use this file except in compliance |
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
C++ callers can now define a condition before they know the table schema or the tree series layout. Both query models accept the same
storage::Expression. This PR contains the native reader work split out of #1169.Query behavior
tag_filterandfield_filteras separate expression pointers after the result parameter. Either can be null. Time bounds restrict the scan, and offset and limit count matching rows. TAG references bind to device-ID segments and retain exact-device lookup and regular-expression support. FIELD references bind to column types and use the existing page pruning and batch evaluation paths.TagFilterBuilderand the predicate factories onAlignedFieldFilter. C++ callers construct TAG and FIELD conditions withExpression::compare,Expression::between, null tests and logical operators. For standalone device-segment evaluation, bind the expression withTagFilter::bind. The CLI and the C wrapper construct named expressions directly. The C signatures are unchanged. For AND, OR and NOT, success transfers operand ownership to the parent. A null operand or aliased binary operands return a null handle and leave ownership with the caller. Allocation failure during composition terminates the calling process.NOT(a = x)on missing data. A missing TAG matches. A null FIELD or tree value is excluded. Existing indexed TAG subclasses and path/time query APIs remain available.Verification
libtsfile. All 15 Python ASan/LSan ownership scenarios passed.