Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1186 +/- ##
===========================================
+ Coverage 69.48% 69.51% +0.03%
===========================================
Files 798 798
Lines 59120 58721 -399
Branches 9639 9562 -77
===========================================
- Hits 41077 40822 -255
+ Misses 16254 16116 -138
+ Partials 1789 1783 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Querying a missing table with a different batch size deletes the executor still borrowed by live results, so advancing or closing them can access freed memory. Separately, retaining ABI epoch 1 despite public symbol, layout, and virtual-table changes allows existing binaries to load an incompatible library; filtered queries also return E_NOT_SUPPORT for previously accepted Java-written tables with TEXT TAG columns.
3 open issues
What changed in this PR
Adds schema-bound, named TAG and FIELD expressions to Apache TsFile’s C++ table-query API.
Changes:
- Introduces borrowed expressions with query-owned filter bindings.
- Unifies FIELD evaluation and statistics pruning, and corrects multi-TAG lookup.
- Updates CLI integration, examples, documentation, and regression tests.
| File | Description |
|---|---|
skills/tsfile/references/properties-filters.md |
Documents expressions, ownership, and migration. |
skills/tsfile/references/advanced-apis.md |
Updates table-query parameter guidance. |
cpp/tools/commands/row_query.cc |
Uses named TAG expressions. |
cpp/tools/commands/commands.h |
Removes the exposed TAG-building helper. |
cpp/test/tools/model_format_e2e_test.cc |
Tests full-value regex alternatives. |
cpp/test/reader/table_view/tsfile_reader_table_test.cc |
Migrates queries and tests multi-TAG lookup. |
cpp/test/reader/table_read_failure_test.cc |
Updates expression and C-wrapper queries. |
cpp/test/reader/filter/tag_filter_test.cc |
Tests TAG binding and null semantics. |
cpp/test/reader/filter/field_filter_test.cc |
Tests shared FIELD evaluation and classification. |
cpp/test/reader/field_filter_regression_test.cc |
Migrates regressions and adds range coverage. |
cpp/test/reader/chunk_reader_resource_test.cc |
Updates filter-binding and reader setup. |
cpp/test/reader/block/masked_bulk_copy_test.cc |
Uses bound FIELD filters. |
cpp/test/reader/aligned_wide_table_small_block_test.cc |
Updates executor calls. |
cpp/test/reader/aligned_chunk_reader_bulk_test.cc |
Tests chunk pruning and FIELD-match reuse. |
cpp/test/cwrapper/cwrapper_extended_test.cc |
Tests composition guards and handle lifetime. |
cpp/src/reader/tsfile_series_scan_iterator.h |
Adds shared-filter chunk classification. |
cpp/src/reader/tsfile_series_scan_iterator.cc |
Classifies chunks before reading headers. |
cpp/src/reader/tsfile_reader.h |
Exposes named-expression table-query parameters. |
cpp/src/reader/tsfile_reader.cc |
Binds expressions during query preparation. |
cpp/src/reader/tsfile_executor.cc |
Transfers ownership of prepared TIME filters. |
cpp/src/reader/task/device_task_iterator.h |
Owns the bound TAG filter. |
cpp/src/reader/table_query_executor.h |
Defines the expression-based executor interface. |
cpp/src/reader/table_query_executor.cc |
Binds and transfers query filters. |
cpp/src/reader/meta_data_querier.h |
Uses typed TAG-filter parameters. |
cpp/src/reader/meta_data_querier.cc |
Updates device-iterator construction. |
cpp/src/reader/imeta_data_querier.h |
Updates the TAG-filter interface contract. |
cpp/src/reader/filter/tag_filter.h |
Replaces positional filters with bound filters. |
cpp/src/reader/filter/tag_filter.cc |
Implements named TAG binding and matching. |
cpp/src/reader/filter/table_field_filter.h |
Removes the row-callback API. |
cpp/src/reader/filter/table_field_filter.cc |
Removes legacy callback evaluation. |
cpp/src/reader/filter/filter.h |
Removes the TAG-row virtual callback. |
cpp/src/reader/filter/field_filter.h |
Defines the shared FIELD-filter interface. |
cpp/src/reader/filter/field_filter.cc |
Implements typed evaluation and statistics classification. |
cpp/src/reader/filter/bind_expression.h |
Adds shared expression-tree binding. |
cpp/src/reader/filter/bind_expression.cc |
Resolves FIELD names and literal types. |
cpp/src/reader/filter/aligned_field_filter.h |
Removes the aligned-only filter API. |
cpp/src/reader/expression.h |
Adds named operands and expression factories. |
cpp/src/reader/expression.cc |
Implements factories and referenced-column collection. |
cpp/src/reader/device_meta_iterator.h |
Uses schema-derived exact-device lookup. |
cpp/src/reader/device_meta_iterator.cc |
Matches bound TAG filters during iteration. |
cpp/src/reader/column_mapping.h |
Registers bound filter-referenced columns. |
cpp/src/reader/block/single_device_tsblock_reader.h |
Borrows the shared FIELD filter. |
cpp/src/reader/block/single_device_tsblock_reader.cc |
Unifies aligned and merged-row filtering. |
cpp/src/reader/block/prepared_series_tsblock_reader.h |
Owns TIME filters with smart pointers. |
cpp/src/reader/block/prepared_series_tsblock_reader.cc |
Updates TIME-filter transfer and cleanup. |
cpp/src/reader/block/device_ordered_tsblock_reader.h |
Owns query TIME and FIELD filters. |
cpp/src/reader/block/device_ordered_tsblock_reader.cc |
Lends filters to per-device readers. |
cpp/src/reader/aligned_chunk_reader.h |
Tracks pages requiring FIELD evaluation. |
cpp/src/reader/aligned_chunk_reader.cc |
Reuses statistics-proven FIELD matches. |
cpp/src/file/tsfile_io_reader.h |
Accepts borrowed shared FIELD filters. |
cpp/src/file/tsfile_io_reader.cc |
Updates multi-series filter parameters. |
cpp/src/cwrapper/tsfile_cwrapper.cc |
Implements existing handles with expressions. |
cpp/src/common/db_common.h |
Adds string-type classification. |
cpp/examples/cpp_examples/demo_read.cpp |
Demonstrates expressions and result cleanup. |
Review effort: Max
| const Expression* field_filter, int batch_size) { | ||
| result_set = nullptr; | ||
| if (!tsfile_executor_ || offset < 0) return E_INVALID_ARG; | ||
| ensure_table_query_executor(batch_size); |
| const Expression* tag_filter, | ||
| const Expression* field_filter = nullptr, int batch_size = 0); |
| if (schema.get_column_schema(operand.reference).data_type_ != | ||
| common::STRING) | ||
| return common::E_NOT_SUPPORT; |


Changes
C++ table queries accept a borrowed
const Expression*for each oftag_filterandfield_filter. Applications can construct the expression by column name before opening the file. Query preparation binds its own copy against the table schema, so the result can outlive the input. The C wrapper keeps its handle and ownership contract.TAG conditions bind to STRING device-ID segments. Aligned and non-aligned table reads share one
FieldFilter. It binds literals to the declared FIELD types and classifies both pages and chunks using the same statistics rules. An aligned page reuses a full FIELD match from chunk or page statistics even when its time predicate selects only some timestamps. The device iterator owns the TAG filter. The result's block reader owns the TIME and FIELD filters and lends them to each per-device reader. The tree query entry points and execution paths are unchanged. The table API no longer exposes positional TAG constructors or the row-filter callback.Multi-TAG regression
In a table with TAGs
siteandline, a device with a missing trailinglinecan be the first index entry. Inferring the TAG count from that entry madesite = 'A'omit a device with(site='A', line='B'). A direct device lookup now requires a single TAG in the table schema. The regression checks the exact row values, rejects an ambiguous prepared series and prepares a series when both TAGs select one device.Upgrading C++ applications
Replace indexed TAG constructors and FIELD filter builders with named expressions. For a TAG-only query with an explicit batch size, pass
tag_filter.get(), nullptr, batch_sizeafter the result-set argument. Recompile and relink applications using the headers and library from the same SDK. The package version, ABI epoch (1), and platform library names stay at their existing values.Verification
libtsfile.so.1)libtsfile.1.dylib) and MinGW import library target (libtsfile.dll)