6 package com.vesoft.nebula.client.graph.data;
8 import com.vesoft.nebula.Edge;
9 import com.vesoft.nebula.Value;
10 import java.io.UnsupportedEncodingException;
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
15 import java.util.Objects;
18 private final Edge edge;
26 throw new RuntimeException(
"Input an null edge object");
37 return edge.type > 0 ?
new ValueWrapper(edge.src, getDecodeType(), getTimezoneOffset())
38 :
new ValueWrapper(edge.dst, getDecodeType(), getTimezoneOffset());
47 return edge.type > 0 ?
new ValueWrapper(edge.dst, getDecodeType(), getTimezoneOffset())
48 :
new ValueWrapper(edge.src, getDecodeType(), getTimezoneOffset());
56 return new String(edge.name);
72 public List<String>
keys() throws UnsupportedEncodingException {
73 List<String> propNames =
new ArrayList<>();
74 for (
byte[] name : edge.props.keySet()) {
75 propNames.add(
new String(name, getDecodeType()));
85 List<ValueWrapper> propVals =
new ArrayList<>();
86 for (Value val : edge.props.values()) {
87 propVals.add(
new ValueWrapper(val, getDecodeType(), getTimezoneOffset()));
96 public HashMap<String, ValueWrapper>
properties() throws UnsupportedEncodingException {
97 HashMap<String, ValueWrapper>
properties =
new HashMap<>();
98 for (
byte[] key : edge.props.keySet()) {
99 properties.put(
new String(key, getDecodeType()),
100 new ValueWrapper(edge.props.get(key), getDecodeType(), getTimezoneOffset()));
106 public boolean equals(Object o) {
110 if (o ==
null || getClass() != o.getClass()) {
114 return ranking() == that.ranking()
115 && Objects.equals(
srcId(), that.srcId())
116 && Objects.equals(
dstId(), that.dstId())
117 && Objects.equals(
edgeName(), that.edgeName());
121 public int hashCode() {
122 return Objects.hash(edge, getDecodeType(), getTimezoneOffset());
126 public String toString() {
128 List<String> propStrs =
new ArrayList<>();
129 Map<String, ValueWrapper> props =
properties();
130 for (String key : props.keySet()) {
131 propStrs.add(key +
": " + props.get(key).toString());
133 return String.format(
"(%s)-[:%s@%d{%s}]->(%s)",
135 }
catch (UnsupportedEncodingException e) {
136 return e.getMessage();
List< ValueWrapper > values()
get property values from the relationship
ValueWrapper dstId()
get the dst id from the relationship
List< String > keys()
get all property name from the relationship
Relationship(Edge edge)
Relationship is a wrapper around the Edge type returned by nebula-graph.
long ranking()
get ranking from the relationship
HashMap< String, ValueWrapper > properties()
get property names and values from the relationship
String edgeName()
get edge name from the relationship
ValueWrapper srcId()
get the src id from the relationship