use of ai.grakn.graql.internal.analytics.DegreeStatisticsVertexProgram in project grakn by graknlabs.
the class TinkerComputeQueryRunner method execWithMapReduce.
private <T, S, Q extends StatisticsQuery<?>> TinkerComputeJob<Optional<S>> execWithMapReduce(Q query, MapReduceFactory<T> mapReduceFactory, Function<T, S> operator) {
return runStatistics(query, tinkerComputeQuery -> {
AttributeType.DataType<?> dataType = tinkerComputeQuery.getDataTypeOfSelectedResourceTypes();
if (!tinkerComputeQuery.selectedResourceTypesHaveInstance()) {
return Optional.empty();
}
Set<LabelId> allSubLabelIds = convertLabelsToIds(tinkerComputeQuery.getCombinedSubTypes());
Set<LabelId> statisticsResourceLabelIds = convertLabelsToIds(tinkerComputeQuery.statisticsResourceLabels());
GraknMapReduce<T> mapReduce = mapReduceFactory.get(statisticsResourceLabelIds, dataType, DegreeVertexProgram.DEGREE);
ComputerResult result = tinkerComputeQuery.compute(new DegreeStatisticsVertexProgram(statisticsResourceLabelIds), mapReduce, allSubLabelIds);
Map<Serializable, T> map = result.memory().get(mapReduce.getClass().getName());
LOG.debug("Result = " + map.get(MapReduce.NullObject.instance()));
return Optional.of(operator.apply(map.get(MapReduce.NullObject.instance())));
});
}
Aggregations