use of org.locationtech.geowave.datastore.redis.util.GeoWaveRedisRow in project geowave by locationtech.
the class RedisReader method createIteratorForReader.
private CloseableIterator<T> createIteratorForReader(final RedissonClient client, final Compression compression, final ReaderParams<T> readerParams, final GeoWaveRowIteratorTransformer<T> rowTransformer, final String namespace, final boolean visibilityEnabled, final boolean async) {
final Collection<SinglePartitionQueryRanges> ranges = readerParams.getQueryRanges().getPartitionQueryRanges();
final Set<String> authorizations = Sets.newHashSet(readerParams.getAdditionalAuthorizations());
if ((ranges != null) && !ranges.isEmpty()) {
return createIterator(client, compression, readerParams, readerParams.getRowTransformer(), namespace, ranges, authorizations, visibilityEnabled, async);
} else {
final Iterator<GeoWaveRedisRow>[] iterators = new Iterator[readerParams.getAdapterIds().length];
int i = 0;
for (final short adapterId : readerParams.getAdapterIds()) {
final Pair<Boolean, Boolean> groupByRowAndSortByTime = RedisUtils.isGroupByRowAndIsSortByTime(readerParams, adapterId);
final String setNamePrefix = RedisUtils.getRowSetPrefix(namespace, readerParams.getInternalAdapterStore().getTypeName(adapterId), readerParams.getIndex().getName());
final Stream<Pair<ByteArray, Iterator<ScoredEntry<GeoWaveRedisPersistedRow>>>> streamIt = RedisUtils.getPartitions(client, setNamePrefix).stream().map(p -> {
final Iterator<ScoredEntry<GeoWaveRedisPersistedRow>> result = RedisUtils.getRowSet(client, compression, setNamePrefix, p.getBytes(), groupByRowAndSortByTime.getRight(), visibilityEnabled).entryRange(Double.NEGATIVE_INFINITY, true, Double.POSITIVE_INFINITY, true);
final Iterator<ScoredEntry<GeoWaveRedisPersistedRow>> it = groupByRowAndSortByTime.getLeft() ? RedisUtils.groupByRow(result, groupByRowAndSortByTime.getRight()) : result;
return ImmutablePair.of(p, it);
});
iterators[i++] = Iterators.concat(streamIt.map(p -> Iterators.transform(p.getRight(), pr -> new GeoWaveRedisRow(pr.getValue(), adapterId, p.getLeft().getBytes(), RedisUtils.getFullSortKey(pr.getScore(), pr.getValue().getSortKeyPrecisionBeyondScore())))).iterator());
}
return wrapResults(Iterators.concat(iterators), readerParams, rowTransformer, authorizations, visibilityEnabled);
}
}
Aggregations