wzx140 commented on code in PR #5522:
URL: https://github.com/apache/hudi/pull/5522#discussion_r894236249
##########
hudi-common/src/main/java/org/apache/hudi/common/table/log/block/HoodieDataBlock.java:
##########
@@ -179,40 +181,45 @@ public final ClosableIterator<IndexedRecord>
getRecordIterator(List<String> keys
return FilteringIterator.getInstance(allRecords, keySet, fullKey,
this::getRecordKey);
}
- protected ClosableIterator<IndexedRecord> readRecordsFromBlockPayload()
throws IOException {
+ protected ClosableIterator<HoodieRecord>
readRecordsFromBlockPayload(HoodieRecord.Mapper mapper) throws IOException {
if (readBlockLazily && !getContent().isPresent()) {
// read log block contents from disk
inflate();
}
try {
- return deserializeRecords(getContent().get());
+ return deserializeRecords(getContent().get(), mapper);
} finally {
// Free up content to be GC'd by deflating the block
deflate();
}
}
- protected ClosableIterator<IndexedRecord> lookupRecords(List<String> keys,
boolean fullKey) throws IOException {
+ protected ClosableIterator<HoodieRecord> lookupRecords(List<String> keys,
boolean fullKey, HoodieRecord.Mapper mapper) throws IOException {
throw new UnsupportedOperationException(
String.format("Point lookups are not supported by this Data block type
(%s)", getBlockType())
);
}
- protected abstract byte[] serializeRecords(List<IndexedRecord> records)
throws IOException;
+ protected abstract byte[] serializeRecords(List<HoodieRecord> records)
throws IOException;
- protected abstract ClosableIterator<IndexedRecord> deserializeRecords(byte[]
content) throws IOException;
+ protected abstract ClosableIterator<HoodieRecord> deserializeRecords(byte[]
content, HoodieRecord.Mapper mapper) throws IOException;
public abstract HoodieLogBlockType getBlockType();
protected Option<Schema.Field> getKeyField(Schema schema) {
return Option.ofNullable(schema.getField(keyFieldName));
}
- protected Option<String> getRecordKey(IndexedRecord record) {
- return getKeyField(record.getSchema())
- .map(keyField -> record.get(keyField.pos()))
- .map(Object::toString);
+ protected Option<String> getRecordKey(HoodieRecord record) {
+ if (record instanceof HoodieAvroIndexedRecord) {
Review Comment:
Fixed. Make an abstracted way in HoodieRecord with
`record.getRecordKey(keyFieldName)`
--
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]