简体   繁体   中英

How to drop a subgraph in Tinkerpop (OrientDB) gremlin query?

Requirement is to drop this subgraph if I have runId and appId . Application can have multiple such appId and thus should be deleted only if no appId is attached to it.

I have tried the below query to drop the subgraph, but only IO and appRun gets dropped. The iRecord & oRecord don't get dropped. Is this because I loose the gremlin pointer? So question is how to delete the iRecord and oRecord .

I was planning to delete the appId in second traversal call. So can I check if the appId has no more connected runId and drop appId in the same traversal.

db.getTraversal()
                .V().has("aRun", "runId", runId).as("aRun")
                .outE("hasIO")
                .inV().hasLabel("io").as("io")
                .sideEffect(outE("output").inV().has("oRecord").drop())
                .sideEffect(inE("input").outV().has("iRecord").drop())
                .sideEffect(select("aRun").drop())
                .sideEffect(select("io").drop())
                .iterate();

I also tried version of answer provided here: Link

db.getTraversal().
  V().has("aRun", "runId", runId)
  emit().
  repeat(out()).
  fold().
  unfold().
  drop()

But this will delete the oRecord , aRun and io but not the iRecord . And question of how to drop appId remains.

Thanks

示例子图

pom.xml:

<dependency>
 <groupId>com.orientechnologies</groupId>
 <artifactId>orientdb-gremlin</artifactId>
 <version>3.0.25</version>
</dependency>

I used this query:

db.getTraversal()
 .V().has("app", "appId", appId).as("app")
 .outE("hasRun")
 .inV().has("aRun", "runId", runId).as("aRun")
 .outE("hasIO")
 .inV().hasLabel("io").as("io")
 .sideEffect(outE("output").inV().hasLabel("oRecord").drop())
 .sideEffect(inE("input").outV().hasLabel("iRecord").drop())
 .sideEffect(select("app").filter(outE("hasRun").count().is(1)).drop())
 .sideEffect(select("aRun").drop())
 .sideEffect(select("io").drop())
 .iterate();

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM