org.vertexium.query.DefaultGraphQueryIterableWithAggregations Maven / Gradle / Ivy
package org.vertexium.query;
import org.vertexium.Element;
import org.vertexium.VertexiumException;
import java.util.*;
public class DefaultGraphQueryIterableWithAggregations extends DefaultGraphQueryIterable {
private final Collection aggregations;
public DefaultGraphQueryIterableWithAggregations(
QueryParameters parameters,
Iterable iterable,
boolean evaluateQueryString,
boolean evaluateHasContainers,
boolean evaluateSortContainers,
Collection aggregations
) {
super(parameters, iterable, evaluateQueryString, evaluateHasContainers, evaluateSortContainers);
this.aggregations = aggregations;
}
@Override
public TResult getAggregationResult(String name, Class extends TResult> resultType) {
for (Aggregation agg : this.aggregations) {
if (agg.getAggregationName().equals(name)) {
return getAggregationResult(agg, this.iterator(true));
}
}
return super.getAggregationResult(name, resultType);
}
public static boolean isAggregationSupported(Aggregation agg) {
if (agg instanceof TermsAggregation) {
return true;
}
return false;
}
public TResult getAggregationResult(Aggregation agg, Iterator it) {
if (agg instanceof TermsAggregation) {
return getTermsAggregationResult((TermsAggregation) agg, it);
}
throw new VertexiumException("Unhandled aggregation: " + agg.getClass().getName());
}
private TResult getTermsAggregationResult(TermsAggregation agg, Iterator it) {
String propertyName = agg.getPropertyName();
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy