Repository navigation
Conversation
| TSDataType dataType, | ||
| EncryptParameter encryptParam, | ||
| int valueOutInitialCapacity) { | ||
| this(valueEncoder, compressor, dataType, encryptParam, new PublicBAOS(valueOutInitialCapacity)); |
There was a problem hiding this comment.
Creating PublicBAOS with this capacity sizes the encoded-value buffer before its first encoder write, allowing flush estimates to avoid repeated growth in this stream. The encryption-aware overload reaches the same allocation point while using its supplied EncryptParameter.
| schemaList.get(i).getValueEncoder(), | ||
| this.encryptParam)); | ||
| this.encryptParam, | ||
| valueOutInitialCapacity)); |
There was a problem hiding this comment.
Each aligned measurement has its own ValueChunkWriter and encoded-value buffer. Forwarding the capacity here applies the estimate to every aligned value column, not only standalone value-page construction.
| PageBodyEncoder.encode( | ||
| pageData, uncompressedSize, compressor, encryptParam, pageIndex, chunkOrdinal); | ||
| int pageBodySize = pageBody.remaining(); | ||
| lastPageDataSize = pageBodySize; |
There was a problem hiding this comment.
PageBodyEncoder has already produced the bytes appended after the page header. Recording this length excludes page-header varints and statistics from non-aligned page-data accounting.
| PageBodyEncoder.encode( | ||
| pageData, uncompressedSize, compressor, encryptParam, pageIndex, chunkOrdinal); | ||
| int pageBodySize = pageBody.remaining(); | ||
| lastPageDataSize = pageBodySize; |
There was a problem hiding this comment.
Aligned time pages also contribute compressed page-body bytes to the flush ratio. Capturing the encoded body length here keeps their page headers out of the count.
| TSDataType dataType, | ||
| EncryptParameter encryptParam, | ||
| int valueOutInitialCapacity) { | ||
| this(valueEncoder, compressor, dataType, encryptParam, new PublicBAOS(valueOutInitialCapacity)); |
There was a problem hiding this comment.
Routing constructor variants through the shared initializer keeps statistics, compressor, and chunk-ordinal setup consistent. The capacity-aware overload supplies a pre-sized PublicBAOS through that same initialization path.
| PageBodyEncoder.encode( | ||
| pageData, uncompressedSize, compressor, encryptParam, pageIndex, chunkOrdinal); | ||
| int pageBodySize = pageBody.remaining(); | ||
| lastPageDataSize = pageBodySize; |
There was a problem hiding this comment.
This records the compressed or encrypted page body after PageBodyEncoder. The page header and statistics are serialized separately, so this length is the data-only portion used by flush accounting.
| } else { | ||
| pageWriter.writePageHeaderAndDataIntoBuff(pageBuffer, false, numOfPages); | ||
| } | ||
| pageDataSize += pageWriter.getLastPageDataSize(); |
There was a problem hiding this comment.
A chunk buffer can contain multiple pages. Accumulating each encoded body here gives the explicit writer overload the exact body-byte total when the packed chunk is flushed.
| } else { | ||
| pageWriter.writePageHeaderAndDataIntoBuff(pageBuffer, false, numOfPages); | ||
| } | ||
| pageDataSize += pageWriter.getLastPageDataSize(); |
There was a problem hiding this comment.
This parallel accumulator covers the time-column pages of aligned flushes. It keeps time body bytes in the ratio while their page headers remain excluded.
| } else { | ||
| pageWriter.writePageHeaderAndDataIntoBuff(pageBuffer, false, numOfPages); | ||
| } | ||
| pageDataSize += pageWriter.getLastPageDataSize(); |
There was a problem hiding this comment.
This accumulator covers value-column pages and is reset with the chunk buffer after emission. Together with the time-column counter it represents aligned flush page bodies.
| * and page statistics | ||
| * @throws IOException if an I/O error occurs. | ||
| */ | ||
| public void writeBytesToStream(PublicBAOS bytes, long pageDataBytes) throws IOException { |
There was a problem hiding this comment.
Flush chunk writers already know the page-body total while encoding, so supplying it here avoids reparsing the packed buffer on the write path and keeps page framing out of the exact count.
| * writeBytesToStream} overload counts the complete packed buffer, including page headers and page | ||
| * statistics, so its contribution is approximate. | ||
| */ | ||
| public long getWrittenPageDataSize() { |
There was a problem hiding this comment.
This counter is scoped to pages produced by flush chunk writers. Raw chunks copied with writeChunk have no paired MemTable-size contribution, and the legacy one-argument overload can include page framing, so callers can interpret the ratio correctly.
|
|
||
| public void reset() throws IOException { | ||
| out.truncate(markedPosition); | ||
| writtenPageDataSize = markedPageDataSize; |
There was a problem hiding this comment.
A failed flush retry truncates the output back to the saved position. Restoring the matching counter checkpoint prevents discarded page bodies from being counted again after the retry.
| // A configured value-buffer capacity must reach the aligned column encoder before its first | ||
| // write. | ||
| @Test | ||
| public void testValuePageBufferInitialCapacity() { |
There was a problem hiding this comment.
This test inspects the value encoder buffer before its first write, verifying that AlignedChunkWriterImpl forwards the configured capacity through its per-measurement writer construction.
|
|
||
| // The requested initial value-buffer capacity is used while encoding and the page stays readable. | ||
| @Test | ||
| public void testValueOutInitialCapacity() throws IOException { |
There was a problem hiding this comment.
The encoder assertion checks the requested allocation, while decoding the resulting page verifies that preallocation preserves the existing serialized value layout.
|
|
||
| // An explicit page-data byte count excludes page framing and chunk-group headers. | ||
| @Test | ||
| public void testWriterCountsSerializedPageDataBytes() throws IOException { |
There was a problem hiding this comment.
These assertions validate the explicit flush count and confirm that the first page-header fields are excluded from the normal page-body total.
|
|
||
| // A chunk copied through writeChunk is excluded from the flush page-data counter. | ||
| @Test | ||
| public void testWriterDoesNotCountCopiedChunks() throws IOException { |
There was a problem hiding this comment.
Copied chunks are outside the flush ratio because this path has no corresponding MemTable byte count. This test makes that accounting boundary explicit.
|
|
||
| // Resetting after a failed write truncates its bytes and removes them from the page-data count. | ||
| @Test | ||
| public void testWriterResetRestoresPageDataCount() throws IOException { |
There was a problem hiding this comment.
A retry truncates bytes after mark. This test verifies the page-data counter is rolled back with the file position, avoiding double counting.
| this.pageWriter = | ||
| new ValuePageWriter( | ||
| valueEncoder, ICompressor.getCompressor(compressionType), dataType, this.encryptParam); | ||
| valueOutInitialCapacity > 0 |
There was a problem hiding this comment.
A positive flush estimate is supplied to the capacity-aware ValuePageWriter constructor. Zero selects the default allocation path when no historical estimate is available.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #1189 +/- ##
===========================================
+ Coverage 69.48% 69.53% +0.04%
===========================================
Files 798 798
Lines 59138 59155 +17
Branches 9642 9646 +4
===========================================
+ Hits 41092 41131 +39
+ Misses 16256 16235 -21
+ Partials 1790 1789 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Accounting scope
The counter is intended for flush-encoded pages. Chunks copied through writeChunk are not included. The one-argument writeBytesToStream(PublicBAOS) overload counts the entire packed page buffer, including headers and statistics, so its contribution may overstate page-body bytes. Flush chunk writers use the overload that receives the explicit page-body byte count.
For example, if a packed page buffer contains 3,000 compressed page-body bytes and 20 bytes of page headers and statistics, passing 3,000 records only the page body. The one-argument overload records all 3,020 bytes. A ValuePageWriter constructed with an initial capacity of 4,096 starts its encoded-value buffer at that size.
Validation