Skip to content

Commit cf92ab6

Browse files
(loader): spelling checked && fixed complicated logics
1 parent b56dacc commit cf92ab6

File tree

7 files changed

+24
-25
lines changed

7 files changed

+24
-25
lines changed

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/HugeGraphLoader.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public static void main(String[] args) {
113113
loader = new HugeGraphLoader(args);
114114
} catch (Throwable e) {
115115
Printer.printError("Failed to start loading", e);
116+
System.exit(1);
116117
return;
117118
}
118119

@@ -178,12 +179,14 @@ private void setGraphMode() {
178179
() -> this.mapping.structs().stream().filter(struct -> !struct.skip())
179180
.map(InputStruct::input);
180181

181-
if (inputsSupplier.get().anyMatch(input -> SourceType.GRAPH.equals(input.type()))) {
182-
if (!inputsSupplier.get().allMatch(input -> SourceType.GRAPH.equals(input.type()))) {
183-
throw new LoadException("All inputs must be of Graph Type");
184-
}
185-
this.context().setRestoreMode();
186-
} else if (this.options.restore) {
182+
boolean allMatch = inputsSupplier.get().allMatch(input -> SourceType.GRAPH.equals(input.type()));
183+
boolean anyMatch = inputsSupplier.get().anyMatch(input -> SourceType.GRAPH.equals(input.type()));
184+
185+
if (anyMatch && !allMatch) {
186+
throw new LoadException("All inputs must be of Graph Type");
187+
}
188+
189+
if (allMatch || this.options.restore) {
187190
this.context().setRestoreMode();
188191
} else {
189192
this.context().setLoadingMode();
@@ -219,11 +222,7 @@ public boolean load() {
219222
LOG.warn(logMessage);
220223
}
221224

222-
RuntimeException e = LoadUtil.targetRuntimeException(t);
223-
Printer.printError("Failed to load", e);
224-
LOG.error("Load failed with exception", e);
225-
226-
throw e;
225+
throw LoadUtil.targetRuntimeException(t);
227226
}
228227

229228
return true;
@@ -354,7 +353,7 @@ private void createGraphSourceLabels(
354353
HugeClient sourceClient,
355354
HugeClient targetClient,
356355
List<? extends SchemaLabel> labels, // VertexLabel or EdgeLabel
357-
Map<String, GraphSource.SeletedLabelDes> selectedMap,
356+
Map<String, GraphSource.SelectedLabelDes> selectedMap,
358357
Map<String, GraphSource.IgnoredLabelDes> ignoredMap,
359358
boolean isVertex) {
360359

@@ -419,10 +418,10 @@ private void createGraphSourceVertexLabel(HugeClient sourceClient,
419418
vertexLabels = sourceClient.schema().getVertexLabels();
420419
}
421420

422-
Map<String, GraphSource.SeletedLabelDes> mapSelectedVertices
421+
Map<String, GraphSource.SelectedLabelDes> mapSelectedVertices
423422
= new HashMap<>();
424423
if (graphSource.getSelectedVertices() != null) {
425-
for (GraphSource.SeletedLabelDes des :
424+
for (GraphSource.SelectedLabelDes des :
426425
graphSource.getSelectedVertices()) {
427426
mapSelectedVertices.put(des.getLabel(), des);
428427
}
@@ -474,10 +473,10 @@ private void createGraphSourceEdgeLabel(HugeClient sourceClient,
474473
edgeLabels = sourceClient.schema().getEdgeLabels();
475474
}
476475

477-
Map<String, GraphSource.SeletedLabelDes> mapSelectedEdges
476+
Map<String, GraphSource.SelectedLabelDes> mapSelectedEdges
478477
= new HashMap<>();
479478
if (graphSource.getSelectedEdges() != null) {
480-
for (GraphSource.SeletedLabelDes des :
479+
for (GraphSource.SelectedLabelDes des :
481480
graphSource.getSelectedEdges()) {
482481
mapSelectedEdges.put(des.getLabel(), des);
483482
}

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/builder/EdgeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class EdgeBuilder extends ElementBuilder<Edge> {
4646
private final VertexLabel sourceLabel;
4747
private final VertexLabel targetLabel;
4848
private final Collection<String> nonNullKeys;
49-
// Used to optimize access performace
49+
// Used to optimize access performance
5050
private VertexIdsIndex vertexIdsIndex;
5151
private String[] lastNames;
5252

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/FileLineFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public boolean ready() {
8484

8585
@Override
8686
public void resetReader() {
87-
LOG.error("resetReader called, reader reset to null, offset={}", this.offset());
87+
LOG.debug("resetReader called, reader reset to null, offset={}", this.offset());
8888
this.reader = null;
8989
}
9090

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/graph/GraphReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void init(LoadContext context,
9999
// Do with Vertex
100100
// 1. Get All Selected Vertex
101101
if (this.source.getSelectedVertices() != null) {
102-
for (GraphSource.SeletedLabelDes selected :
102+
for (GraphSource.SelectedLabelDes selected :
103103
this.source.getSelectedVertices()) {
104104

105105
selectedVertices.put(selected.getLabel(), null);
@@ -141,7 +141,7 @@ public void init(LoadContext context,
141141
// Do with edges
142142
// 1. Get All Selected Edges
143143
if (this.source.getSelectedEdges() != null) {
144-
for (GraphSource.SeletedLabelDes selected :
144+
for (GraphSource.SelectedLabelDes selected :
145145
this.source.getSelectedEdges()) {
146146
selectedEdges.put(selected.getLabel(), null);
147147
if (selected.getQuery() != null && selected.getQuery().size() > 0) {

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/source/graph/GraphSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public class GraphSource extends AbstractSource {
5656
private String password;
5757

5858
@JsonProperty("selected_vertices")
59-
private List<SeletedLabelDes> selectedVertices;
59+
private List<SelectedLabelDes> selectedVertices;
6060

6161
@JsonProperty("ignored_vertices")
6262
private List<IgnoredLabelDes> ignoredVertices;
6363

6464
@JsonProperty("selected_edges")
65-
private List<SeletedLabelDes> selectedEdges;
65+
private List<SelectedLabelDes> selectedEdges;
6666

6767
@JsonProperty("ignored_edges")
6868
private List<IgnoredLabelDes> ignoredEdges;
@@ -97,7 +97,7 @@ public FileSource asFileSource() {
9797
}
9898

9999
@Data
100-
public static class SeletedLabelDes {
100+
public static class SelectedLabelDes {
101101
@JsonProperty("query")
102102
private Map<String, Object> query;
103103

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/DataTypeUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static boolean isSimpleValue(Object value) {
6363
public static Object convert(Object value, PropertyKey propertyKey,
6464
InputSource source) {
6565
E.checkArgumentNotNull(value, "The value of Property(%s) to be " +
66-
"converted. can't be null", propertyKey.name());
66+
"converted can't be null", propertyKey.name());
6767

6868
String key = propertyKey.name();
6969
DataType dataType = propertyKey.dataType();

hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/HugeClientHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected static void pickHostFromMeta(LoadOptions options) {
152152
List<String> urls = clientFactory.getAutoURLs(options.cluster,
153153
options.graphSpace, null);
154154

155-
E.checkState(CollectionUtils.isNotEmpty(urls), "No avaliable service!");
155+
E.checkState(CollectionUtils.isNotEmpty(urls), "No available service!");
156156

157157
int r = (int) Math.floor(Math.random() * urls.size());
158158
String url = urls.get(r);

0 commit comments

Comments
 (0)