Repository navigation
Conversation
- restorable writer: propagate allocation failures during the recovery scan instead of returning E_OK - io writer: check the bloom filter add_path_entry result before serializing the index - dataset index: reject missing sections before dereferencing their records - local random-access file: reject a closed descriptor before fstat() - result_set: inherit enable_shared_from_this publicly; qualify virtual calls made from constructors/destructors - ts2diff decoder: return a defined value on corrupt input; qds: drop dead assignments - pass read-only shared_ptr/vector/string parameters by const reference, and move parameters that are stored into members - reserve vectors before loop appends; replace std::endl with '\n' in logs - use uint8_t for the chimp leading-zero tables; cast unsigned char values before streaming - add cpp/.clang-tidy (clang-analyzer, bugprone, performance checks)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1171 +/- ##
===========================================
- Coverage 69.27% 69.26% -0.01%
===========================================
Files 791 791
Lines 58564 58578 +14
Branches 9516 9517 +1
===========================================
+ Hits 40570 40574 +4
- Misses 16247 16255 +8
- Partials 1747 1749 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The changes break existing SDK symbols and virtual contracts, while failure paths can abort finalization or leak recovery resources.
4 open issues
What changed in this PR
Adds static-analysis configuration and addresses clang-tidy findings across TsFile’s C++ implementation, with corresponding CLI updates.
Changes:
- Configures analyzer, bug-prone-code, and performance checks with targeted suppressions.
- Improves recovery error handling, index-writing checks, lookup guards, and decoder fallback values.
- Reduces unnecessary copies and allocations, and makes destructor cleanup calls explicit.
| File | Description |
|---|---|
cpp/tools/commands/row_query.cc |
Updates the CLI tag-filter override signature. |
cpp/src/writer/tsfile_writer.h |
Uses const references in schema-check declarations. |
cpp/src/writer/tsfile_writer.cc |
Updates schema checks and annotates ownership transfers. |
cpp/src/writer/tsfile_tree_writer.h |
Changes batch-registration parameters to const reference. |
cpp/src/writer/tsfile_tree_writer.cc |
Updates the batch-registration definition. |
cpp/src/reader/tsfile_tree_reader.cc |
Reserves device-ID output capacity and avoids copies. |
cpp/src/reader/tsfile_series_scan_iterator.h |
Moves the device ID into iterator state. |
cpp/src/reader/tsfile_series_scan_iterator.cc |
Documents and suppresses a defensive flag reset. |
cpp/src/reader/tsfile_reader.h |
Updates reader parameter declarations. |
cpp/src/reader/tsfile_reader.cc |
Reduces parameter copies and reserves metadata capacity. |
cpp/src/reader/task/device_task_iterator.h |
Moves task-iterator constructor arguments. |
cpp/src/reader/task/device_query_task.h |
Moves arguments into task members. |
cpp/src/reader/task/device_query_task.cc |
Moves arguments when constructing query tasks. |
cpp/src/reader/table_result_set.h |
Moves column metadata into result-set members. |
cpp/src/reader/table_result_set.cc |
Qualifies destructor cleanup. |
cpp/src/reader/table_query_executor.cc |
Reserves tag-column schema capacity. |
cpp/src/reader/result_set.h |
Makes shared-ownership inheritance public and adjusts logging. |
cpp/src/reader/qds_without_timegenerator.cc |
Removes dead assignments from skip branches. |
cpp/src/reader/filter/tag_filter.h |
Changes tag-filter virtual parameters to const references. |
cpp/src/reader/filter/tag_filter.cc |
Updates tag-filter method definitions. |
cpp/src/reader/filter/filter.h |
Updates the base row-filter virtual signature. |
cpp/src/reader/filter/filter_type.h |
Avoids flushing diagnostic output on each newline. |
cpp/src/reader/filter/aligned_field_filter.h |
Uses const-reference column-name parameters. |
cpp/src/reader/filter/aligned_field_filter.cc |
Updates aligned-filter factory definitions. |
cpp/src/reader/expression.cc |
Replaces flushing newlines in diagnostics. |
cpp/src/reader/chunk_reader.cc |
Annotates intentional error assignments before assertions. |
cpp/src/reader/block/single_device_tsblock_reader.h |
Qualifies destructor cleanup. |
cpp/src/reader/block/device_ordered_tsblock_reader.cc |
Adds a null-reader guard in next(). |
cpp/src/reader/aligned_chunk_reader.cc |
Annotates intentional error assignments before assertions. |
cpp/src/file/write_file.h |
Qualifies the destructor’s close call. |
cpp/src/file/tsfile_io_writer.h |
Updates shared-pointer parameter declarations. |
cpp/src/file/tsfile_io_writer.cc |
Checks bloom-filter insertion errors and reduces copies. |
cpp/src/file/tsfile_io_reader.h |
Changes reader shared-pointer parameters to const references. |
cpp/src/file/tsfile_io_reader.cc |
Updates definitions and corrects argument-name comments. |
cpp/src/file/restorable_tsfile_io_writer.cc |
Returns allocation failures before recovery finalization. |
cpp/src/file/local_random_access_read_file.h |
Qualifies destruction and close calls. |
cpp/src/file/local_random_access_read_file.cc |
Rejects closed descriptors before generation probing. |
cpp/src/encoding/zigzag_encoder.h |
Removes unused trailing shifts. |
cpp/src/encoding/ts2diff_encoder.h |
Qualifies destructor cleanup. |
cpp/src/encoding/ts2diff_decoder.h |
Initializes scalar fallback return values. |
cpp/src/encoding/plain_encoder.h |
Qualifies destructor cleanup. |
cpp/src/encoding/dictionary_encoder.h |
Accepts string input by const reference. |
cpp/src/encoding/chimp_encoder.h |
Uses unsigned leading-zero table values. |
cpp/src/encoding/chimp_decoder.h |
Uses unsigned decoding table values. |
cpp/src/encoding/alp/alp_traits.h |
Documents and suppresses intentional bitwise comparisons. |
cpp/src/dataset/dataset_index.cc |
Guards unavailable sections before lookups. |
cpp/src/cwrapper/tsfile_cwrapper.cc |
Reserves column capacity and annotates bounded array access. |
cpp/src/compress/zstd_compressor.h |
Qualifies destructor cleanup. |
cpp/src/compress/lz4_compressor.h |
Qualifies destructor cleanup. |
cpp/src/common/tsfile_common.h |
Reduces copies and prints byte-valued fields numerically. |
cpp/src/common/tsfile_common.cc |
Updates lookup signatures and annotates an error assignment. |
cpp/src/common/tablet.h |
Moves schema ownership and checks the stored member. |
cpp/src/common/tablet.cc |
Documents and suppresses a required by-value specialization. |
cpp/src/common/schema.h |
Reserves data-type vector capacity. |
cpp/src/common/row_record.h |
Replaces flushing newlines in diagnostics. |
cpp/src/common/device_id.cc |
Casts the segment constant before addition. |
cpp/src/common/allocator/page_arena.h |
Computes aligned addresses using pointer advancement. |
cpp/src/common/allocator/mem_alloc.cc |
Avoids repeated flushing in memory statistics. |
cpp/src/common/allocator/byte_stream.h |
Replaces a flushing diagnostic newline. |
cpp/.clang-tidy |
Defines static-analysis checks, exclusions, and header filtering. |
Review effort: Balanced
Comment on lines
+474
to
+475
| if (RET_FAIL( | ||
| filter.add_path_entry(tmp_device_name, measurement_name))) { |
| } | ||
| virtual bool satisfyRow(int time, | ||
| std::vector<std::string*> segments) const { | ||
| const std::vector<std::string*>& segments) const { |
| * @return Returns 0 on success, or a non-zero error code on failure. | ||
| */ | ||
| int get_timeseries_schema(std::shared_ptr<IDeviceID> device_id, | ||
| int get_timeseries_schema(const std::shared_ptr<IDeviceID>& device_id, |
Comment on lines
+831
to
+834
| if (ret == common::E_OOM) { | ||
| reader.close(); | ||
| return ret; | ||
| } |
- keep by-value parameters on exported entry points and virtual overrides so the installed headers and shared-library ABI stay unchanged; internal helpers still take const references - tsfile_io_writer: remove the success-only assertion so a failed bloom-filter insert propagates instead of aborting debug builds - restorable writer: release the pending chunk group's device reference before returning on OOM
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.


Summary
Adds a
clang-tidyconfiguration for the C++ implementation and fixes thefindings it reports on
cpp/src(61 translation units;third_partyand theANTLR-generated parser are excluded from the reported scope).
Real defects
restorable_tsfile_io_writer: an allocation failure during the recoveryscan was swallowed and the function returned
E_OK;E_OOMis nowpropagated to the caller (releasing the pending chunk group's device
reference first).
tsfile_io_writer: the result of the bloom-filteradd_path_entrycall wasoverwritten by the following
RET_FAIL(...), so a failed insert wasignored. The call is now checked, and the success-only assertion at the end
of the index loop is gone so the failure propagates instead of aborting
debug builds.
dataset_index: the name/series lookups used a section view without checkingthat the section was present, so a malformed index could be dereferenced
through a null pointer; they now return
NOT_FOUND.local_random_access_read_file: the file generation probe could callfstaton a closed descriptor; it now rejectsfd_ < 0first.Correctness / design cleanups
ResultSetnow inheritsenable_shared_from_thispublicly.not depend on virtual dispatch (
PlainEncoder,TS2DIFFEncoder/Decoder,SingleDeviceTsBlockReader,TableResultSet,LZ4Compressor,ZstdCompressor,LocalRandomAccessReadFile,WriteFile).TS2DIFFDecoder: error paths return a defined value instead of anindeterminate one;
QDSWithoutTimeGenerator: removed dead assignments inthe skip branches.
DeviceOrderedTsBlockReader::nextguards against a null current reader.Performance / bugprone
shared_ptr/vector/stringparametersby const reference (or move them into members where they are stored);
release()results that are intentionally discarded are cast tovoid.reserved before loop appends;std::endlis replaced with'\n'in logging.uint8_t;unsigned charvalues are castbefore streaming to
ostreamin debug output; argument comments intsfile_io_readerwere corrected.ABI / interface compatibility
Only internal and private helpers take parameters by const reference. The
public entry-point classes (
TsFileReader,TsFileTreeWriter) and thevirtual filter interface keep their original by-value parameters, so the
installed headers and the shared-library ABI (SONAME epoch 1) are unchanged.
Intentional patterns
ret = E_XXX; ASSERT(false);error paths, the cwrapper's boundedtimeseries[slot]access, and ALP's bitwise float/double equality areannotated with targeted
NOLINTcomments instead of being rewritten.Testing
libtsfileandTsFile_Testbuild in WSL (Ubuntu 26.04, GCC 15.2,CMake 3.31) against a checkout of
developplus this change.are CLI tests that create a FIFO with
mkfifo(), which the NTFS-backed/mnt/dworkspace does not support (mkfiforeturns -1); they areenvironment-only and unrelated to this change.
cpp/src; remaining warnings are confinedto the generated
PathParser.cpp.