Minor fixes for MergeOnRead MVP release readiness
This commit is contained in:
committed by
vinoth chandar
parent
75df72f575
commit
93f345a032
@@ -77,6 +77,7 @@ public class HoodieLogFormatTest {
|
||||
private Path partitionPath;
|
||||
private static String basePath;
|
||||
private int bufferSize = 4096;
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
|
||||
private Boolean readBlocksLazily = true;
|
||||
|
||||
@@ -401,7 +402,7 @@ public class HoodieLogFormatTest {
|
||||
// scan all log blocks (across multiple log files)
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath,
|
||||
logFiles.stream().map(logFile -> logFile.getPath().toString()).collect(Collectors.toList()), schema, "100",
|
||||
10240L, readBlocksLazily, false, bufferSize);
|
||||
10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
|
||||
List<IndexedRecord> scannedRecords = new ArrayList<>();
|
||||
for (HoodieRecord record : scanner) {
|
||||
@@ -527,7 +528,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("", 200, scanner.getTotalLogRecords());
|
||||
Set<String> readKeys = new HashSet<>(200);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
@@ -587,7 +588,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"102", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"102", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We read 200 records from 2 write batches", 200, scanner.getTotalLogRecords());
|
||||
Set<String> readKeys = new HashSet<>(200);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
@@ -665,7 +666,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"103", 10240L, true, false, bufferSize);
|
||||
"103", 10240L, true, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We would read 200 records", 200, scanner.getTotalLogRecords());
|
||||
Set<String> readKeys = new HashSet<>(200);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
@@ -719,7 +720,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"102", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"102", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We still would read 200 records", 200, scanner.getTotalLogRecords());
|
||||
final List<String> readKeys = new ArrayList<>(200);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
@@ -739,7 +740,7 @@ public class HoodieLogFormatTest {
|
||||
|
||||
readKeys.clear();
|
||||
scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema, "101", 10240L, readBlocksLazily,
|
||||
false, bufferSize);
|
||||
false, bufferSize, BASE_OUTPUT_PATH);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
assertEquals("Stream collect should return all 200 records after rollback of delete", 200, readKeys.size());
|
||||
}
|
||||
@@ -800,7 +801,7 @@ public class HoodieLogFormatTest {
|
||||
|
||||
// all data must be rolled back before merge
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We would have scanned 0 records because of rollback", 0, scanner.getTotalLogRecords());
|
||||
|
||||
final List<String> readKeys = new ArrayList<>();
|
||||
@@ -849,7 +850,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We would read 0 records", 0, scanner.getTotalLogRecords());
|
||||
}
|
||||
|
||||
@@ -881,7 +882,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"100", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We still would read 100 records", 100, scanner.getTotalLogRecords());
|
||||
final List<String> readKeys = new ArrayList<>(100);
|
||||
scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey()));
|
||||
@@ -931,7 +932,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"101", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"101", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We would read 0 records", 0, scanner.getTotalLogRecords());
|
||||
}
|
||||
|
||||
@@ -1019,7 +1020,7 @@ public class HoodieLogFormatTest {
|
||||
"100").map(s -> s.getPath().toString()).collect(Collectors.toList());
|
||||
|
||||
HoodieCompactedLogRecordScanner scanner = new HoodieCompactedLogRecordScanner(fs, basePath, allLogFiles, schema,
|
||||
"101", 10240L, readBlocksLazily, false, bufferSize);
|
||||
"101", 10240L, readBlocksLazily, false, bufferSize, BASE_OUTPUT_PATH);
|
||||
assertEquals("We would read 0 records", 0, scanner.getTotalLogRecords());
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +51,14 @@ import org.junit.Test;
|
||||
|
||||
public class TestDiskBasedMap {
|
||||
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
|
||||
@Test
|
||||
public void testSimpleInsert() throws IOException, URISyntaxException {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(Optional.empty(),
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH,
|
||||
new StringConverter(), new HoodieRecordConverter(schema, payloadClazz));
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
((GenericRecord) iRecords.get(0)).get(HoodieRecord.COMMIT_TIME_METADATA_FIELD).toString();
|
||||
@@ -78,7 +80,7 @@ public class TestDiskBasedMap {
|
||||
Schema schema = getSimpleSchema();
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(Optional.empty(),
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH,
|
||||
new StringConverter(), new HoodieRecordConverter(schema, payloadClazz));
|
||||
List<HoodieRecord> hoodieRecords = SchemaTestUtil
|
||||
.generateHoodieTestRecordsWithoutHoodieMetadata(0, 1000);
|
||||
@@ -105,7 +107,7 @@ public class TestDiskBasedMap {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
DiskBasedMap records = new DiskBasedMap<>(Optional.empty(),
|
||||
DiskBasedMap records = new DiskBasedMap<>(BASE_OUTPUT_PATH,
|
||||
new StringConverter(), new HoodieRecordConverter(schema, payloadClazz));
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
|
||||
@@ -191,9 +193,7 @@ public class TestDiskBasedMap {
|
||||
}
|
||||
|
||||
/**
|
||||
* vb - Disabled this test after talking to Nishanth as this relies on timing and sometimes fails in my laptop.
|
||||
* This specific test sometime takes more than 100 ms (In one case, saw 122 ms),
|
||||
* @na: TODO: Please check if this can be removed.
|
||||
* @na: Leaving this test here for a quick performance test
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.uber.hoodie.common.util.SchemaTestUtil;
|
||||
import com.uber.hoodie.common.util.SpillableMapTestUtils;
|
||||
import com.uber.hoodie.common.util.collection.converter.HoodieRecordConverter;
|
||||
import com.uber.hoodie.common.util.collection.converter.StringConverter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -40,6 +41,7 @@ import java.util.Optional;
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.generic.GenericRecord;
|
||||
import org.apache.avro.generic.IndexedRecord;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
@@ -48,13 +50,22 @@ import org.junit.runners.MethodSorters;
|
||||
public class TestExternalSpillableMap {
|
||||
|
||||
private static final String FAILURE_OUTPUT_PATH = "/tmp/test_fail";
|
||||
private static final String BASE_OUTPUT_PATH = "/tmp/";
|
||||
|
||||
@BeforeClass
|
||||
public static void cleanUp() {
|
||||
File file = new File(BASE_OUTPUT_PATH);
|
||||
file.delete();
|
||||
file = new File(FAILURE_OUTPUT_PATH);
|
||||
file.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleInsertTest() throws IOException, URISyntaxException {
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(SchemaTestUtil.getSimpleSchema());
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.empty(), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -76,7 +87,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.of(FAILURE_OUTPUT_PATH), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -114,7 +125,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.empty(), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -169,7 +180,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.of(FAILURE_OUTPUT_PATH), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, FAILURE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100);
|
||||
@@ -188,7 +199,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.of(FAILURE_OUTPUT_PATH), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<String> recordKeys = new ArrayList<>();
|
||||
@@ -241,7 +252,7 @@ public class TestExternalSpillableMap {
|
||||
String payloadClazz = HoodieAvroPayload.class.getName();
|
||||
|
||||
ExternalSpillableMap<String, HoodieRecord<? extends HoodieRecordPayload>> records =
|
||||
new ExternalSpillableMap<>(16L, Optional.of(FAILURE_OUTPUT_PATH), new StringConverter(),
|
||||
new ExternalSpillableMap<>(16L, BASE_OUTPUT_PATH, new StringConverter(),
|
||||
new HoodieRecordConverter(schema, payloadClazz)); //16B
|
||||
|
||||
List<String> recordKeys = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user