[HUDI-624]: Split some of the code from PR for HUDI-479 (#1344)
This commit is contained in:
@@ -38,8 +38,6 @@ import org.apache.hudi.config.HoodieCompactionConfig;
|
||||
import org.apache.hudi.config.HoodieMemoryConfig;
|
||||
import org.apache.hudi.hive.util.SchemaUtil;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
@@ -59,6 +57,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import scala.Tuple2;
|
||||
@@ -85,14 +84,14 @@ public class HoodieLogFileCommand implements CommandMarker {
|
||||
List<String> logFilePaths = Arrays.stream(fs.globStatus(new Path(logFilePathPattern)))
|
||||
.map(status -> status.getPath().toString()).collect(Collectors.toList());
|
||||
Map<String, List<Tuple3<HoodieLogBlockType, Tuple2<Map<HeaderMetadataType, String>, Map<HeaderMetadataType, String>>, Integer>>> commitCountAndMetadata =
|
||||
Maps.newHashMap();
|
||||
new HashMap<>();
|
||||
int numCorruptBlocks = 0;
|
||||
int dummyInstantTimeCount = 0;
|
||||
|
||||
for (String logFilePath : logFilePaths) {
|
||||
FileStatus[] fsStatus = fs.listStatus(new Path(logFilePath));
|
||||
Schema writerSchema = new AvroSchemaConverter()
|
||||
.convert(Preconditions.checkNotNull(SchemaUtil.readSchemaFromLogFile(fs, new Path(logFilePath))));
|
||||
.convert(Objects.requireNonNull(SchemaUtil.readSchemaFromLogFile(fs, new Path(logFilePath))));
|
||||
Reader reader = HoodieLogFormat.newReader(fs, new HoodieLogFile(fsStatus[0].getPath()), writerSchema);
|
||||
|
||||
// read the avro blocks
|
||||
@@ -181,7 +180,7 @@ public class HoodieLogFileCommand implements CommandMarker {
|
||||
AvroSchemaConverter converter = new AvroSchemaConverter();
|
||||
// get schema from last log file
|
||||
Schema readerSchema =
|
||||
converter.convert(Preconditions.checkNotNull(SchemaUtil.readSchemaFromLogFile(fs, new Path(logFilePaths.get(logFilePaths.size() - 1)))));
|
||||
converter.convert(Objects.requireNonNull(SchemaUtil.readSchemaFromLogFile(fs, new Path(logFilePaths.get(logFilePaths.size() - 1)))));
|
||||
|
||||
List<IndexedRecord> allRecords = new ArrayList<>();
|
||||
|
||||
@@ -204,7 +203,7 @@ public class HoodieLogFileCommand implements CommandMarker {
|
||||
} else {
|
||||
for (String logFile : logFilePaths) {
|
||||
Schema writerSchema = new AvroSchemaConverter()
|
||||
.convert(Preconditions.checkNotNull(SchemaUtil.readSchemaFromLogFile(client.getFs(), new Path(logFile))));
|
||||
.convert(Objects.requireNonNull(SchemaUtil.readSchemaFromLogFile(client.getFs(), new Path(logFile))));
|
||||
HoodieLogFormat.Reader reader =
|
||||
HoodieLogFormat.newReader(fs, new HoodieLogFile(new Path(logFile)), writerSchema);
|
||||
// read the avro blocks
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package org.apache.hudi.cli.commands;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.hudi.HoodieWriteClient;
|
||||
import org.apache.hudi.cli.DedupeSparkJob;
|
||||
import org.apache.hudi.cli.utils.SparkUtil;
|
||||
import org.apache.hudi.common.util.FSUtils;
|
||||
import org.apache.hudi.common.util.StringUtils;
|
||||
import org.apache.hudi.config.HoodieIndexConfig;
|
||||
import org.apache.hudi.config.HoodieWriteConfig;
|
||||
import org.apache.hudi.index.HoodieIndex;
|
||||
@@ -81,7 +81,7 @@ public class SparkMain {
|
||||
case UPSERT:
|
||||
assert (args.length >= 12);
|
||||
String propsFilePath = null;
|
||||
if (!Strings.isNullOrEmpty(args[11])) {
|
||||
if (!StringUtils.isNullOrEmpty(args[11])) {
|
||||
propsFilePath = args[11];
|
||||
}
|
||||
List<String> configs = new ArrayList<>();
|
||||
@@ -94,7 +94,7 @@ public class SparkMain {
|
||||
case COMPACT_RUN:
|
||||
assert (args.length >= 9);
|
||||
propsFilePath = null;
|
||||
if (!Strings.isNullOrEmpty(args[8])) {
|
||||
if (!StringUtils.isNullOrEmpty(args[8])) {
|
||||
propsFilePath = args[8];
|
||||
}
|
||||
configs = new ArrayList<>();
|
||||
@@ -107,7 +107,7 @@ public class SparkMain {
|
||||
case COMPACT_SCHEDULE:
|
||||
assert (args.length >= 6);
|
||||
propsFilePath = null;
|
||||
if (!Strings.isNullOrEmpty(args[5])) {
|
||||
if (!StringUtils.isNullOrEmpty(args[5])) {
|
||||
propsFilePath = args[5];
|
||||
}
|
||||
configs = new ArrayList<>();
|
||||
@@ -142,7 +142,7 @@ public class SparkMain {
|
||||
case CLEAN:
|
||||
assert (args.length >= 5);
|
||||
propsFilePath = null;
|
||||
if (!Strings.isNullOrEmpty(args[3])) {
|
||||
if (!StringUtils.isNullOrEmpty(args[3])) {
|
||||
propsFilePath = args[3];
|
||||
}
|
||||
configs = new ArrayList<>();
|
||||
|
||||
@@ -24,8 +24,6 @@ import org.apache.hudi.cli.commands.SparkMain;
|
||||
import org.apache.hudi.common.util.FSUtils;
|
||||
import org.apache.hudi.common.util.StringUtils;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import org.apache.spark.SparkConf;
|
||||
import org.apache.spark.api.java.JavaSparkContext;
|
||||
import org.apache.spark.launcher.SparkLauncher;
|
||||
@@ -33,6 +31,7 @@ import org.apache.spark.launcher.SparkLauncher;
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Utility functions dealing with Spark.
|
||||
@@ -55,7 +54,7 @@ public class SparkUtil {
|
||||
sparkLauncher.setPropertiesFile(propertiesFile);
|
||||
}
|
||||
File libDirectory = new File(new File(currentJar).getParent(), "lib");
|
||||
for (String library : Preconditions.checkNotNull(libDirectory.list())) {
|
||||
for (String library : Objects.requireNonNull(libDirectory.list())) {
|
||||
sparkLauncher.addJar(new File(libDirectory, library).getAbsolutePath());
|
||||
}
|
||||
return sparkLauncher;
|
||||
|
||||
Reference in New Issue
Block a user