private Stream < ConceptList > runComputePath ( GraqlCompute . Path query ) { ConceptId fromID = ConceptId . of ( query . from ( ) ) ; ConceptId toID = ConceptId . of ( query . to ( ) ) ; if ( ! scopeContainsInstances ( query , fromID , toID ) ) throw GraqlQueryException . instanceDoesNotExist ( ) ; if ( fromID . equals ( toID ) ) return Stream . of ( new ConceptList ( ImmutableList . of ( fromID ) ) ) ; Set < LabelId > scopedLabelIds = convertLabelsToIds ( scopeTypeLabels ( query ) ) ; ComputerResult result = compute ( new ShortestPathVertexProgram ( fromID , toID ) , null , scopedLabelIds ) ; Multimap < ConceptId , ConceptId > pathsAsEdgeList = HashMultimap . create ( ) ; Map < String , Set < String > > resultFromMemory = result . memory ( ) . get ( ShortestPathVertexProgram . SHORTEST_PATH ) ; resultFromMemory . forEach ( ( id , idSet ) -> idSet . forEach ( id2 -> { pathsAsEdgeList . put ( Schema . conceptIdFromVertexId ( id ) , Schema . conceptIdFromVertexId ( id2 ) ) ; } ) ) ; List < List < ConceptId > > paths ; if ( ! resultFromMemory . isEmpty ( ) ) { paths = getComputePathResultList ( pathsAsEdgeList , fromID ) ; if ( scopeIncludesAttributes ( query ) ) { paths = getComputePathResultListIncludingImplicitRelations ( paths ) ; } } else { paths = Collections . emptyList ( ) ; } return paths . stream ( ) . map ( ConceptList :: new ) ; }
The Graql compute path query run method