use of ai.grakn.graql.internal.analytics.MedianVertexProgram in project grakn by graknlabs.
the class TinkerComputeQueryRunner method run.
public ComputeJob<Optional<Number>> run(MedianQuery query) {
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());
ComputerResult result = tinkerComputeQuery.compute(new MedianVertexProgram(statisticsResourceLabelIds, dataType), null, allSubLabelIds);
Number finalResult = result.memory().get(MedianVertexProgram.MEDIAN);
LOG.debug("Median = " + finalResult);
return Optional.of(finalResult);
});
}
Aggregations