[MINOR] Inline the partition path logic into the builder (#5310)
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.apache.hudi.table.format;
|
||||
|
||||
import org.apache.hudi.common.fs.FSUtils;
|
||||
import org.apache.hudi.common.model.HoodieOperation;
|
||||
import org.apache.hudi.common.model.HoodieRecord;
|
||||
import org.apache.hudi.common.table.log.HoodieMergedLogRecordScanner;
|
||||
@@ -42,7 +43,6 @@ import org.apache.flink.table.data.RowData;
|
||||
import org.apache.flink.types.RowKind;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -52,10 +52,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.apache.hudi.common.fs.FSUtils.getFs;
|
||||
import static org.apache.hudi.common.fs.FSUtils.getRelativePartitionPath;
|
||||
import static org.apache.hudi.common.util.CollectionUtils.isNullOrEmpty;
|
||||
|
||||
/**
|
||||
* Utilities for format.
|
||||
*/
|
||||
@@ -128,13 +124,11 @@ public class FormatUtils {
|
||||
Schema logSchema,
|
||||
Configuration config,
|
||||
boolean withOperationField) {
|
||||
String basePath = split.getTablePath();
|
||||
List<String> logPaths = split.getLogPaths().get();
|
||||
FileSystem fs = getFs(basePath, config);
|
||||
HoodieMergedLogRecordScanner.Builder logRecordScannerBuilder = HoodieMergedLogRecordScanner.newBuilder()
|
||||
FileSystem fs = FSUtils.getFs(split.getTablePath(), config);
|
||||
return HoodieMergedLogRecordScanner.newBuilder()
|
||||
.withFileSystem(fs)
|
||||
.withBasePath(basePath)
|
||||
.withLogFilePaths(logPaths)
|
||||
.withBasePath(split.getTablePath())
|
||||
.withLogFilePaths(split.getLogPaths().get())
|
||||
.withReaderSchema(logSchema)
|
||||
.withLatestInstantTime(split.getLatestCommit())
|
||||
.withReadBlocksLazily(
|
||||
@@ -150,12 +144,8 @@ public class FormatUtils {
|
||||
config.get(HoodieRealtimeConfig.SPILLABLE_MAP_BASE_PATH_PROP,
|
||||
HoodieRealtimeConfig.DEFAULT_SPILLABLE_MAP_BASE_PATH))
|
||||
.withInstantRange(split.getInstantRange())
|
||||
.withOperationField(withOperationField);
|
||||
if (!isNullOrEmpty(logPaths)) {
|
||||
logRecordScannerBuilder
|
||||
.withPartition(getRelativePartitionPath(new Path(basePath), new Path(logPaths.get(0)).getParent()));
|
||||
}
|
||||
return logRecordScannerBuilder.build();
|
||||
.withOperationField(withOperationField)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static HoodieUnMergedLogRecordScanner unMergedLogScanner(
|
||||
@@ -163,7 +153,7 @@ public class FormatUtils {
|
||||
Schema logSchema,
|
||||
Configuration config,
|
||||
HoodieUnMergedLogRecordScanner.LogRecordScannerCallback callback) {
|
||||
FileSystem fs = getFs(split.getTablePath(), config);
|
||||
FileSystem fs = FSUtils.getFs(split.getTablePath(), config);
|
||||
return HoodieUnMergedLogRecordScanner.newBuilder()
|
||||
.withFileSystem(fs)
|
||||
.withBasePath(split.getTablePath())
|
||||
@@ -244,8 +234,8 @@ public class FormatUtils {
|
||||
HoodieWriteConfig writeConfig,
|
||||
Configuration hadoopConf) {
|
||||
String basePath = writeConfig.getBasePath();
|
||||
HoodieMergedLogRecordScanner.Builder logRecordScannerBuilder = HoodieMergedLogRecordScanner.newBuilder()
|
||||
.withFileSystem(getFs(basePath, hadoopConf))
|
||||
return HoodieMergedLogRecordScanner.newBuilder()
|
||||
.withFileSystem(FSUtils.getFs(basePath, hadoopConf))
|
||||
.withBasePath(basePath)
|
||||
.withLogFilePaths(logPaths)
|
||||
.withReaderSchema(logSchema)
|
||||
@@ -256,12 +246,8 @@ public class FormatUtils {
|
||||
.withMaxMemorySizeInBytes(writeConfig.getMaxMemoryPerPartitionMerge())
|
||||
.withSpillableMapBasePath(writeConfig.getSpillableMapBasePath())
|
||||
.withDiskMapType(writeConfig.getCommonConfig().getSpillableDiskMapType())
|
||||
.withBitCaskDiskMapCompressionEnabled(writeConfig.getCommonConfig().isBitCaskDiskMapCompressionEnabled());
|
||||
if (!isNullOrEmpty(logPaths)) {
|
||||
logRecordScannerBuilder
|
||||
.withPartition(getRelativePartitionPath(new Path(basePath), new Path(logPaths.get(0)).getParent()));
|
||||
}
|
||||
return logRecordScannerBuilder.build();
|
||||
.withBitCaskDiskMapCompressionEnabled(writeConfig.getCommonConfig().isBitCaskDiskMapCompressionEnabled())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Boolean string2Boolean(String s) {
|
||||
|
||||
Reference in New Issue
Block a user