Skip to content

Commit

Permalink
adapt the latest version & clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
imbajin committed Nov 1, 2022
1 parent 4f60381 commit 62f7290
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@

import java.util.Map;

import javax.inject.Singleton;
import javax.ws.rs.Consumes;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import org.slf4j.Logger;

import com.baidu.hugegraph.HugeGraph;
Expand All @@ -46,6 +37,15 @@
import com.codahale.metrics.annotation.Timed;
import com.google.common.collect.ImmutableMap;

import jakarta.inject.Singleton;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;

@Path("graphs/{graph}/jobs/algorithm")
@Singleton
public class AlgorithmAPI extends API {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.JsonUtil;
import com.baidu.hugegraph.util.ParameterUtil;

import jersey.repackaged.com.google.common.base.Objects;
import com.google.common.base.Objects;

@SuppressWarnings("deprecation") // StringEscapeUtils
public abstract class AbstractAlgorithm implements Algorithm {
Expand Down Expand Up @@ -382,9 +381,7 @@ protected Iterator<Vertex> vertices(Object label, long limit) {
ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
query.capacity(Query.NO_CAPACITY);
query.limit(limit);
if (label != null) {
query.eq(HugeKeys.LABEL, this.getVertexLabelId(label));
}
query.eq(HugeKeys.LABEL, this.getVertexLabelId(label));
return this.graph().vertices(query);
}

Expand Down Expand Up @@ -544,8 +541,8 @@ public JsonMap() {
this(4 * (int) Bytes.KB);
}

public JsonMap(int initCapaticy) {
this.json = new StringBuilder(initCapaticy);
public JsonMap(int initCapacity) {
this.json = new StringBuilder(initCapacity);
}

public void startObject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Iterator;
import java.util.Map;

import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.slf4j.Logger;
Expand Down Expand Up @@ -90,7 +90,6 @@ private HugeGraph createTempGraph(UserJob<Object> job) {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty(CoreOptions.BACKEND.name(), "memory");
config.setProperty(CoreOptions.STORE.name(), name);
config.setDelimiterParsingDisabled(true);
/*
* NOTE: this temp graph don't need to init backend because no task info
* required, also not set started because no task to be scheduled.
Expand Down Expand Up @@ -129,12 +128,11 @@ protected static boolean copySchema(Map<String, Object> parameters) {

private static class Traverser extends AlgoTraverser {

private static Map<String, Object> PARAMS = ImmutableMap.of(
"depth", 10L,
"degree", -1L,
"sample", -1L,
"top", -1L /* sorted */,
"workers", 0);
private static final Map<String, Object> PARAMS = ImmutableMap.of("depth", 10L,
"degree", -1L,
"sample", -1L,
"top", -1L /* sorted */,
"workers", 0);

public Traverser(UserJob<Object> job) {
super(job);
Expand Down

0 comments on commit 62f7290

Please sign in to comment.