This is an automated email from the ASF dual-hosted git repository.

jin pushed a commit to branch release-1.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit e9eb8240d1830e9bd21bdf379718926a747c6a08
Author: imbajin <[email protected]>
AuthorDate: Fri Dec 30 11:32:43 2022 +0800

    fix: support null value for gremlin test
---
 .github/workflows/stale.yml                        |  4 ++--
 .../org/apache/hugegraph/schema/PropertyKey.java   |  2 +-
 .../org/apache/hugegraph/structure/HugeEdge.java   | 19 ++++++++++------
 .../apache/hugegraph/structure/HugeElement.java    | 25 +++++++++++++---------
 .../apache/hugegraph/structure/HugeProperty.java   |  3 +--
 5 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index 9f428d122..dc8a70408 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -20,8 +20,8 @@ jobs:
         stale-pr-message: 'Due to the lack of activity, the current pr is 
marked as stale and will be closed after 180 days, any update will remove the 
stale label'
         stale-issue-label: 'inactive'
         stale-pr-label: 'inactive'
-        exempt-issue-labels: 
'feature,bug,enhancement,improvement,wontfix,todo,guide,doc,help wanted'
-        exempt-pr-labels: 
'feature,bug,enhancement,improvement,wontfix,todo,guide,doc,help wanted'
+        exempt-issue-labels: 
'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
+        exempt-pr-labels: 
'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
         exempt-all-milestones: true
 
         days-before-issue-stale: 15
diff --git 
a/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java 
b/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java
index e397af2b0..d81cb79a4 100644
--- a/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java
+++ b/hugegraph-core/src/main/java/org/apache/hugegraph/schema/PropertyKey.java
@@ -230,7 +230,7 @@ public class PropertyKey extends SchemaElement implements 
Propertiable {
     }
 
     /**
-     * Check type of all the values(may be some of list properties) valid
+     * Check type of all the values(maybe some list properties) valid
      * @param values the property values to be checked data type
      * @param <V> the property value class
      * @return true if all the values are or can convert to the data type,
diff --git 
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java 
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java
index daa091202..8bfa67f2f 100644
--- a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java
+++ b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java
@@ -47,12 +47,14 @@ import 
org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 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;
@@ -202,6 +204,11 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
         E.checkArgument(this.label.properties().contains(propertyKey.id()),
                         "Invalid property '%s' for edge label '%s'",
                         key, this.label());
+        if (value == null) {
+            this.removeProperty(propertyKey.id());
+            return EmptyProperty.instance();
+        }
+
         // Sort-Keys can only be set once
         if (this.schemaLabel().sortKeys().contains(propertyKey.id())) {
             E.checkArgument(!this.hasProperty(propertyKey.id()),
@@ -281,7 +288,7 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
 
         if (keys.length == 0) {
             for (HugeProperty<?> prop : this.getProperties()) {
-                assert prop instanceof Property;
+                assert prop != null;
                 props.add((Property<V>) prop);
             }
         } else {
@@ -297,7 +304,6 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
                     // Not found
                     continue;
                 }
-                assert prop instanceof Property;
                 props.add((Property<V>) prop);
             }
         }
@@ -322,8 +328,7 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
             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;
         }
     }
@@ -364,6 +369,7 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
         if (ownerLabel.equals(this.label.sourceLabel())) {
             this.vertices(true, owner, other);
         } else {
+            // TODO: why when compare the label but ignore the result?
             ownerLabel.equals(this.label.targetLabel());
             this.vertices(false, owner, other);
         }
@@ -517,8 +523,7 @@ public class HugeEdge extends HugeElement implements Edge, 
Cloneable {
             ownerVertex.correctVertexLabel(tgtLabel);
             otherVertexLabel = srcLabel;
         }
-        HugeVertex otherVertex = new HugeVertex(graph, otherVertexId,
-                                                otherVertexLabel);
+        HugeVertex otherVertex = new HugeVertex(graph, otherVertexId, 
otherVertexLabel);
 
         ownerVertex.propNotLoaded();
         otherVertex.propNotLoaded();
diff --git 
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java 
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
index 3e5d56ca0..5d5cca741 100644
--- 
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
+++ 
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java
@@ -33,7 +33,9 @@ import org.apache.hugegraph.HugeGraph;
 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;
@@ -41,6 +43,9 @@ 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;
@@ -49,12 +54,6 @@ import 
org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 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 =
@@ -63,8 +62,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;
@@ -427,8 +426,14 @@ public abstract class HugeElement implements Element, 
GraphType, Idfiable {
             Object val = keyValues[i + 1];
 
             if (!(key instanceof String) && !(key instanceof T)) {
-                throw Element.Exceptions
-                      .providedKeyValuesMustHaveALegalKeyOnEvenIndices();
+                throw 
Element.Exceptions.providedKeyValuesMustHaveALegalKeyOnEvenIndices();
+            }
+            if (val == null) {
+                if (T.label.equals(key)) {
+                    throw Element.Exceptions.labelCanNotBeNull();
+                }
+                // Ignore null value for tinkerpop test compatibility
+                continue;
             }
             if (val == null) {
                 throw Property.Exceptions.propertyDoesNotExist();
diff --git 
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeProperty.java 
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeProperty.java
index 829efb3ba..39549cebb 100644
--- 
a/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeProperty.java
+++ 
b/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeProperty.java
@@ -51,8 +51,7 @@ public abstract class HugeProperty<V> implements Property<V>, 
GraphType {
     }
 
     public Object id() {
-        return SplicingIdGenerator.concat(this.owner.id().asString(),
-                                          this.key());
+        return SplicingIdGenerator.concat(this.owner.id().asString(), 
this.key());
     }
 
     @Override

Reply via email to