Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface MergeRowChangeProcessor
* <ul>
* <li>All data columns, in table column order</li>
* <li>{@link ConnectorMergeSink#storeMergedRows The operation block}</li>
* <li>{@link ConnectorMergeSink#storeMergedRows The merge case number block}</li>
* <li>The rowId block</li>
* <li>The last column in the resulting page is 1 if the row is an insert
* derived from an update, and zero otherwise.</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ public interface ConnectorMergeSink
/**
* Store the page resulting from a merge. The page consists of {@code n} channels, numbered {@code 0..n-1}:
* <ul>
* <li>Blocks {@code 0..n-3} in page are the data columns</li>
* <li>Block {@code n-2} is the tinyint <i>operation</i>:
* <li>Blocks {@code 0..n-4} in page are the data columns</li>
* <li>Block {@code n-3} is the tinyint <i>operation</i>:
* <ul>
* <li>{@link #INSERT_OPERATION_NUMBER}</li>
* <li>{@link #DELETE_OPERATION_NUMBER}</li>
* <li>{@link #UPDATE_OPERATION_NUMBER}</li>
* <li>{@link #UPDATE_INSERT_OPERATION_NUMBER}</li>
* <li>{@link #UPDATE_DELETE_OPERATION_NUMBER}</li>
* </ul>
* <li>Block {@code n-2} is the integer <i>merge case number</i>:
* <p>the number starting with 0, for the `WHEN` clause that matched for the row</p>
* <li>Block {@code n-1} is a connector-specific rowId column, whose handle was previously returned by
* {@link ConnectorMetadata#getMergeRowIdColumnHandle(ConnectorSession, ConnectorTableHandle) getMergeRowIdColumnHandle()}
* </li>
Expand Down
10 changes: 6 additions & 4 deletions docs/src/main/sphinx/develop/supporting-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,16 @@ The merge case `RowBlock` has the following layout:
- A block containing the `MERGE` case operation number, encoded as
`INSERT` = 1, `DELETE` = 2, `UPDATE` = 3 and if no `MERGE`
case matched, -1.
- A block containing the number, starting with 0, for the
- A block containing the `MERGE` case number, the number starting with 0, for the
`WHEN` clause that matched for the row, or -1 if no clause
matched.

The page returned from `transformPage` consists of:

- All table columns, in table column order.
- The merge case operation block.
- The rowId block.
- The tinyint type merge case operation block.
- The integer type merge case number block.
- The rowId block remains unchanged from the provided input page.
- A byte block containing 1 if the row is an insert derived from an
update operation, and 0 otherwise. This block is used to correctly
calculate the count of rows changed for connectors that represent
Expand Down Expand Up @@ -309,7 +310,8 @@ The only interesting methods are:
`ConnectorPageSinkProvider.createMergeSink()`, passing the page
generated by the `RowChangeProcessor.transformPage()` method.
That page consists of all table columns, in table column order,
followed by the `TINYINT` operation column, followed by the rowId column.
followed by the `TINYINT` operation column, followed by the `INTEGER`
merge case number column, followed by the rowId column.

The job of `storeMergedRows()` is iterate over the rows in the page,
and process them based on the value of the operation column, `INSERT`,
Expand Down
Loading