You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(cpp): cover the extended C wrapper API - #1130
The C wrapper is the surface the Python bindings call, but several of its entry points had zero C++ test coverage (41 of 168 functions in tsfile_cwrapper.cc at the time of writing).
cpp/test/cwrapper/cwrapper_extended_test.cc now covers:
global time encoding/compression setters and getters, plus set_allow_non_decreasing_timestamps
tablet_get_cur_row_size, typed adders by name/index (float, bool, int32)
tsfile_writer_flush
result-set getters by index (int32/int64/float/double/bool), is_null_by_index, binary cell copies, get_metadata plus the metadata accessors, and free_result_set_meta_data
tsfile_reader_query_table (offset/limit pages are compared against the full result by row identity), tsfile_query_table_batch, and tsfile_result_set_get_next_tsblock_as_arrow
an Arrow write through tsfile_writer_write_arrow, verified by reopening the file and checking row count, timestamps and every typed value
tag filter and/or/not composition and tsfile_query_table_with_tag_filter
the legacy device/record path (_tsfile_writer_register_device, typed record inserts, _tsfile_writer_write_ts_record, _tsfile_writer_flush) and tsfile_query_table_on_tree
generic-writer table write via _tsfile_writer_write_table
Measured with this build: tsfile_cwrapper.cc 71.8% lines (1507/2099) and 162/171 functions; arrow_c.cc 77.5% lines (527/680) and 27/28 functions. The remaining prepared-series functions require a dataset-index locator that the C API does not expose. _tsfile_writer_write_arrow_table is not asserted: the generic writer does not persist Arrow field values for this tablet layout, so the test does not encode that behavior.
./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON (1859 tests, 0 failed; macOS run used the Xcode 26.6 toolchain with ASAN_OPTIONS=detect_container_overflow=0 for the uninstrumented ANTLR runtime)
Exercise the C parts of the wrapper that the Python bindings use but the
C++ suite never reached: global time encoding/compression setters and
getters, tablet row-count/typed adders, writer flush, result-set value
getters and metadata accessors, binary cell copies, reader query
variants (offset/limit, inverted range, batch), Arrow block export and
Arrow table writes through both writers, tag filter and/or/not
composition, schema-array release helpers, and the legacy device/record
write path.
tsfile_cwrapper.cc: 62.5% -> 73.5% line coverage (163/168 functions);
arrow_c.cc: 69.9% -> 77.5% (27/28 functions). The remaining prepared-series
entry points need a dataset-index locator that is not exposed through the
C API.
This PR expands C++ test coverage for the C wrapper used by Python bindings, covering previously untested entry points without changing production code.
Changes:
Adds coverage for configuration, tablet helpers, typed result getters, metadata, and schema cleanup.
Exercises pagination, batch and Arrow queries, and composed tag filters.
Tests legacy record writes, generic table writes, and both Arrow writer APIs.
File
Description
cpp/test/cwrapper/cwrapper_extended_test.cc
Adds shared fixtures and eight tests covering extended C wrapper APIs.
Address review feedback:
- compare the offset/limit page against the full result by row identity so
a wrapper that ignores the offset cannot pass
- make count_result_rows fail when next() returns an error instead of
mistaking it for an empty result set
- read the Arrow-written table back and check the row count, timestamps and
typed values
The legacy _tsfile_writer_write_arrow_table path is no longer asserted: the
generic writer does not persist Arrow field values for this tablet layout,
so asserting its output would enshrine a defect in an unused internal API.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Tests lack assertions for the batch-size limit, negated-filter tag identity, and timestamp-policy state, allowing regressions in all three behaviors to pass.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Verify wrapper toggles update the native timestamp policy
These assertions only check return codes, so a wrapper that always returns RET_OK without changing the timestamp policy passes both calls. Please assert the native configuration after each toggle so this test verifies that the C wrapper actually enables and disables the option.
Test that each returned batch respects the requested size
The query requests a batch size of 3, but this loop only checks that batches are nonempty and total 10 rows. A regression that substitutes a larger positive batch size would still pass (for example, returning each device's five rows in one block). Please assert that every returned block contains at most 3 rows so this test verifies the batch-size argument as well as row preservation.
Verify the negated tag filter returns only devB rows
Both devA and devB have five rows, so this assertion passes even if tsfile_tag_filter_not simply returns its input without negating it: the query would return five devA rows instead of five devB rows. Please also check that every returned TAG is devB to distinguish the predicate from its complement.
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
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.
Summary
The C wrapper is the surface the Python bindings call, but several of its entry points had zero C++ test coverage (41 of 168 functions in
tsfile_cwrapper.ccat the time of writing).cpp/test/cwrapper/cwrapper_extended_test.ccnow covers:set_allow_non_decreasing_timestampstablet_get_cur_row_size, typed adders by name/index (float,bool,int32)tsfile_writer_flushint32/int64/float/double/bool),is_null_by_index, binary cell copies,get_metadataplus the metadata accessors, andfree_result_set_meta_datatsfile_reader_query_table(offset/limit pages are compared against the full result by row identity),tsfile_query_table_batch, andtsfile_result_set_get_next_tsblock_as_arrowtsfile_writer_write_arrow, verified by reopening the file and checking row count, timestamps and every typed valueand/or/notcomposition andtsfile_query_table_with_tag_filtertsfile_free_table_schema_array,tsfile_free_device_schema_array)_tsfile_writer_register_device, typed record inserts,_tsfile_writer_write_ts_record,_tsfile_writer_flush) andtsfile_query_table_on_tree_tsfile_writer_write_tableMeasured with this build:
tsfile_cwrapper.cc71.8% lines (1507/2099) and 162/171 functions;arrow_c.cc77.5% lines (527/680) and 27/28 functions. The remaining prepared-series functions require a dataset-index locator that the C API does not expose._tsfile_writer_write_arrow_tableis not asserted: the generic writer does not persist Arrow field values for this tablet layout, so the test does not encode that behavior.Test plan
./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON(Java, C++, Python; 1858 C++ tests passed)./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON(1859 tests, 0 failed; macOS run used the Xcode 26.6 toolchain withASAN_OPTIONS=detect_container_overflow=0for the uninstrumented ANTLR runtime)./mvnw spotless:check -P with-java,with-python