the-other-tim-brown commented on code in PR #13157:
URL: https://github.com/apache/hudi/pull/13157#discussion_r2049612332
##########
hudi-common/src/test/java/org/apache/hudi/common/table/read/TestHoodieFileGroupReaderBase.java:
##########
@@ -366,4 +400,70 @@ private boolean shouldValidatePartialRead(FileSlice
fileSlice, Schema requestedS
}
return false;
}
+
+ private List<HoodieRecord> mergeRecordLists(List<HoodieRecord> updates,
List<HoodieRecord> existing) {
+ Set<String> updatedKeys =
updates.stream().map(HoodieRecord::getRecordKey).collect(Collectors.toSet());
+ return Stream.concat(updates.stream(), existing.stream().filter(record ->
!updatedKeys.contains(record.getRecordKey())))
+ .collect(Collectors.toList());
+ }
+
+ private List<RecordIdentifier> convertHoodieRecords(List<HoodieRecord>
records, Schema schema) {
+ int keyFieldIndex = schema.getField(KEY_FIELD_NAME).pos();
+ int orderingFieldIndex = schema.getField(PRECOMBINE_FIELD_NAME).pos();
+ int partitionFieldIndex = schema.getField(PARTITION_FIELD_NAME).pos();
+ int riderFieldIndex = schema.getField(RIDER_FIELD_NAME).pos();
+ return records.stream().map(record -> {
+ try {
+ RawTripTestPayload payload = (RawTripTestPayload) record.getData();
+ IndexedRecord indexedRecord = payload.getRecordToInsert(schema);
+ return new
RecordIdentifier(indexedRecord.get(keyFieldIndex).toString(),
indexedRecord.get(orderingFieldIndex).toString(),
+ indexedRecord.get(partitionFieldIndex).toString(),
indexedRecord.get(riderFieldIndex).toString());
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }).collect(Collectors.toList());
+ }
+
+ private List<RecordIdentifier> convertEngineRecords(List<T> records, Schema
schema, HoodieReaderContext<T> readerContext) {
+ return records.stream()
+ .map(record -> new RecordIdentifier(readerContext.getValue(record,
schema, KEY_FIELD_NAME).toString(),
+ readerContext.getValue(record, schema,
PRECOMBINE_FIELD_NAME).toString(),
+ readerContext.getValue(record, schema,
PARTITION_FIELD_NAME).toString(),
+ readerContext.getValue(record, schema,
RIDER_FIELD_NAME).toString()))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Used for equality checks between the expected and actual records for the
FileGroupReader.
+ */
+ private static class RecordIdentifier {
Review Comment:
Updated the code
--
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]