Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void testEmptyLog() throws IOException {
assertEquals(0, writer.getCurrentSize(), "Just created this log, size should be 0");
assertTrue(writer.getLogFile().getFileName().startsWith("."), "Check all log files should start with a .");
assertEquals(1, writer.getLogFile().getLogVersion(), "Version should be 1 for new log created");
writer.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nsivabalan for the future reference: it's easier to manage and more predictable to use try-with-resources statement:

try (Closeable c = ...) {
  // Will be closed automatically even in the presence of exceptions
}

}

@ParameterizedTest
Expand Down Expand Up @@ -698,7 +699,7 @@ public void testBasicAppendAndScanMultipleFiles(ExternalSpillableMap.DiskMapType

assertEquals(scannedRecords.size(), allRecords.stream().mapToLong(Collection::size).sum(),
"Scanner records count should be the same as appended records");

scanner.close();
}

@Test
Expand Down Expand Up @@ -933,6 +934,7 @@ public void testAvroLogRecordReaderBasic(ExternalSpillableMap.DiskMapType diskMa
copyOfRecords1.stream().map(s -> ((GenericRecord) s).get(HoodieRecord.RECORD_KEY_METADATA_FIELD).toString())
.collect(Collectors.toSet());
assertEquals(originalKeys, readKeys, "CompositeAvroLogReader should return 200 records from 2 versions");
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1017,6 +1019,7 @@ public void testAvroLogRecordReaderWithRollbackTombstone(ExternalSpillableMap.Di
copyOfRecords1.stream().map(s -> ((GenericRecord) s).get(HoodieRecord.RECORD_KEY_METADATA_FIELD).toString())
.collect(Collectors.toSet());
assertEquals(originalKeys, readKeys, "CompositeAvroLogReader should return 200 records from 2 versions");
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1106,6 +1109,7 @@ public void testAvroLogRecordReaderWithFailedPartialBlock(ExternalSpillableMap.D
copyOfRecords1.stream().map(s -> ((GenericRecord) s).get(HoodieRecord.RECORD_KEY_METADATA_FIELD).toString())
.collect(Collectors.toSet());
assertEquals(originalKeys, readKeys, "CompositeAvroLogReader should return 200 records from 2 versions");
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1209,6 +1213,7 @@ public void testAvroLogRecordReaderWithDeleteAndRollback(ExternalSpillableMap.Di
FileCreateUtils.deleteDeltaCommit(basePath, "101", fs);

readKeys.clear();
scanner.close();
scanner = HoodieMergedLogRecordScanner.newBuilder()
.withFileSystem(fs)
.withBasePath(basePath)
Expand Down Expand Up @@ -1243,6 +1248,8 @@ public void testAvroLogRecordReaderWithDeleteAndRollback(ExternalSpillableMap.Di
Collections.sort(firstBlockRecords);
Collections.sort(readKeys);
assertEquals(firstBlockRecords, readKeys, "CompositeAvroLogReader should return 150 records from 2 versions");
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1360,6 +1367,8 @@ public void testAvroLogRecordReaderWithDisorderDelete(ExternalSpillableMap.DiskM
Collections.sort(originalKeys);
Collections.sort(readKeys);
assertEquals(originalKeys, readKeys, "HoodieMergedLogRecordScanner should return 180 records from 4 versions");
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1447,6 +1456,8 @@ public void testAvroLogRecordReaderWithFailedRollbacks(ExternalSpillableMap.Disk
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
assertEquals(0, readKeys.size(), "Stream collect should return all 0 records");
FileCreateUtils.deleteDeltaCommit(basePath, "100", fs);
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1513,6 +1524,8 @@ public void testAvroLogRecordReaderWithInsertDeleteAndRollback(ExternalSpillable
.build();
assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records");
FileCreateUtils.deleteDeltaCommit(basePath, "100", fs);
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1568,6 +1581,8 @@ public void testAvroLogRecordReaderWithInvalidRollback(ExternalSpillableMap.Disk
final List<String> readKeys = new ArrayList<>(100);
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
assertEquals(100, readKeys.size(), "Stream collect should return all 150 records");
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1637,6 +1652,8 @@ public void testAvroLogRecordReaderWithInsertsDeleteAndRollback(ExternalSpillabl
.withUseScanV2(useScanv2)
.build();
assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records");
writer.close();
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1746,6 +1763,7 @@ public void testAvroLogRecordReaderWithMixedInsertsCorruptsAndRollback(ExternalS
.build();
assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records");
FileCreateUtils.deleteDeltaCommit(basePath, "100", fs);
scanner.close();
}

@ParameterizedTest
Expand Down Expand Up @@ -1936,6 +1954,7 @@ public void testAvroLogRecordReaderWithMixedInsertsCorruptsRollbackAndMergedLogB
assertEquals(expectedBlockInstants, validBlockInstants);
Collections.sort(readKeys);
assertEquals(expectedRecords, readKeys, "Record keys read should be exactly same.");
scanner.close();
}

/*
Expand Down Expand Up @@ -2013,7 +2032,7 @@ private void testAvroLogRecordReaderMergingMultipleLogFiles(int numRecordsInLog1

assertEquals(Math.max(numRecordsInLog1, numRecordsInLog2), scanner.getNumMergedRecordsInLog(),
"We would read 100 records");

scanner.close();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down