Skip to content

Commit

Permalink
code clean & format client
Browse files Browse the repository at this point in the history
  • Loading branch information
returnToInnocence committed Mar 20, 2024
1 parent 7bfcd66 commit 1fcc380
Show file tree
Hide file tree
Showing 49 changed files with 105 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public GremlinRequest(String gremlin) {
}

public static class Builder {

private GremlinRequest request;
private GremlinManager manager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.hugegraph.util.CommonUtil;
import org.apache.hugegraph.api.API;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.constant.HugeType;
import org.apache.hugegraph.util.CommonUtil;

public class MetricsAPI extends API {

Expand Down Expand Up @@ -68,7 +68,7 @@ public Map<String, Object> backend(String graph) {

@SuppressWarnings("unchecked")
public Map<String, Map<String, Object>> all() {
Map<String,Object> params = new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("type", "json");
RestResult result = this.client.get(this.path(), params);
Map<?, ?> map = result.readObject(Map.class);
Expand All @@ -86,7 +86,7 @@ public String allWithPromFormat() {
}

public Map<String, Map<String, Object>> statistics() {
Map<String,Object> params = new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("type", "json");
RestResult result = this.client.get(this.path() + STATISTICS_PATH, params);
Map<?, ?> map = result.readObject(Map.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import java.util.List;
import java.util.Map;

import org.apache.hugegraph.util.TaskCache;
import org.apache.hugegraph.api.API;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.rest.ClientException;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.Task;
import org.apache.hugegraph.structure.constant.HugeType;
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.TaskCache;

import com.google.common.collect.ImmutableMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.traverser.PathsWithVertices;
import org.apache.hugegraph.structure.traverser.CustomizedPathsRequest;
import org.apache.hugegraph.structure.traverser.PathsWithVertices;

public class CustomizedPathsAPI extends TraversersAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@

package org.apache.hugegraph.api.traverser;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.hugegraph.api.graph.GraphAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.rest.RestResult;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.logging.log4j.util.Strings;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class EdgeExistenceAPI extends TraversersAPI {

public EdgeExistenceAPI(RestClient client, String graph) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@

import org.apache.hugegraph.api.graph.GraphAPI;
import org.apache.hugegraph.client.RestClient;

import org.apache.hugegraph.rest.RestResult;

import org.apache.hugegraph.structure.constant.Direction;
import org.apache.hugegraph.structure.traverser.JaccardSimilarity;
import org.apache.hugegraph.structure.traverser.SingleSourceJaccardSimilarityRequest;

import org.apache.hugegraph.util.E;

public class JaccardSimilarityAPI extends TraversersAPI {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private Step() {
this.direction = null;
this.labels = new ArrayList<>();
this.degree = Traverser.DEFAULT_MAX_DEGREE;
this.top = (int) Traverser.DEFAULT_PATHS_LIMIT;
this.top = Traverser.DEFAULT_PATHS_LIMIT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Set;

import org.apache.commons.collections.CollectionUtils;

import org.apache.hugegraph.api.auth.AccessAPI;
import org.apache.hugegraph.api.auth.BelongAPI;
import org.apache.hugegraph.api.auth.GroupAPI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package org.apache.hugegraph.driver;

import org.apache.hugegraph.api.gremlin.CypherAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.gremlin.Response;
import org.apache.hugegraph.structure.gremlin.ResultSet;
import org.apache.hugegraph.client.RestClient;

public class CypherManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import org.apache.hugegraph.annotation.UnimplementedFeature;
import org.apache.hugegraph.api.graph.EdgeAPI;
import org.apache.hugegraph.api.graph.VertexAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.exception.InvalidOperationException;
import org.apache.hugegraph.structure.GraphElement;
import org.apache.hugegraph.structure.constant.Direction;
import org.apache.hugegraph.structure.constant.T;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.graph.BatchEdgeRequest;
import org.apache.hugegraph.structure.graph.BatchOlapPropertyRequest;
import org.apache.hugegraph.structure.graph.BatchVertexRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.Map;

import org.apache.hugegraph.api.graphs.GraphsAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.constant.GraphMode;
import org.apache.hugegraph.structure.constant.GraphReadMode;
import org.apache.hugegraph.client.RestClient;

public class GraphsManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.apache.hugegraph.api.gremlin.GremlinAPI;
import org.apache.hugegraph.api.gremlin.GremlinRequest;
import org.apache.hugegraph.api.job.GremlinJobAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.gremlin.Response;
import org.apache.hugegraph.structure.gremlin.ResultSet;
import org.apache.hugegraph.client.RestClient;

public class GremlinManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import org.apache.hugegraph.api.job.RebuildAPI;
import org.apache.hugegraph.api.task.TaskAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.schema.EdgeLabel;
import org.apache.hugegraph.structure.schema.IndexLabel;
import org.apache.hugegraph.structure.schema.VertexLabel;
import org.apache.hugegraph.client.RestClient;

public class JobManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import java.util.List;
import java.util.Map;

import org.apache.hugegraph.api.task.TaskAPI;
import org.apache.hugegraph.structure.SchemaElement;
import org.apache.hugegraph.api.schema.EdgeLabelAPI;
import org.apache.hugegraph.api.schema.IndexLabelAPI;
import org.apache.hugegraph.api.schema.PropertyKeyAPI;
import org.apache.hugegraph.api.schema.SchemaAPI;
import org.apache.hugegraph.api.schema.VertexLabelAPI;
import org.apache.hugegraph.api.task.TaskAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.SchemaElement;
import org.apache.hugegraph.structure.schema.BuilderProxy;
import org.apache.hugegraph.structure.schema.EdgeLabel;
import org.apache.hugegraph.structure.schema.IndexLabel;
Expand Down Expand Up @@ -82,7 +82,7 @@ public PropertyKey addPropertyKey(PropertyKey propertyKey) {

public PropertyKey addPropertyKey(PropertyKey propertyKey, long seconds) {
PropertyKey.PropertyKeyWithTask task = this.propertyKeyAPI
.create(propertyKey);
.create(propertyKey);
if (task.taskId() != 0L) {
this.taskAPI.waitUntilTaskSuccess(task.taskId(), seconds);
}
Expand All @@ -91,7 +91,7 @@ public PropertyKey addPropertyKey(PropertyKey propertyKey, long seconds) {

public long addPropertyKeyAsync(PropertyKey propertyKey) {
PropertyKey.PropertyKeyWithTask task = this.propertyKeyAPI
.create(propertyKey);
.create(propertyKey);
return task.taskId();
}

Expand All @@ -109,7 +109,7 @@ public PropertyKey clearPropertyKey(PropertyKey propertyKey) {

public PropertyKey clearPropertyKey(PropertyKey propertyKey, long seconds) {
PropertyKey.PropertyKeyWithTask task = this.propertyKeyAPI
.clear(propertyKey);
.clear(propertyKey);
if (task.taskId() != 0L) {
this.taskAPI.waitUntilTaskSuccess(task.taskId(), seconds);
}
Expand All @@ -118,7 +118,7 @@ public PropertyKey clearPropertyKey(PropertyKey propertyKey, long seconds) {

public long clearPropertyKeyAsync(PropertyKey propertyKey) {
PropertyKey.PropertyKeyWithTask task = this.propertyKeyAPI
.clear(propertyKey);
.clear(propertyKey);
return task.taskId();
}

Expand Down Expand Up @@ -228,7 +228,7 @@ public IndexLabel addIndexLabel(IndexLabel indexLabel) {

public IndexLabel addIndexLabel(IndexLabel indexLabel, long seconds) {
IndexLabel.IndexLabelWithTask cil = this.indexLabelAPI
.create(indexLabel);
.create(indexLabel);
if (cil.taskId() != 0L) {
this.taskAPI.waitUntilTaskSuccess(cil.taskId(), seconds);
}
Expand All @@ -237,7 +237,7 @@ public IndexLabel addIndexLabel(IndexLabel indexLabel, long seconds) {

public long addIndexLabelAsync(IndexLabel indexLabel) {
IndexLabel.IndexLabelWithTask cil = this.indexLabelAPI
.create(indexLabel);
.create(indexLabel);
return cil.taskId();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import org.apache.hugegraph.api.task.TaskAPI;
import org.apache.hugegraph.api.task.TasksWithPage;
import org.apache.hugegraph.structure.Task;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.Task;

public class TaskManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hugegraph.api.traverser.CrosspointsAPI;
import org.apache.hugegraph.api.traverser.CustomizedCrosspointsAPI;
import org.apache.hugegraph.api.traverser.CustomizedPathsAPI;
import org.apache.hugegraph.api.traverser.EdgeExistenceAPI;
import org.apache.hugegraph.api.traverser.EdgesAPI;
import org.apache.hugegraph.api.traverser.FusiformSimilarityAPI;
import org.apache.hugegraph.api.traverser.JaccardSimilarityAPI;
Expand All @@ -42,7 +43,6 @@
import org.apache.hugegraph.api.traverser.TemplatePathsAPI;
import org.apache.hugegraph.api.traverser.VerticesAPI;
import org.apache.hugegraph.api.traverser.WeightedShortestPathAPI;
import org.apache.hugegraph.api.traverser.EdgeExistenceAPI;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.constant.Direction;
import org.apache.hugegraph.structure.constant.Traverser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package org.apache.hugegraph.driver;

import java.util.Map;

import org.apache.hugegraph.api.variables.VariablesAPI;
import org.apache.hugegraph.client.RestClient;

import java.util.Map;

public class VariablesManager {

private VariablesAPI variablesAPI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.apache.hugegraph.driver;

import org.apache.hugegraph.api.version.VersionAPI;
import org.apache.hugegraph.structure.version.Versions;
import org.apache.hugegraph.client.RestClient;
import org.apache.hugegraph.structure.version.Versions;

public class VersionManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Vertex;
import org.apache.hugegraph.driver.GraphManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.driver.SchemaManager;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Vertex;

public class BatchExample {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package org.apache.hugegraph.example;

import org.apache.hugegraph.structure.constant.T;
import org.apache.hugegraph.structure.graph.Vertex;
import org.apache.hugegraph.driver.GraphManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.driver.SchemaManager;
import org.apache.hugegraph.structure.constant.T;
import org.apache.hugegraph.structure.graph.Vertex;

public class MovieExample {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
import java.util.Iterator;
import java.util.List;

import org.apache.hugegraph.driver.GraphManager;
import org.apache.hugegraph.driver.GremlinManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.driver.SchemaManager;
import org.apache.hugegraph.structure.constant.T;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Path;
import org.apache.hugegraph.structure.graph.Vertex;
import org.apache.hugegraph.structure.gremlin.Result;
import org.apache.hugegraph.structure.gremlin.ResultSet;
import org.apache.hugegraph.driver.GraphManager;
import org.apache.hugegraph.driver.GremlinManager;
import org.apache.hugegraph.driver.HugeClient;
import org.apache.hugegraph.driver.SchemaManager;

public class SingleExample {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class PathDeserializer extends JsonDeserializer<Path> {

@Override
public Path deserialize(JsonParser parser, DeserializationContext ctxt)
throws IOException {
throws IOException {

JsonNode node = parser.getCodec().readTree(parser);
Path path = new Path();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public byte[] getKeyBytes(GraphElement e) {
byte[] array = null;
if (e.type() == "vertex" && e.id() != null) {
BytesBuffer buffer = BytesBuffer.allocate(2 + 1 + e.id().toString().length());
buffer.writeShort(getPartition(HugeType.VERTEX, IdGenerator.of(e.id())));
buffer.writeShort(getPartition(HugeType.VERTEX, IdGenerator.of(e.id())));

Check warning on line 54 in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java#L54

Added line #L54 was not covered by tests
buffer.writeId(IdGenerator.of(e.id()));
array = buffer.bytes();
} else if (e.type() == "edge") {
BytesBuffer buffer = BytesBuffer.allocate(BytesBuffer.BUF_EDGE_ID);
Edge edge = (Edge)e;
Edge edge = (Edge) e;

Check warning on line 59 in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java#L59

Added line #L59 was not covered by tests
buffer.writeShort(getPartition(HugeType.EDGE, IdGenerator.of(edge.sourceId())));
buffer.writeId(IdGenerator.of(edge.sourceId()));
buffer.write(HugeType.EDGE_OUT.code());
Expand All @@ -78,17 +78,17 @@ public byte[] getValueBytes(GraphElement e) {
for (Map.Entry<String, Object> entry : e.properties().entrySet()) {
PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey());
buffer.writeVInt(propertyKey.id().intValue());
buffer.writeProperty(propertyKey.dataType(),entry.getValue());
buffer.writeProperty(propertyKey.dataType(), entry.getValue());

Check warning on line 81 in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java#L81

Added line #L81 was not covered by tests
}
array = buffer.bytes();
} else if (e.type() == "edge") {
int propsCount = e.properties().size();
int propsCount = e.properties().size();

Check warning on line 85 in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java#L85

Added line #L85 was not covered by tests
BytesBuffer buffer = BytesBuffer.allocate(4 + 16 * propsCount);
buffer.writeVInt(propsCount);
for (Map.Entry<String, Object> entry : e.properties().entrySet()) {
PropertyKey propertyKey = graphSchema.getPropertyKey(entry.getKey());
buffer.writeVInt(propertyKey.id().intValue());
buffer.writeProperty(propertyKey.dataType(),entry.getValue());
buffer.writeProperty(propertyKey.dataType(), entry.getValue());

Check warning on line 91 in hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-client/src/main/java/org/apache/hugegraph/serializer/direct/HBaseSerializer.java#L91

Added line #L91 was not covered by tests
}
array = buffer.bytes();
}
Expand Down
Loading

0 comments on commit 1fcc380

Please sign in to comment.