Skip to content

Commit

Permalink
align source_label and target_label to server
Browse files Browse the repository at this point in the history
  • Loading branch information
Thespica committed Oct 20, 2024
1 parent e94ba55 commit cc14145
Showing 1 changed file with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class EdgeLabel extends SchemaLabel {
public EdgeLabel(@JsonProperty("name") String name) {
super(name);
this.frequency = Frequency.DEFAULT;
sourceLabel = null;
targetLabel = null;
this.links = new HashSet<>();
this.sortKeys = new CopyOnWriteArrayList<>();
this.ttl = 0L;
Expand Down Expand Up @@ -200,13 +202,9 @@ public static class BuilderImpl implements Builder {

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;
}

Expand Down Expand Up @@ -264,8 +262,6 @@ public Builder link(String sourceLabel, String targetLabel) {
HashMap<String, String> map = new HashMap<>();
map.put(sourceLabel, targetLabel);
this.edgeLabel.links.add(map);
this.sourceLabel = null;
this.targetLabel = null;
return this;
}

Expand All @@ -290,11 +286,11 @@ public Builder sourceLabel(String label) {
E.checkArgument(this.edgeLabel.links.isEmpty(),
"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;
}
Expand All @@ -307,11 +303,11 @@ 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;
}
Expand Down

0 comments on commit cc14145

Please sign in to comment.