[HUDI-1294] Adding inline read and seek based read(batch get) for hfile log blocks in metadata table (#3762)
This commit is contained in:
committed by
GitHub
parent
0223c442ec
commit
69ee790a47
@@ -27,6 +27,7 @@ import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.table.HoodieTableConfig;
|
||||
import org.apache.hudi.common.table.log.HoodieLogFormat;
|
||||
import org.apache.hudi.common.table.log.HoodieLogFormat.Writer;
|
||||
import org.apache.hudi.common.table.log.block.HoodieLogBlock;
|
||||
import org.apache.hudi.common.table.timeline.HoodieTimeline;
|
||||
import org.apache.hudi.common.testutils.FileCreateUtils;
|
||||
import org.apache.hudi.common.testutils.HoodieTestUtils;
|
||||
@@ -137,6 +138,24 @@ public class TestHoodieRealtimeRecordReader {
|
||||
public void testReader(ExternalSpillableMap.DiskMapType diskMapType,
|
||||
boolean isCompressionEnabled,
|
||||
boolean partitioned) throws Exception {
|
||||
testReaderInternal(diskMapType, isCompressionEnabled, partitioned);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHFileInlineReader() throws Exception {
|
||||
testReaderInternal(ExternalSpillableMap.DiskMapType.BITCASK, false, false,
|
||||
HoodieLogBlock.HoodieLogBlockType.HFILE_DATA_BLOCK);
|
||||
}
|
||||
|
||||
private void testReaderInternal(ExternalSpillableMap.DiskMapType diskMapType,
|
||||
boolean isCompressionEnabled,
|
||||
boolean partitioned) throws Exception {
|
||||
testReaderInternal(diskMapType, isCompressionEnabled, partitioned, HoodieLogBlock.HoodieLogBlockType.AVRO_DATA_BLOCK);
|
||||
}
|
||||
|
||||
private void testReaderInternal(ExternalSpillableMap.DiskMapType diskMapType,
|
||||
boolean isCompressionEnabled,
|
||||
boolean partitioned, HoodieLogBlock.HoodieLogBlockType logBlockType) throws Exception {
|
||||
// initial commit
|
||||
Schema schema = HoodieAvroUtils.addMetadataFields(SchemaTestUtil.getEvolvedSchema());
|
||||
HoodieTestUtils.init(hadoopConf, basePath.toString(), HoodieTableType.MERGE_ON_READ);
|
||||
@@ -175,7 +194,7 @@ public class TestHoodieRealtimeRecordReader {
|
||||
} else {
|
||||
writer =
|
||||
InputFormatTestUtil.writeDataBlockToLogFile(partitionDir, fs, schema, "fileid0", baseInstant,
|
||||
instantTime, 120, 0, logVersion);
|
||||
instantTime, 120, 0, logVersion, logBlockType);
|
||||
}
|
||||
long size = writer.getCurrentSize();
|
||||
writer.close();
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.apache.hudi.common.model.HoodieTableType;
|
||||
import org.apache.hudi.common.table.log.HoodieLogFormat;
|
||||
import org.apache.hudi.common.table.log.block.HoodieAvroDataBlock;
|
||||
import org.apache.hudi.common.table.log.block.HoodieCommandBlock;
|
||||
import org.apache.hudi.common.table.log.block.HoodieDataBlock;
|
||||
import org.apache.hudi.common.table.log.block.HoodieHFileDataBlock;
|
||||
import org.apache.hudi.common.table.log.block.HoodieLogBlock;
|
||||
import org.apache.hudi.common.testutils.HoodieTestUtils;
|
||||
import org.apache.hudi.common.testutils.SchemaTestUtil;
|
||||
@@ -301,7 +303,14 @@ public class InputFormatTestUtil {
|
||||
|
||||
public static HoodieLogFormat.Writer writeDataBlockToLogFile(File partitionDir, FileSystem fs, Schema schema, String
|
||||
fileId,
|
||||
String baseCommit, String newCommit, int numberOfRecords, int offset, int logVersion)
|
||||
String baseCommit, String newCommit, int numberOfRecords, int offset, int logVersion) throws IOException, InterruptedException {
|
||||
return writeDataBlockToLogFile(partitionDir, fs, schema, fileId, baseCommit, newCommit, numberOfRecords, offset, logVersion, HoodieLogBlock.HoodieLogBlockType.AVRO_DATA_BLOCK);
|
||||
}
|
||||
|
||||
public static HoodieLogFormat.Writer writeDataBlockToLogFile(File partitionDir, FileSystem fs, Schema schema, String
|
||||
fileId,
|
||||
String baseCommit, String newCommit, int numberOfRecords, int offset, int logVersion,
|
||||
HoodieLogBlock.HoodieLogBlockType logBlockType)
|
||||
throws InterruptedException, IOException {
|
||||
HoodieLogFormat.Writer writer = HoodieLogFormat.newWriterBuilder().onParentPath(new Path(partitionDir.getPath()))
|
||||
.withFileExtension(HoodieLogFile.DELTA_EXTENSION).withFileId(fileId).withLogVersion(logVersion)
|
||||
@@ -314,7 +323,8 @@ public class InputFormatTestUtil {
|
||||
Map<HoodieLogBlock.HeaderMetadataType, String> header = new HashMap<>();
|
||||
header.put(HoodieLogBlock.HeaderMetadataType.INSTANT_TIME, newCommit);
|
||||
header.put(HoodieLogBlock.HeaderMetadataType.SCHEMA, writeSchema.toString());
|
||||
HoodieAvroDataBlock dataBlock = new HoodieAvroDataBlock(records, header);
|
||||
HoodieDataBlock dataBlock = (logBlockType == HoodieLogBlock.HoodieLogBlockType.HFILE_DATA_BLOCK) ? new HoodieHFileDataBlock(records, header) :
|
||||
new HoodieAvroDataBlock(records, header);
|
||||
writer.appendBlock(dataBlock);
|
||||
return writer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user