Search in sources :

Example 1 with RowReaderWrapper

use of org.locationtech.geowave.core.store.operations.RowReaderWrapper in project geowave by locationtech.

the class CassandraOperations method createReader.

@Override
public RowReader<GeoWaveRow> createReader(final DataIndexReaderParams readerParams) {
    final byte[][] dataIds;
    Iterator<GeoWaveRow> iterator;
    if (readerParams.getDataIds() == null) {
        if ((readerParams.getStartInclusiveDataId() != null) || (readerParams.getEndInclusiveDataId() != null)) {
            final List<byte[]> intermediaries = new ArrayList<>();
            ByteArrayUtils.addAllIntermediaryByteArrays(intermediaries, new ByteArrayRange(readerParams.getStartInclusiveDataId(), readerParams.getEndInclusiveDataId()));
            dataIds = intermediaries.toArray(new byte[0][]);
            iterator = getRows(dataIds, readerParams.getAdapterId());
        } else {
            iterator = getRows(readerParams.getAdapterId());
        }
    } else {
        dataIds = readerParams.getDataIds();
        iterator = getRows(dataIds, readerParams.getAdapterId());
    }
    if (options.isVisibilityEnabled()) {
        Stream<GeoWaveRow> stream = Streams.stream(iterator);
        final Set<String> authorizations = Sets.newHashSet(readerParams.getAdditionalAuthorizations());
        stream = stream.filter(new ClientVisibilityFilter(authorizations));
        iterator = stream.iterator();
    }
    return new RowReaderWrapper<>(new CloseableIterator.Wrapper(iterator));
}
Also used : GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) RowReaderWrapper(org.locationtech.geowave.core.store.operations.RowReaderWrapper) ArrayList(java.util.ArrayList) ByteArrayRange(org.locationtech.geowave.core.index.ByteArrayRange) ClientVisibilityFilter(org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter)

Example 2 with RowReaderWrapper

use of org.locationtech.geowave.core.store.operations.RowReaderWrapper in project geowave by locationtech.

the class DynamoDBOperations method createReader.

@Override
public RowReader<GeoWaveRow> createReader(final DataIndexReaderParams readerParams) {
    final String typeName = readerParams.getInternalAdapterStore().getTypeName(readerParams.getAdapterId());
    if (typeName == null) {
        return new RowReaderWrapper<>(new CloseableIterator.Empty<GeoWaveRow>());
    }
    byte[][] dataIds;
    Iterator<GeoWaveRow> iterator;
    if (readerParams.getDataIds() != null) {
        dataIds = readerParams.getDataIds();
        iterator = getRowsFromDataIndex(dataIds, readerParams.getAdapterId(), typeName);
    } else {
        if ((readerParams.getStartInclusiveDataId() != null) || (readerParams.getEndInclusiveDataId() != null)) {
            final List<byte[]> intermediaries = new ArrayList<>();
            ByteArrayUtils.addAllIntermediaryByteArrays(intermediaries, new ByteArrayRange(readerParams.getStartInclusiveDataId(), readerParams.getEndInclusiveDataId()));
            dataIds = intermediaries.toArray(new byte[0][]);
            iterator = getRowsFromDataIndex(dataIds, readerParams.getAdapterId(), typeName);
        } else {
            iterator = getRowsFromDataIndex(readerParams.getAdapterId(), typeName);
        }
    }
    if (options.getBaseOptions().isVisibilityEnabled()) {
        Stream<GeoWaveRow> stream = Streams.stream(iterator);
        final Set<String> authorizations = Sets.newHashSet(readerParams.getAdditionalAuthorizations());
        stream = stream.filter(new ClientVisibilityFilter(authorizations));
        iterator = stream.iterator();
    }
    return new RowReaderWrapper<>(new CloseableIterator.Wrapper<>(iterator));
}
Also used : CloseableIterator(org.locationtech.geowave.core.store.CloseableIterator) GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) RowReaderWrapper(org.locationtech.geowave.core.store.operations.RowReaderWrapper) ArrayList(java.util.ArrayList) ByteArrayRange(org.locationtech.geowave.core.index.ByteArrayRange) ClientVisibilityFilter(org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter)

Aggregations

ArrayList (java.util.ArrayList)2 ByteArrayRange (org.locationtech.geowave.core.index.ByteArrayRange)2 CloseableIterator (org.locationtech.geowave.core.store.CloseableIterator)2 GeoWaveRow (org.locationtech.geowave.core.store.entities.GeoWaveRow)2 RowReaderWrapper (org.locationtech.geowave.core.store.operations.RowReaderWrapper)2 ClientVisibilityFilter (org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter)2