Skip to content

Commit

Permalink
Let VertexAPI use simplified property serializer
Browse files Browse the repository at this point in the history
Implement #307

Change-Id: I7e47b75160ff240157aec30c1e9b4690a3412e4e
  • Loading branch information
Linary committed Mar 11, 2019
1 parent 1a059fa commit 9fb71f8
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 86 deletions.
17 changes: 1 addition & 16 deletions hugegraph-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jersey2</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-json</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -101,7 +86,7 @@
</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>0.33.0.0</Implementation-Version>
<Implementation-Version>0.34.0.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,46 @@ private static class GremlinRequest implements Checkable {
@JsonProperty
private Map<String, String> aliases = new HashMap<>();

public void aliase(String key, String value) {
this.aliases.put(key, value);
public String gremlin() {
return this.gremlin;
}

public void binding(String name, Object value) {
this.bindings.put(name, value);
public void gremlin(String gremlin) {
this.gremlin = gremlin;
}

public Map<String, Object> bindings() {
return this.bindings;
}

public void bindings(Map<String, Object> bindings) {
this.bindings = bindings;
}

public void binding(String name, Object value) {
this.bindings.put(name, value);
}

public String language() {
return this.language;
}

public String gremlin() {
return this.gremlin;
public void language(String language) {
this.language = language;
}

public Map<String, String> aliases() {
return this.aliases;
}

public void aliases(Map<String, String> aliases) {
this.aliases = aliases;
}

public void aliase(String key, String value) {
this.aliases.put(key, value);
}

public String name() {
// Get the first line of script as the name
String firstLine = this.gremlin.split("\r\n|\r|\n", 2)[0];
Expand Down Expand Up @@ -236,11 +252,30 @@ public void checkCreate(boolean isBatch) {
}

public String toJson() {
return JsonUtil.toJson(this);
Map<String, Object> map = new HashMap<>();
map.put("gremlin", this.gremlin);
map.put("bindings", this.bindings);
map.put("language", this.language);
map.put("aliases", this.aliases);
return JsonUtil.toJson(map);
}

public static GremlinRequest fromJson(String json) {
return JsonUtil.fromJson(json, GremlinRequest.class);
@SuppressWarnings("unchecked")
Map<String, Object> map = JsonUtil.fromJson(json, Map.class);
String gremlin = (String) map.get("gremlin");
@SuppressWarnings("unchecked")
Map<String, Object> bindings = (Map<String, Object>) map.get("bindings");
String language = (String) map.get("language");
@SuppressWarnings("unchecked")
Map<String, String> aliases = (Map<String, String>) map.get("aliases");

GremlinRequest request = new GremlinRequest();
request.gremlin(gremlin);
request.bindings(bindings);
request.language(language);
request.aliases(aliases);
return request;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
import com.baidu.hugegraph.backend.store.BackendMetrics;
import com.baidu.hugegraph.backend.tx.GraphTransaction;
import com.baidu.hugegraph.core.GraphManager;
import com.baidu.hugegraph.metric.MetricsModule;
import com.baidu.hugegraph.metric.ServerReporter;
import com.baidu.hugegraph.metric.SystemMetrics;
import com.baidu.hugegraph.util.InsertionOrderUtil;
import com.baidu.hugegraph.util.JsonUtil;
import com.baidu.hugegraph.util.Log;
import com.codahale.metrics.Metric;
import com.codahale.metrics.annotation.Timed;
import com.codahale.metrics.json.MetricsModule;

@Singleton
@Path("metrics")
Expand Down
Loading

0 comments on commit 9fb71f8

Please sign in to comment.