private boolean targetContainsInstance ( GraqlCompute . Statistics . Value query ) { for ( Label attributeType : targetTypeLabels ( query ) ) { for ( Label type : scopeTypeLabels ( query ) ) { Boolean patternExist = tx . stream ( Graql . match ( Graql . var ( "x" ) . has ( attributeType . getValue ( ) , Graql . var ( ) ) , Graql . var ( "x" ) . isa ( Graql . type ( type . getValue ( ) ) ) ) , false ) . iterator ( ) . hasNext ( ) ; if ( patternExist ) return true ; } } return false ; //TODO: should use the following ask query when ask query is even lazier // List<Pattern> checkResourceTypes = statisticsResourceTypes.stream() // .map(type -> var("x").has(type, var())).collect(Collectors.toList()); // List<Pattern> checkSubtypes = inTypes.stream() // .map(type -> var("x").isa(Graql.label(type))).collect(Collectors.toList()); // // return tx.get().graql().infer(false) // .match(or(checkResourceTypes), or(checkSubtypes)).get().aggregate(ask()).execute(); }
Helper method to check whether the concept types in the target have any instances