Skip to content

Commit

Permalink
Remove redundant ACID condition in OrcFileWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Nov 14, 2023
1 parent 380b0a5 commit 0e5d54e
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public Closeable commit()
{
try {
if (transaction.isAcidTransactionRunning() && useAcidSchema) {
updateUserMetadata();
updateAcidUserMetadata();
}
orcWriter.close();
}
Expand Down Expand Up @@ -213,28 +213,26 @@ public Closeable commit()
return rollbackAction;
}

private void updateUserMetadata()
private void updateAcidUserMetadata()
{
int bucketValue = computeBucketValue(bucketNumber.orElse(0), 0);
long writeId = maxWriteId.isPresent() ? maxWriteId.getAsLong() : transaction.getWriteId();
if (transaction.isAcidTransactionRunning()) {
int stripeRowCount = orcWriter.getStripeRowCount();
Map<String, String> userMetadata = new HashMap<>();
switch (writerKind) {
case INSERT:
userMetadata.put("hive.acid.stats", format("%s,0,0", stripeRowCount));
break;
case DELETE:
userMetadata.put("hive.acid.stats", format("0,0,%s", stripeRowCount));
break;
default:
throw new IllegalStateException("In updateUserMetadata, unknown writerKind " + writerKind);
}
userMetadata.put("hive.acid.key.index", format("%s,%s,%s;", writeId, bucketValue, stripeRowCount - 1));
userMetadata.put("hive.acid.version", "2");

orcWriter.updateUserMetadata(userMetadata);
int stripeRowCount = orcWriter.getStripeRowCount();
Map<String, String> userMetadata = new HashMap<>();
switch (writerKind) {
case INSERT:
userMetadata.put("hive.acid.stats", format("%s,0,0", stripeRowCount));
break;
case DELETE:
userMetadata.put("hive.acid.stats", format("0,0,%s", stripeRowCount));
break;
default:
throw new IllegalStateException("In updateUserMetadata, unknown writerKind " + writerKind);
}
userMetadata.put("hive.acid.key.index", format("%s,%s,%s;", writeId, bucketValue, stripeRowCount - 1));
userMetadata.put("hive.acid.version", "2");

orcWriter.updateUserMetadata(userMetadata);
}

@Override
Expand Down

0 comments on commit 0e5d54e

Please sign in to comment.