Skip to content

Commit

Permalink
Restore partial update change
Browse files Browse the repository at this point in the history
  • Loading branch information
yihua committed May 14, 2024
1 parent fc620ec commit 802eeb7
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@ protected void appendDataAndDeleteBlocks(Map<HeaderMetadataType, String> header,
: hoodieTable.getMetaClient().getTableConfig().getRecordKeyFieldProp();

blocks.add(getBlock(config, pickLogDataBlockFormat(), recordList, shouldWriteRecordPositions,
header, keyField));
getUpdatedHeader(header, config), keyField));
}

if (appendDeleteBlocks && recordsToDeleteWithPositions.size() > 0) {
blocks.add(new HoodieDeleteBlock(recordsToDeleteWithPositions, shouldWriteRecordPositions,
header));
getUpdatedHeader(header, config)));
}

if (blocks.size() > 0) {
Expand Down Expand Up @@ -640,6 +640,19 @@ private HoodieLogBlock.HoodieLogBlockType pickLogDataBlockFormat() {
}
}

private static Map<HeaderMetadataType, String> getUpdatedHeader(Map<HeaderMetadataType, String> header,
HoodieWriteConfig config) {
Map<HeaderMetadataType, String> updatedHeader = new HashMap<>(header);
if (config.shouldWritePartialUpdates()) {
// When enabling writing partial updates to the data blocks, the "IS_PARTIAL" flag is also
// written to the block header so that the reader can differentiate partial updates, i.e.,
// the "SCHEMA" header contains the partial schema.
updatedHeader.put(
HeaderMetadataType.IS_PARTIAL, Boolean.toString(true));
}
return updatedHeader;
}

private static HoodieLogBlock getBlock(HoodieWriteConfig writeConfig,
HoodieLogBlock.HoodieLogBlockType logDataBlockFormat,
List<HoodieRecord> records,
Expand Down

0 comments on commit 802eeb7

Please sign in to comment.