@Override public GeoResults<GeoLocation<V>> convert(GeoResults<GeoLocation<byte[]>> source) { List<GeoResult<GeoLocation<V>>> values = new ArrayList<>(source.getContent().size()); for (GeoResult<GeoLocation<byte[]>> value : source.getContent()) { values.add(new GeoResult<>( new GeoLocation<>(serializer.deserialize(value.getContent().getName()), value.getContent().getPoint()), value.getDistance())); } return new GeoResults<>(values, source.getAverageDistance().getMetric()); } }
private GeoResult<GeoLocation<V>> readGeoResult(GeoResult<GeoLocation<ByteBuffer>> source) { return new GeoResult<>(new GeoLocation(readValue(source.getContent().getName()), source.getContent().getPoint()), source.getDistance()); } }
private static Distance calculateAverageDistance(List<? extends GeoResult<?>> results, Metric metric) { Assert.notNull(results, "Results must not be null!"); Assert.notNull(metric, "Metric must not be null!"); if (results.isEmpty()) { return new Distance(0, metric); } double averageDistance = results.stream()// .mapToDouble(it -> it.getDistance().getValue())// .average().orElse(0); return new Distance(averageDistance, metric); } }
@Override public GeoResults<GeoLocation<V>> convert(GeoResults<GeoLocation<byte[]>> source) { List<GeoResult<GeoLocation<V>>> values = new ArrayList<>(source.getContent().size()); for (GeoResult<GeoLocation<byte[]>> value : source.getContent()) { values.add(new GeoResult<>( new GeoLocation<>(serializer.deserialize(value.getContent().getName()), value.getContent().getPoint()), value.getDistance())); } return new GeoResults<>(values, source.getAverageDistance().getMetric()); } }
@Override public GeoResults<GeoLocation<V>> convert(GeoResults<GeoLocation<byte[]>> source) { List<GeoResult<GeoLocation<V>>> values = new ArrayList<>(source.getContent().size()); for (GeoResult<GeoLocation<byte[]>> value : source.getContent()) { values.add(new GeoResult<>( new GeoLocation<>(serializer.deserialize(value.getContent().getName()), value.getContent().getPoint()), value.getDistance())); } return new GeoResults<>(values, source.getAverageDistance().getMetric()); } }
private GeoResult<GeoLocation<V>> readGeoResult(GeoResult<GeoLocation<ByteBuffer>> source) { return new GeoResult<>(new GeoLocation(readValue(source.getContent().getName()), source.getContent().getPoint()), source.getDistance()); } }
private GeoResult<GeoLocation<V>> readGeoResult(GeoResult<GeoLocation<ByteBuffer>> source) { return new GeoResult<>(new GeoLocation(readValue(source.getContent().getName()), source.getContent().getPoint()), source.getDistance()); } }