nsivabalan commented on code in PR #12594:
URL: https://github.com/apache/hudi/pull/12594#discussion_r1911165776
##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -84,19 +86,32 @@ public HoodieDataBlock(List<HoodieRecord> records,
Map<FooterMetadataType, String> footer,
String keyFieldName) {
super(header, footer, Option.empty(), Option.empty(), null, false);
- if (shouldWriteRecordPositions) {
- records.sort((o1, o2) -> {
- long v1 = o1.getCurrentPosition();
- long v2 = o2.getCurrentPosition();
- return Long.compare(v1, v2);
- });
- if (isPositionValid(records.get(0).getCurrentPosition())) {
- addRecordPositionsToHeader(
-
records.stream().map(HoodieRecord::getCurrentPosition).collect(Collectors.toSet()),
- records.size());
+ if (shouldWriteRecordPositions && !records.isEmpty()) {
+ String baseFileInstantTime =
records.get(0).getCurrentBaseFileInstantTime();
+ for (HoodieRecord record : records) {
+ if
(!baseFileInstantTime.equals(record.getCurrentBaseFileInstantTime())) {
+ baseFileInstantTime = EMPTY_STRING;
+ break;
+ }
+ }
+ if (StringUtils.isNullOrEmpty(baseFileInstantTime)) {
+ LOG.warn("Base file instant time of delete positions cannot be
determined, possibly "
+ + "due to inserts or different base file instant times for the
input records.");
} else {
- LOG.warn("There are records without valid positions. "
- + "Skip writing record positions to the data block header.");
+ records.sort((o1, o2) -> {
+ long v1 = o1.getCurrentPosition();
+ long v2 = o2.getCurrentPosition();
+ return Long.compare(v1, v2);
+ });
+ if (isPositionValid(records.get(0).getCurrentPosition())) {
Review Comment:
curious on this code block even prior to this patch.
why would position be invalid?
and if its valid for 1st record, is it safe to assume entire set of records
are valid as well ?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]