skorotkov commented on code in PR #12026: URL: https://github.com/apache/ignite/pull/12026#discussion_r2113393419
########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java: ########## @@ -655,24 +678,62 @@ private long allocateDataPage(int part) throws IgniteCheckedException { } } + /** + * Grid cursor for rows to be written. + * <p> + * If current row is fragmented allows to maintain ID of page containg tail fragment. + */ + private static class WriteRowsGridCursor<T> extends GridCursorIteratorWrapper<T> { + /** Tail page id. */ + private long tailPageId = -1; + + /** + * @param iter Iterator. + */ + public WriteRowsGridCursor(Iterator<T> iter) { + super(iter); + } + + /** {@inheritDoc} */ + @Override public boolean next() throws IgniteCheckedException { + tailPageId(-1); + + return super.next(); + } + + /** Get tail page id. */ + public void tailPageId(long tailPageId) { + this.tailPageId = tailPageId; + } + + /** Set tail page id. */ + public long tailPageId() { + return tailPageId; + } + } + /** * Write fragments of the row, which occupy the whole memory page. A data row is ignored if it is less than the max * payload of an empty data page. * * @param row Row to process. * @param statHolder Statistics holder to track IO operations. + * @param cur Rows cursor. * @return Number of bytes written, {@link #COMPLETE} if the row was fully written, {@code 0} if data row was * ignored because it is less than the max payload of an empty data page. * @throws IgniteCheckedException If failed. */ - private int writeWholePages(T row, IoStatisticsHolder statHolder) throws IgniteCheckedException { + private int writeWholePages(T row, IoStatisticsHolder statHolder, WriteRowsGridCursor<T> cur) throws IgniteCheckedException { assert row.link() == 0 : row.link(); int written = 0; int rowSize = row.size(); while (rowSize - written >= MIN_SIZE_FOR_DATA_PAGE) { - written = writeSinglePage(row, written, statHolder); + written = writeSinglePage(row, written, statHolder, cur.tailPageId()); + + if (written != COMPLETE && cur.tailPageId() == -1) + cur.tailPageId(PageIdUtils.pageId(row.link())); Review Comment: tailId is reset to -1 once cursor is moved to next row in next() call. So tailId is always relevant to the *current* row. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org