-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support null value for gremlin test #2061
Changes from all commits
2cf8981
e68b4d1
ef0c949
deefd9d
2987c12
87108b4
dcd846b
ebaa542
cba6559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,14 @@ | |
import org.apache.hugegraph.backend.serializer.BytesBuffer; | ||
import org.apache.hugegraph.perf.PerfUtil.Watched; | ||
import org.apache.hugegraph.util.E; | ||
import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyProperty; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
public class HugeEdge extends HugeElement implements Edge, Cloneable { | ||
|
||
private Id id; | ||
private EdgeLabel label; | ||
private final EdgeLabel label; | ||
private String name; | ||
|
||
private HugeVertex sourceVertex; | ||
|
@@ -200,6 +202,11 @@ public <V> Property<V> property(String key, V value) { | |
E.checkArgument(this.label.properties().contains(propertyKey.id()), | ||
"Invalid property '%s' for edge label '%s'", | ||
key, this.label()); | ||
if (value == null) { | ||
imbajin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.removeProperty(propertyKey.id()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if remove null value's property, may cause tinkerpop ut failed ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow the tinkerpop ci action tests with release-1.0.0 |
||
return EmptyProperty.instance(); | ||
} | ||
|
||
// Sort-Keys can only be set once | ||
if (this.schemaLabel().sortKeys().contains(propertyKey.id())) { | ||
E.checkArgument(!this.hasProperty(propertyKey.id()), | ||
|
@@ -279,7 +286,7 @@ public <V> Iterator<Property<V>> properties(String... keys) { | |
|
||
if (keys.length == 0) { | ||
for (HugeProperty<?> prop : this.getProperties()) { | ||
assert prop instanceof Property; | ||
assert prop != null; | ||
props.add((Property<V>) prop); | ||
} | ||
} else { | ||
|
@@ -295,7 +302,6 @@ public <V> Iterator<Property<V>> properties(String... keys) { | |
// Not found | ||
continue; | ||
} | ||
assert prop instanceof Property; | ||
props.add((Property<V>) prop); | ||
} | ||
} | ||
|
@@ -320,8 +326,7 @@ public Object sysprop(HugeKeys key) { | |
case PROPERTIES: | ||
return this.getPropertiesMap(); | ||
default: | ||
E.checkArgument(false, | ||
"Invalid system property '%s' of Edge", key); | ||
E.checkArgument(false, "Invalid system property '%s' of Edge", key); | ||
return null; | ||
} | ||
} | ||
|
@@ -362,6 +367,7 @@ public void vertices(HugeVertex owner, HugeVertex other) { | |
if (ownerLabel.equals(this.label.sourceLabel())) { | ||
this.vertices(true, owner, other); | ||
} else { | ||
// TODO: why compare the label but ignore the result? | ||
ownerLabel.equals(this.label.targetLabel()); | ||
this.vertices(false, owner, other); | ||
} | ||
|
@@ -515,8 +521,7 @@ public static HugeEdge constructEdge(HugeVertex ownerVertex, | |
ownerVertex.correctVertexLabel(tgtLabel); | ||
otherVertexLabel = srcLabel; | ||
} | ||
HugeVertex otherVertex = new HugeVertex(graph, otherVertexId, | ||
otherVertexLabel); | ||
HugeVertex otherVertex = new HugeVertex(graph, otherVertexId, otherVertexLabel); | ||
|
||
ownerVertex.propNotLoaded(); | ||
otherVertex.propNotLoaded(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,14 +31,19 @@ | |
import org.apache.hugegraph.backend.id.EdgeId; | ||
import org.apache.hugegraph.backend.id.Id; | ||
import org.apache.hugegraph.backend.id.IdGenerator; | ||
import org.apache.hugegraph.backend.serializer.BytesBuffer; | ||
import org.apache.hugegraph.backend.tx.GraphTransaction; | ||
import org.apache.hugegraph.perf.PerfUtil.Watched; | ||
import org.apache.hugegraph.schema.PropertyKey; | ||
import org.apache.hugegraph.schema.SchemaLabel; | ||
import org.apache.hugegraph.schema.VertexLabel; | ||
import org.apache.hugegraph.type.HugeType; | ||
import org.apache.hugegraph.type.Idfiable; | ||
import org.apache.hugegraph.type.define.Cardinality; | ||
import org.apache.hugegraph.type.define.HugeKeys; | ||
import org.apache.hugegraph.util.CollectionUtil; | ||
import org.apache.hugegraph.util.E; | ||
import org.apache.hugegraph.util.InsertionOrderUtil; | ||
import org.apache.hugegraph.util.collection.CollectionFactory; | ||
import org.apache.tinkerpop.gremlin.structure.Element; | ||
import org.apache.tinkerpop.gremlin.structure.Property; | ||
|
@@ -47,12 +52,6 @@ | |
import org.eclipse.collections.api.iterator.IntIterator; | ||
import org.eclipse.collections.api.map.primitive.MutableIntObjectMap; | ||
|
||
import org.apache.hugegraph.backend.serializer.BytesBuffer; | ||
import org.apache.hugegraph.perf.PerfUtil.Watched; | ||
import org.apache.hugegraph.util.CollectionUtil; | ||
import org.apache.hugegraph.util.E; | ||
import org.apache.hugegraph.util.InsertionOrderUtil; | ||
|
||
public abstract class HugeElement implements Element, GraphType, Idfiable { | ||
|
||
private static final MutableIntObjectMap<HugeProperty<?>> EMPTY_MAP = | ||
|
@@ -61,8 +60,8 @@ public abstract class HugeElement implements Element, GraphType, Idfiable { | |
|
||
private final HugeGraph graph; | ||
private MutableIntObjectMap<HugeProperty<?>> properties; | ||
|
||
private long expiredTime; // TODO: move into properties to keep small object | ||
// TODO: move into properties to keep small object | ||
private long expiredTime; | ||
|
||
private boolean removed; | ||
private boolean fresh; | ||
|
@@ -425,14 +424,14 @@ public static final ElementKeys classifyKeys(Object... keyValues) { | |
Object val = keyValues[i + 1]; | ||
|
||
if (!(key instanceof String) && !(key instanceof T)) { | ||
throw Element.Exceptions | ||
.providedKeyValuesMustHaveALegalKeyOnEvenIndices(); | ||
throw Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices(); | ||
} | ||
if (val == null) { | ||
if (key.equals(T.label)) { | ||
if (T.label.equals(key)) { | ||
throw Element.Exceptions.labelCanNotBeNull(); | ||
} | ||
throw Property.Exceptions.propertyDoesNotExist(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems need to skip the null value here with |
||
// Ignore null value for tinkerpop test compatibility | ||
continue; | ||
} | ||
imbajin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (key.equals(T.id)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also update
HugeVertex.property(String key, V value)