@Override protected GeohashResult bucketsToResults(List<GeohashBucket> buckets) { return new GeohashResult(buckets); } }.reduce(query, bucketsByKey);
public long getMaxCount() { long max = Long.MIN_VALUE; for (GeohashBucket b : getBuckets()) { max = Math.max(max, b.getCount()); } return max; } }
private ClientApiSearchResponse.AggregateResult toClientApiGeohashResult(GeohashResult agg) { ClientApiSearchResponse.GeohashAggregateResult result = new ClientApiSearchResponse.GeohashAggregateResult(); result.setMaxCount(agg.getMaxCount()); for (GeohashBucket geohashBucket : agg.getBuckets()) { ClientApiSearchResponse.GeohashAggregateResult.Bucket b = new ClientApiSearchResponse.GeohashAggregateResult.Bucket( ClientApiConverter.toClientApiGeoRect(geohashBucket.getGeoCell()), ClientApiConverter.toClientApiGeoPoint(geohashBucket.getGeoPoint()), geohashBucket.getCount(), toClientApiNestedResults(geohashBucket.getNestedResults()) ); result.getBuckets().put(geohashBucket.getKey(), b); } return result; }
public long getMaxCount() { long max = Long.MIN_VALUE; for (GeohashBucket b : getBuckets()) { max = Math.max(max, b.getCount()); } return max; } }
@Override protected GeohashResult bucketsToResults(List<GeohashBucket> buckets) { return new GeohashResult(buckets); } }.reduce(query, bucketsByKey);
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) { Query q = graph.query(authorizations).limit(0); GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", GeohashAggregation.class.getName()); return null; } q.addAggregation(agg); return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets()); }
@Override protected GeohashResult bucketsToResults(List<GeohashBucket> buckets) { return new GeohashResult(buckets); } }.reduce(query, bucketsByKey);
private Map<String, Long> queryGraphQueryWithGeohashAggregation(String propertyName, int precision, Authorizations authorizations) { Query q = graph.query(authorizations).limit(0); GeohashAggregation agg = new GeohashAggregation("geo-count", propertyName, precision); if (!q.isAggregationSupported(agg)) { LOGGER.warn("%s unsupported", GeohashAggregation.class.getName()); return null; } q.addAggregation(agg); return geoHashBucketToMap(q.vertices().getAggregationResult("geo-count", GeohashResult.class).getBuckets()); }
@Override protected GeohashResult bucketsToResults(List<GeohashBucket> buckets) { return new GeohashResult(buckets); } }.reduce(query, bucketsByKey);
public static <TResult extends AggregationResult> TResult createEmptyResult(Class<? extends TResult> resultType) { if (resultType.equals(TermsResult.class)) { return resultType.cast(new TermsResult(new ArrayList<>())); } if (resultType.equals(StatisticsResult.class)) { return resultType.cast(new StatisticsResult(0, 0.0, 0.0, 0.0, 0.0)); } if (resultType.equals(HistogramResult.class)) { return resultType.cast(new HistogramResult(new ArrayList<>())); } if (resultType.equals(RangeResult.class)) { return resultType.cast(new RangeResult(new ArrayList<>())); } if (resultType.equals(PercentilesResult.class)) { return resultType.cast(new PercentilesResult(new ArrayList<>())); } if (resultType.equals(GeohashResult.class)) { return resultType.cast(new GeohashResult(new ArrayList<>())); } if (resultType.equals(CardinalityResult.class)) { return resultType.cast(new CardinalityResult(0)); } throw new VertexiumException("Unhandled type to create empty results for: " + resultType.getName()); } }
public static <TResult extends AggregationResult> TResult createEmptyResult(Class<? extends TResult> resultType) { if (resultType.equals(TermsResult.class)) { return resultType.cast(new TermsResult(new ArrayList<>())); } if (resultType.equals(StatisticsResult.class)) { return resultType.cast(new StatisticsResult(0, 0.0, 0.0, 0.0, 0.0)); } if (resultType.equals(HistogramResult.class)) { return resultType.cast(new HistogramResult(new ArrayList<>())); } if (resultType.equals(RangeResult.class)) { return resultType.cast(new RangeResult(new ArrayList<>())); } if (resultType.equals(PercentilesResult.class)) { return resultType.cast(new PercentilesResult(new ArrayList<>())); } if (resultType.equals(GeohashResult.class)) { return resultType.cast(new GeohashResult(new ArrayList<>())); } if (resultType.equals(CardinalityResult.class)) { return resultType.cast(new CardinalityResult(0)); } throw new VertexiumException("Unhandled type to create empty results for: " + resultType.getName()); } }