You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by co...@apache.org on 2023/08/31 20:03:57 UTC

[tinkerpop] branch 3.6-dev updated: TINKERPOP-2986: [StarGraph] Drop edge properties when dropping edges (#2212)

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

colegreer pushed a commit to branch 3.6-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.6-dev by this push:
     new 73d684045c TINKERPOP-2986: [StarGraph] Drop edge properties when dropping edges (#2212)
73d684045c is described below

commit 73d684045c614e84821d8fece7190dc065d155ec
Author: Boxuan Li <li...@connect.hku.hk>
AuthorDate: Thu Aug 31 13:03:51 2023 -0700

    TINKERPOP-2986: [StarGraph] Drop edge properties when dropping edges (#2212)
    
    SparkGraphComputer uses StarGraph to represent an in-memory graph. EdgeFilter can
    be configured by users to drop unneeded edges, but the edge properties aren't dropped.
    This fixes this bug and greatly reduces memory footprint.
---
 .../tinkerpop/gremlin/structure/util/star/StarGraph.java       | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index 0c47d78caa..9b3de0bd34 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -360,12 +360,20 @@ public final class StarGraph implements Graph, Serializable {
             super(id, label);
         }
 
+        private void dropEdgeProperty(Object id) {
+            if (edgeProperties != null) {
+                edgeProperties.remove(id);
+            }
+        }
+
         public void dropEdges(final Direction direction) {
             if ((direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) && null != this.outEdges) {
+                this.outEdges.values().forEach(edges -> edges.forEach(edge -> dropEdgeProperty(edge.id())));
                 this.outEdges.clear();
                 this.outEdges = null;
             }
             if ((direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) && null != this.inEdges) {
+                this.inEdges.values().forEach(edges -> edges.forEach(edge -> dropEdgeProperty(edge.id())));
                 this.inEdges.clear();
                 this.inEdges = null;
             }
@@ -373,12 +381,14 @@ public final class StarGraph implements Graph, Serializable {
 
         public void dropEdges(final Direction direction, final String edgeLabel) {
             if (null != this.outEdges && (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH))) {
+                this.outEdges.get(edgeLabel).forEach(edge -> dropEdgeProperty(edge.id()));
                 this.outEdges.remove(edgeLabel);
 
                 if (this.outEdges.isEmpty())
                     this.outEdges = null;
             }
             if (null != this.inEdges && (direction.equals(Direction.IN) || direction.equals(Direction.BOTH))) {
+                this.inEdges.get(edgeLabel).forEach(edge -> dropEdgeProperty(edge.id()));
                 this.inEdges.remove(edgeLabel);
 
                 if (this.inEdges.isEmpty())