Skip to content

Commit

Permalink
Change ORC ACID row_id columns order
Browse files Browse the repository at this point in the history
To match order in ORC file.
  • Loading branch information
losipiuk committed Jun 8, 2021
1 parent 37e560b commit af40c87
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class HiveUpdatablePageSource
{
// The channel numbers of the child blocks in the RowBlock passed to deleteRows()
public static final int ORIGINAL_TRANSACTION_CHANNEL = 0;
public static final int ROW_ID_CHANNEL = 1;
public static final int BUCKET_CHANNEL = 2;
public static final int BUCKET_CHANNEL = 1;
public static final int ROW_ID_CHANNEL = 2;
// Used for UPDATE operations
public static final int ROW_CHANNEL = 3;
public static final int ACID_ROW_STRUCT_COLUMN_ID = 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public Block createUpdateRowBlock(Page page, List<Integer> nonUpdatedChannelNumb

Block[] blocks = new Block[acidBlocks + (nonUpdatedColumns.isEmpty() ? 0 : 1)];
blocks[ORIGINAL_TRANSACTION_CHANNEL] = page.getBlock(ORIGINAL_TRANSACTION_CHANNEL);
blocks[ROW_ID_CHANNEL] = page.getBlock(ROW_ID_CHANNEL);
blocks[BUCKET_CHANNEL] = page.getBlock(BUCKET_CHANNEL);
blocks[ROW_ID_CHANNEL] = page.getBlock(ROW_ID_CHANNEL);

if (!nonUpdatedColumns.isEmpty()) {
Block[] nonUpdatedColumnBlocks = new Block[getNonUpdatedColumns().size()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public final class AcidSchema
ACID_COLUMN_ROW_STRUCT);
public static final List<Field> ACID_READ_FIELDS = ImmutableList.of(
field(ACID_COLUMN_ORIGINAL_TRANSACTION, BIGINT),
field(ACID_COLUMN_ROW_ID, BIGINT),
field(ACID_COLUMN_BUCKET, INTEGER));
field(ACID_COLUMN_BUCKET, INTEGER),
field(ACID_COLUMN_ROW_ID, BIGINT));

public static final RowType ACID_ROW_ID_ROW_TYPE = RowType.from(ACID_READ_FIELDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ public Block block(Page sourcePage, MaskDeletedRowsFunction maskDeletedRowsFunct
Optional.empty(),
new Block[] {
sourcePage.getBlock(ORIGINAL_TRANSACTION_CHANNEL),
sourcePage.getBlock(ROW_ID_CHANNEL),
sourcePage.getBlock(BUCKET_CHANNEL),
sourcePage.getBlock(ROW_ID_CHANNEL),
}));
return rowBlock;
}
Expand Down Expand Up @@ -394,8 +394,8 @@ public Block block(Page sourcePage, MaskDeletedRowsFunction maskDeletedRowsFunct
ImmutableList.Builder<Block> originalFilesBlockBuilder = ImmutableList.builder();
originalFilesBlockBuilder.add(
new RunLengthEncodedBlock(ORIGINAL_FILE_TRANSACTION_ID_BLOCK, positionCount),
createOriginalFilesRowIdBlock(startingRowId, filePosition, positionCount),
new RunLengthEncodedBlock(bucketBlock, positionCount));
new RunLengthEncodedBlock(bucketBlock, positionCount),
createOriginalFilesRowIdBlock(startingRowId, filePosition, positionCount));
for (int channel = 0; channel < sourcePage.getChannelCount(); channel++) {
originalFilesBlockBuilder.add(sourcePage.getBlock(channel));
}
Expand Down Expand Up @@ -425,8 +425,8 @@ public Block block(Page sourcePage, MaskDeletedRowsFunction maskDeletedRowsFunct
Optional.empty(),
new Block[] {
new RunLengthEncodedBlock(ORIGINAL_FILE_TRANSACTION_ID_BLOCK, positionCount),
createOriginalFilesRowIdBlock(startingRowId, filePosition, positionCount),
new RunLengthEncodedBlock(bucketBlock, positionCount)
new RunLengthEncodedBlock(bucketBlock, positionCount),
createOriginalFilesRowIdBlock(startingRowId, filePosition, positionCount)
}));
return rowBlock;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ private static ConnectorPageSource createOrcPageSource(
fileReadTypes.add(BIGINT);
fileReadLayouts.add(fullyProjectedLayout());

fileReadColumns.add(acidColumnsByName.get(AcidSchema.ACID_COLUMN_ROW_ID.toLowerCase(ENGLISH)));
fileReadTypes.add(BIGINT);
fileReadLayouts.add(fullyProjectedLayout());

fileReadColumns.add(acidColumnsByName.get(AcidSchema.ACID_COLUMN_BUCKET.toLowerCase(ENGLISH)));
fileReadTypes.add(INTEGER);
fileReadLayouts.add(fullyProjectedLayout());

fileReadColumns.add(acidColumnsByName.get(AcidSchema.ACID_COLUMN_ROW_ID.toLowerCase(ENGLISH)));
fileReadTypes.add(BIGINT);
fileReadLayouts.add(fullyProjectedLayout());
}

Map<String, OrcColumn> fileColumnsByName = ImmutableMap.of();
Expand Down

0 comments on commit af40c87

Please sign in to comment.