@ SuppressWarnings ( "unchecked" ) public GraphTraversal < Vertex , Map < String , Element > > getGraphTraversal ( TransactionOLTP tx , Set < Variable > vars ) { if ( fragments ( ) . size ( ) == 1 ) { // If there are no disjunctions, we don't need to union them and get a performance boost ImmutableList < Fragment > list = Iterables . getOnlyElement ( fragments ( ) ) ; return getConjunctionTraversal ( tx , tx . getTinkerTraversal ( ) . V ( ) , vars , list ) ; } else { Traversal [ ] traversals = fragments ( ) . stream ( ) . map ( list -> getConjunctionTraversal ( tx , __ . V ( ) , vars , list ) ) . toArray ( Traversal [ ] :: new ) ; // This is a sneaky trick - we want to do a union but tinkerpop requires all traversals to start from // somewhere, so we start from a single arbitrary vertex. GraphTraversal traversal = tx . getTinkerTraversal ( ) . V ( ) . limit ( 1 ) . union ( traversals ) ; return selectVars ( traversal , vars ) ; } }
Because union accepts an array we can t use generics