use of org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter 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));
}
use of org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter in project geowave by locationtech.
the class CassandraReader method initScanner.
protected void initScanner() {
final Collection<SinglePartitionQueryRanges> ranges = readerParams.getQueryRanges().getPartitionQueryRanges();
if ((ranges != null) && !ranges.isEmpty()) {
iterator = operations.getBatchedRangeRead(readerParams.getIndex().getName(), readerParams.getAdapterIds(), ranges, DataStoreUtils.isMergingIteratorRequired(readerParams, visibilityEnabled), rowTransformer, new ClientVisibilityFilter(Sets.newHashSet(readerParams.getAdditionalAuthorizations()))).results();
} else {
// TODO figure out the query select by adapter IDs here
final Select select = operations.getSelect(readerParams.getIndex().getName());
CloseableIterator<CassandraRow> results = operations.executeQuery(select.build());
if ((readerParams.getAdapterIds() != null) && (readerParams.getAdapterIds().length > 0)) {
// TODO because we aren't filtering server-side by adapter ID,
// we will need to filter here on the client
results = new CloseableIteratorWrapper<>(results, Iterators.filter(results, input -> ArrayUtils.contains(readerParams.getAdapterIds(), input.getAdapterId())));
}
iterator = wrapResults(results, readerParams);
}
}
use of org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter in project geowave by locationtech.
the class CassandraReader method wrapResults.
@SuppressWarnings("unchecked")
private CloseableIterator<T> wrapResults(final CloseableIterator<CassandraRow> results, final RangeReaderParams<T> readerParams) {
final Set<String> authorizations = Sets.newHashSet(readerParams.getAdditionalAuthorizations());
final Iterator<GeoWaveRow> iterator = (Iterator) Streams.stream(results).filter(new ClientVisibilityFilter(authorizations)).iterator();
return new CloseableIteratorWrapper<>(results, rowTransformer.apply(DataStoreUtils.isMergingIteratorRequired(readerParams, visibilityEnabled) ? new GeoWaveRowMergingIterator(iterator) : iterator));
}
use of org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter 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));
}
use of org.locationtech.geowave.core.store.query.filter.ClientVisibilityFilter in project geowave by locationtech.
the class FileSystemReader method createIteratorForDataIndexReader.
private Iterator<GeoWaveRow> createIteratorForDataIndexReader(final FileSystemClient client, final DataIndexReaderParams dataIndexReaderParams) {
final FileSystemDataIndexTable dataIndexTable = FileSystemUtils.getDataIndexTable(client, dataIndexReaderParams.getAdapterId(), dataIndexReaderParams.getInternalAdapterStore().getTypeName(dataIndexReaderParams.getAdapterId()));
Iterator<GeoWaveRow> iterator;
if (dataIndexReaderParams.getDataIds() != null) {
iterator = dataIndexTable.dataIndexIterator(dataIndexReaderParams.getDataIds());
} else {
iterator = dataIndexTable.dataIndexIterator(dataIndexReaderParams.getStartInclusiveDataId(), dataIndexReaderParams.getEndInclusiveDataId());
}
if (client.isVisibilityEnabled()) {
Stream<GeoWaveRow> stream = Streams.stream(iterator);
final Set<String> authorizations = Sets.newHashSet(dataIndexReaderParams.getAdditionalAuthorizations());
stream = stream.filter(new ClientVisibilityFilter(authorizations));
iterator = stream.iterator();
}
return iterator;
}
Aggregations