This is an automated email from the ASF dual-hosted git repository.
vgalaxies pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-hugegraph-toolchain.git
The following commit(s) were added to refs/heads/master by this push:
new 1bd2ea0c fix(client): serialize source and target label for non-father
edge label (#628)
1bd2ea0c is described below
commit 1bd2ea0c1caf0c7eac393f0e41dcfb03b53326df
Author: John <[email protected]>
AuthorDate: Tue Oct 22 16:37:37 2024 +0800
fix(client): serialize source and target label for non-father edge label
(#628)
Co-authored-by: imbajin <[email protected]>
---
.../structure/constant/EdgeLabelType.java | 4 +-
.../hugegraph/structure/schema/EdgeLabel.java | 65 +++++++++-------------
2 files changed, 28 insertions(+), 41 deletions(-)
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/constant/EdgeLabelType.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/constant/EdgeLabelType.java
index 34db91d4..befc7cf8 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/constant/EdgeLabelType.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/constant/EdgeLabelType.java
@@ -25,8 +25,8 @@ public enum EdgeLabelType {
SUB(2, "SUB");
- private byte code = 0;
- private String name = null;
+ private final byte code;
+ private final String name;
EdgeLabelType(int code, String name) {
assert code < 256;
diff --git
a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java
b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java
index b2746ada..1ef60037 100644
---
a/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java
+++
b/hugegraph-client/src/main/java/org/apache/hugegraph/structure/schema/EdgeLabel.java
@@ -43,6 +43,10 @@ public class EdgeLabel extends SchemaLabel {
private String parentLabel;
@JsonProperty("frequency")
private Frequency frequency;
+ @JsonProperty("source_label")
+ private String sourceLabel;
+ @JsonProperty("target_label")
+ private String targetLabel;
@JsonProperty("links")
private Set<Map<String, String>> links;
@JsonProperty("sort_keys")
@@ -56,6 +60,8 @@ public class EdgeLabel extends SchemaLabel {
public EdgeLabel(@JsonProperty("name") String name) {
super(name);
this.frequency = Frequency.DEFAULT;
+ this.sourceLabel = null;
+ this.targetLabel = null;
this.links = new HashSet<>();
this.sortKeys = new CopyOnWriteArrayList<>();
this.ttl = 0L;
@@ -108,7 +114,7 @@ public class EdgeLabel extends SchemaLabel {
public boolean linkedVertexLabel(String vertexLabel) {
if (this.edgeLabelType.parent() || this.links == null ||
- this.links.isEmpty()) {
+ this.links.isEmpty()) {
return false;
}
@@ -136,15 +142,14 @@ public class EdgeLabel extends SchemaLabel {
@Override
public String toString() {
- return String.format("{name=%s, " + "edgeLabel_type=%s, " +
"parent_label=%s" +
- "links=%s, sortKeys=%s, indexLabels=%s, " +
- "nullableKeys=%s, properties=%s, ttl=%s, " +
- "ttlStartTime=%s, status=%s}",
- this.name,
- this.edgeLabelType, this.parentLabel,
- this.links, this.sortKeys, this.indexLabels,
- this.nullableKeys, this.properties, this.ttl,
- this.ttlStartTime, this.status);
+ return String.format("{name=%s, sourceLabel=%s, targetLabel=%s, " +
"edgeLabel_type=%s, " +
+ "parent_label=%s, links=%s, sortKeys=%s,
indexLabels=%s, " +
+ "nullableKeys=%s, properties=%s, ttl=%s,
ttlStartTime=%s, status=%s}",
+ this.name, this.sourceLabel(), this.targetLabel(),
+ this.edgeLabelType, this.parentLabel,
+ this.links, this.sortKeys, this.indexLabels,
+ this.nullableKeys, this.properties, this.ttl,
+ this.ttlStartTime, this.status);
}
public EdgeLabelV53 switchV53() {
@@ -167,18 +172,12 @@ public class EdgeLabel extends SchemaLabel {
/**
* Set the source label of the edge label
- *
- * @deprecated Suggested use {@link #link(String, String)} to set the
source and target label pair
*/
- @Deprecated
Builder sourceLabel(String label);
/**
* Set the target label of the edge label
- *
- * @deprecated Suggested use {@link #link(String, String)} to set the
source and target label pair
*/
- @Deprecated
Builder targetLabel(String label);
Builder frequency(Frequency frequency);
@@ -202,13 +201,9 @@ public class EdgeLabel extends SchemaLabel {
private final EdgeLabel edgeLabel;
private final SchemaManager manager;
- private String sourceLabel;
- private String targetLabel;
public BuilderImpl(String name, SchemaManager manager) {
this.edgeLabel = new EdgeLabel(name);
- this.sourceLabel = null;
- this.targetLabel = null;
this.manager = manager;
}
@@ -246,10 +241,10 @@ public class EdgeLabel extends SchemaLabel {
@Override
public Builder sortKeys(String... keys) {
E.checkArgument(this.edgeLabel.sortKeys.isEmpty(),
- "Not allowed to assign sort keys multi times");
+ "Not allowed to assign sort keys multi times");
List<String> sortKeys = Arrays.asList(keys);
E.checkArgument(CollectionUtil.allUnique(sortKeys),
- "Invalid sort keys %s, which contains some " +
+ "Invalid sort keys %s, which contains some " +
"duplicate properties", sortKeys);
this.edgeLabel.sortKeys.addAll(sortKeys);
return this;
@@ -266,8 +261,6 @@ public class EdgeLabel extends SchemaLabel {
HashMap<String, String> map = new HashMap<>();
map.put(sourceLabel, targetLabel);
this.edgeLabel.links.add(map);
- this.sourceLabel = null;
- this.targetLabel = null;
return this;
}
@@ -286,40 +279,34 @@ public class EdgeLabel extends SchemaLabel {
/**
* Set the source label of the edge label
- *
- * @deprecated Suggested use {@link #link(String, String)} to set the
source and target label pair
*/
- @Deprecated
@Override
public Builder sourceLabel(String label) {
E.checkArgument(this.edgeLabel.links.isEmpty(),
- "Not allowed add source label to an edge label which " +
+ "Not allowed add source label to an edge label
which " +
"already has links");
- if (this.targetLabel != null) {
- link(label, this.targetLabel);
- this.targetLabel = null;
+ if (this.edgeLabel.targetLabel != null) {
+ link(label, this.edgeLabel.targetLabel);
+ this.edgeLabel.targetLabel = null;
} else {
- this.sourceLabel = label;
+ this.edgeLabel.sourceLabel = label;
}
return this;
}
/**
* Set the target label of the edge label
- *
- * @deprecated Suggested use {@link #link(String, String)} to set the
source and target label pair
*/
- @Deprecated
@Override
public Builder targetLabel(String label) {
E.checkArgument(this.edgeLabel.links.isEmpty(),
"Not allowed add source label to an edge label " +
"which already has links");
- if (this.sourceLabel != null) {
- link(this.sourceLabel, label);
- this.sourceLabel = null;
+ if (this.edgeLabel.sourceLabel != null) {
+ link(this.edgeLabel.sourceLabel, label);
+ this.edgeLabel.sourceLabel = null;
} else {
- this.targetLabel = label;
+ this.edgeLabel.targetLabel = label;
}
return this;
}