Skip to content

Adding vertices and edges with the same label name - generate ClassCastException on traversal of vertices - g.V() #498

Closed

Description

@nicolaiwadstrom

ArcadeDB Version: 22.8.1

JDK Version: Oracle Corporation v11.0.2 build 11.0.2+9 (2019-01-15) - class version 55.0

OS: MacOS 12.4

Expected behavior

ArcadeGraph.vertices( ids... String ) to return only vertices

Actual behavior

the query in ArcadeGraph.vertices() implementation do not query only vertices, but will also return edges, which causes a ClassCastException on line 212:

  return resultset.stream()
          .map(result -> (Vertex) new ArcadeVertex(this, (com.arcadedb.graph.Vertex) (result.toElement())))
    .iterator();

The problem is: (com.arcadedb.graph.Vertex) (result.toElement())

Steps to reproduce

Create Vertices and Edges with properties, where vertices and the the edge have the same label identifier. Do a graph traversal:

			com.arcadedb.database.Database database = databaseServer().getDatabase( "debug-db-2", true, true );

			org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph graph = 
				org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph.open( database );
			
			GraphTraversalSource g = 
				AnonymousTraversalSource
					.traversal()
					.withEmbedded( graph )
			;
			
			org.apache.tinkerpop.gremlin.structure.Vertex _v1 = g.addV( "l1" ).property(  "[test]", "sallad" ).next();
			org.apache.tinkerpop.gremlin.structure.Vertex _v2 = g.addV( "l1" ).property(  "[test]", "sallad" ).next();

			g.addE( "l1" ).from( _v1 ).to( _v2 ).property(  "[test]", "sallad" ).iterate();
			
			
			g.V()
				.has( "[test]", org.apache.tinkerpop.gremlin.process.traversal.P.within( "sallad" ) )
			
			.forEachRemaining( v -> {
				System.out.println( v + " --> " + "  " );
			} );

---- Exception details ----

java.lang.ClassCastException: class com.arcadedb.graph.MutableEdge cannot be cast to class com.arcadedb.graph.Vertex (com.arcadedb.graph.MutableEdge and com.arcadedb.graph.Vertex are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.arcadedb.graph.MutableEdge cannot be cast to class com.arcadedb.graph.Vertex (com.arcadedb.graph.MutableEdge and com.arcadedb.graph.Vertex are in unnamed module of loader 'app')
	at org.apache.tinkerpop.gremlin.arcadedb.structure.ArcadeGraph.lambda$vertices$0(ArcadeGraph.java:212) ~[arcadedb-gremlin-22.8.1.jar:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
	at com.arcadedb.query.sql.executor.ResultSet.tryAdvance(ResultSet.java:60) ~[arcadedb-engine-22.8.1.jar:?]
	at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:294) ~[?:?]
	at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206) ~[?:?]
	at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:169) ~[?:?]
	at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300) ~[?:?]
	at java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681) ~[?:?]
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:149) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:150) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:55) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep.processNextStart(FilterStep.java:37) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:135) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:40) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:230) ~[gremlin-core-3.5.1.jar:3.5.1]
	at org.apache.tinkerpop.gremlin.process.traversal.Traversal.forEachRemaining(Traversal.java:278) ~[gremlin-core-3.5.1.jar:3.5.1]
	at test.lambda$0(TestEmbeddedDatabaserServer2.java:139) ~[classes/:?]
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159) ~[vertx-core-4.3.1.jar:4.3.1]
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:101) ~[vertx-core-4.3.1.jar:4.3.1]
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157) ~[vertx-core-4.3.1.jar:4.3.1]
	at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76) ~[vertx-core-4.3.1.jar:4.3.1]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.77.Final.jar:4.1.77.Final]
	at java.lang.Thread.run(Thread.java:834) [?:?]

Activity

  1. self-assigned this
    on Aug 31, 2022
  2. added this to the 22.9.1 milestone on Aug 31, 2022
  3. lvca commented on Sep 1, 2022

    @lvca
    Member

    I checked the method and only the buckets relative to the vertex types are considered:

  4. lvca commented on Sep 1, 2022

    @lvca
    Member

    Ok, I found something odd in ArcadeGraph. A check is missing about the label name. It checks only that the vertex/edge types exist without checking that is a vertex or edge type. Not sure if this fixes the issue, I'd need a test case in java to reproduce it. Any chance you can build the latest snapshot from git main branch and try it out?

  5. nicolaiwadstrom commented on Sep 4, 2022

    @nicolaiwadstrom
    Author

    Thanks, I will give it a go to try to build from latest and see if that fixes it.

  6. modified the milestones: 22.9.1, 22.10.1 on Oct 3, 2022
  7. lvca commented on Oct 15, 2022

    @lvca
    Member

    @nicolaiwadstrom any news on this? Were you able to try this out? Thanks in advance.

  8. lvca commented on Oct 24, 2022

    @lvca
    Member

    No feedback from the user, closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions