Repository navigation
feat: allow non-decreasing (duplicate) timestamps behind an opt-in flag - #1085
Conversation
…ag (#1056) Add an opt-in `allowNonDecreasingTimestamps` flag (default off) across all three implementations so a writer can accept a timestamp equal to the last written one while still rejecting strictly decreasing timestamps. Java: `TSFileConfig` flag threaded through the aligned/non-aligned chunk group writers and the tablet write context. C++: `ConfigValue` field plus a C API setter, applied in TimePageWriter's single and batch paths and the recovered-last-time ordering checks. Python: `allow_non_decreasing_timestamps` keyword argument on the writer constructors. Duplicate timestamps are preserved as separate rows (no write-time dedup). Tests cover flag on/off in Java, C++, and Python, plus a cross-language round-trip (Java writes duplicates, C++ reads them back).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1085 +/- ##
===========================================
+ Coverage 66.49% 66.51% +0.02%
===========================================
Files 778 778
Lines 56559 56577 +18
Branches 9098 9105 +7
===========================================
+ Hits 37607 37632 +25
+ Misses 17301 17291 -10
- Partials 1651 1654 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… tests The rejected write leaves the C++ writer unrecoverable, so its file handle stays open on Windows; deleting a fixed-named file then fails with WinError 32 and leaks into the next test. Write to a unique temp dir and clean up best-effort.
…mitting a binary
Replace the committed Java-written binary fixture with a self-contained
non-aligned write+read round-trip test in TsFileWriterTest, and remove the
now-unused standalone reader test and binary fixture.
The new test writes {0, 1, 1, 2} through the non-aligned row path with
allow_non_decreasing_timestamps enabled and asserts the duplicate
timestamps are read back as separate rows.
Add an optional trailing timestampProfile column to the compatibility matrix. The duplicates profile writes timestamps as row/2 (each value appears twice) with allow_non_decreasing_timestamps enabled. Two new INT32/PLAIN cases (table + tree) let each side write the fixture and validate the other side's file returns the duplicates as separate rows.
jt2594838
left a comment
There was a problem hiding this comment.
May register this config into TsFile properties so that the down-stream applications (like IoTDB load) may know how to handle the file correctly.
When the writer runs with allowNonDecreasingTimestamps, register the file-level property "allowNonDecreasingTimestamps" = "true" so downstream applications (e.g. an IoTDB load) can tell the file may contain duplicate timestamps and must not assume strictly increasing times within a series. The property is added at writer initialization in both Java (TsFileIOWriter, including the append path in RestorableTsFileIOWriter) and C++ (TsFileIOWriter init, which both the tree and table writers use). Flag-off writes add nothing, so existing files are unchanged.
|
Thanks for the review. The flag is now recorded in the file metadata: when |
CTest runs cases of one binary in parallel (--parallel 4). All cases in this fixture shared one fixed file name, so the new policy-property cases truncated or removed the file while WriterPreservesBinaryNullAndEmptyValues was still using it, failing that test on Linux and Windows CI. Derive the file name from the current test name instead.
Closes #1056.
Summary
Adds an opt-in
allowNonDecreasingTimestampsflag (default off) across Java, C++, and Python. When enabled, a writer accepts a timestamp equal to the previously written timestamp and only rejects strictly decreasing timestamps. When disabled, behavior and error messages are unchanged.TSFileConfig.allowNonDecreasingTimestamps, threaded throughAlignedChunkGroupWriterImpl,NonAlignedChunkGroupWriterImpl, andTabletWriteContext.ConfigValue::allow_non_decreasing_timestamps_plus a C API setterset_allow_non_decreasing_timestamps(bool), applied inTimePageWriter::write/write_batchandTsFileWriter's recovered-last-time ordering checks.allow_non_decreasing_timestamps=keyword argument onTsFileWriterandTsFileTableWriter.Duplicate semantics
timestamps[i] < timestamps[i-1]) are still rejected; strictly decreasing timestamps still fail in every path.File property
When the flag is enabled, the writer registers the file-level property
allowNonDecreasingTimestamps="true"in the TsFile metadata (JavaTsFileIOWriter, including theRestorableTsFileIOWriterappend path; C++TsFileIOWriter::init, used by both tree and table writers). Downstream applications such as an IoTDB load can read it and avoid assuming strictly increasing times within a series. Flag-off writes add nothing, so existing files keep their metadata unchanged.Tests
AllowNonDecreasingTimestampsTest(flag on/off, aligned + non-aligned, round-trip read, property present/absent).TsFileWriterTest.AllowNonDecreasing*(aligned and non-aligned write+read round-trips, plus strictly-decreasing rejection),EqualTimestampsRejectedAlignedWhenFlagOff, andTsFilePropertiesTest.RecordsAllowNonDecreasingTimestampsPolicy/OmitsPolicyPropertyWhenFlagOff.test_allow_non_decreasing_timestamps.py(duplicates round-trip, property present/absent, rejection cases).compatibility-matrix.csvaddstable_int32_plain_dupsandtree_int32_plain_dups(timestampProfile=duplicates); the compatibility workflow writes each with Java and C++ and validates the other side's fixture returns the duplicate timestamps as separate rows.