Copilot commented on code in PR #683:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/683#discussion_r2467899937
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/HugeClientHolder.java:
##########
@@ -106,4 +144,31 @@ public static HugeClient create(LoadOptions options) {
throw e;
}
}
+
+ protected static void pickHostFromMeta(LoadOptions options) {
+ PDHugeClientFactory clientFactory =
+ new PDHugeClientFactory(options.pdPeers, options.routeType);
+
+ List<String> urls = clientFactory.getAutoURLs(options.cluster,
+ options.graphSpace,
null);
+
+ E.checkState(CollectionUtils.isNotEmpty(urls), "No avaliable
service!");
Review Comment:
Corrected spelling of 'avaliable' to 'available'.
```suggestion
E.checkState(CollectionUtils.isNotEmpty(urls), "No available
service!");
```
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/builder/EdgeBuilder.java:
##########
@@ -34,20 +37,16 @@
import org.apache.hugegraph.structure.schema.EdgeLabel;
import org.apache.hugegraph.structure.schema.SchemaLabel;
import org.apache.hugegraph.structure.schema.VertexLabel;
-import org.apache.hugegraph.util.E;
-
import com.google.common.collect.ImmutableList;
-import org.apache.spark.sql.Row;
-
public class EdgeBuilder extends ElementBuilder<Edge> {
private final EdgeMapping mapping;
private final EdgeLabel edgeLabel;
private final VertexLabel sourceLabel;
private final VertexLabel targetLabel;
private final Collection<String> nonNullKeys;
- // Used to optimize access performance
+ // Used to optimize access performace
Review Comment:
Corrected spelling of 'performace' to 'performance'.
```suggestion
// Used to optimize access performance
```
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/reader/file/FileLineFetcher.java:
##########
@@ -84,6 +84,7 @@ public boolean ready() {
@Override
public void resetReader() {
+ LOG.error("resetReader called, reader reset to null, offset={}",
this.offset());
Review Comment:
Error-level logging used for normal operation. This should be debug-level
logging unless this represents an actual error condition.
```suggestion
LOG.debug("resetReader called, reader reset to null, offset={}",
this.offset());
```
##########
hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/LoadTest.java:
##########
@@ -45,7 +48,9 @@ public class LoadTest {
protected static final String HTTPS_PROTOCOL = "https";
protected static final String TRUST_STORE_PATH =
"assembly/travis/conf/hugegraph.truststore";
protected static final String FILE_URL = CommonUtil.PREFIX +
"hugegraph.truststore";
- protected static final HugeClient CLIENT = HugeClient.builder(URL,
GRAPH).build();
+ protected static final HugeClient CLIENT = HugeClient.builder(URL, GRAPH)
+ .configUser("admin",
"pa")
Review Comment:
Hardcoded password 'pa' detected in authentication configuration. Use
environment variables or configuration files for credentials.
```suggestion
protected static final String TEST_USER =
System.getenv("HUGEGRAPH_TEST_USER") != null ?
System.getenv("HUGEGRAPH_TEST_USER") : "admin";
protected static final String TEST_PASS =
System.getenv("HUGEGRAPH_TEST_PASS") != null ?
System.getenv("HUGEGRAPH_TEST_PASS") : "pa";
protected static final HugeClient CLIENT = HugeClient.builder(URL, GRAPH)
.configUser(TEST_USER, TEST_PASS)
```
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/source/graph/GraphSource.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.loader.source.graph;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hugegraph.util.E;
+
+import org.apache.hugegraph.driver.HugeClient;
+import org.apache.hugegraph.driver.factory.PDHugeClientFactory;
+import org.apache.hugegraph.loader.source.AbstractSource;
+import org.apache.hugegraph.loader.source.SourceType;
+import org.apache.hugegraph.loader.source.file.FileSource;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+
+@Data
+public class GraphSource extends AbstractSource {
+ @JsonProperty("pd-peers")
+ private String pdPeers;
+
+ @JsonProperty("meta-endpoints")
+ private String metaEndPoints;
+
+ @JsonProperty("cluster")
+ private String cluster;
+
+ @JsonProperty("graphspace")
+ private String graphSpace;
+
+ @JsonProperty("graph")
+ private String graph;
+
+ @JsonProperty("username")
+ private String username;
+
+ @JsonProperty("password")
+ private String password;
+
+ @JsonProperty("selected_vertices")
+ private List<SeletedLabelDes> selectedVertices;
+
+ @JsonProperty("ignored_vertices")
+ private List<IgnoredLabelDes> ignoredVertices;
+
+ @JsonProperty("selected_edges")
+ private List<SeletedLabelDes> selectedEdges;
+
+ @JsonProperty("ignored_edges")
+ private List<IgnoredLabelDes> ignoredEdges;
+
+ @JsonProperty("batch_size")
+ private int batchSize = 500;
+
+ @Override
+ public SourceType type() {
+ return SourceType.GRAPH;
+ }
+
+ @Override
+ public void check() throws IllegalArgumentException {
+ super.check();
+
+ E.checkArgument(!StringUtils.isEmpty(this.graphSpace),
+ "graphspace of GraphInput must be not empty");
+
+ E.checkArgument(!StringUtils.isEmpty(this.graph),
+ "graph of GraphInput must be not empty");
+ }
+
+ @Override
+ public FileSource asFileSource() {
+ FileSource source = new FileSource();
+ source.header(this.header());
+ source.charset(this.charset());
+ source.listFormat(this.listFormat());
+
+ return source;
+ }
+
+ @Data
+ public static class SeletedLabelDes {
Review Comment:
Corrected spelling of 'Seleted' to 'Selected'.
##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/DataTypeUtil.java:
##########
@@ -59,8 +60,10 @@ public static boolean isSimpleValue(Object value) {
return ReflectionUtil.isSimpleType(value.getClass());
}
- public static Object convert(Object value, PropertyKey propertyKey,
InputSource source) {
- E.checkArgumentNotNull(value, "The value to be converted can't be
null");
+ public static Object convert(Object value, PropertyKey propertyKey,
+ InputSource source) {
+ E.checkArgumentNotNull(value, "The value of Property(%s) to be " +
+ "converted. can't be null",
propertyKey.name());
Review Comment:
Remove unnecessary period before 'can't' in error message.
```suggestion
"converted can't be null",
propertyKey.name());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]