use of org.locationtech.geowave.datastore.filesystem.util.FileSystemClient in project geowave by locationtech.
the class FileSystemReader method createIterator.
private CloseableIterator<T> createIterator(final FileSystemClient client, final RangeReaderParams<T> readerParams, final GeoWaveRowIteratorTransformer<T> rowTransformer, final Collection<SinglePartitionQueryRanges> ranges, final Set<String> authorizations, final boolean async) {
final Iterator<CloseableIterator> it = Arrays.stream(ArrayUtils.toObject(readerParams.getAdapterIds())).map(adapterId -> new FileSystemQueryExecution(client, adapterId, readerParams.getInternalAdapterStore().getTypeName(adapterId), readerParams.getIndex().getName(), client.getFormat(), rowTransformer, ranges, new ClientVisibilityFilter(authorizations), DataStoreUtils.isMergingIteratorRequired(readerParams, client.isVisibilityEnabled()), async, FileSystemUtils.isGroupByRowAndIsSortByTime(readerParams, adapterId), FileSystemUtils.isSortByKeyRequired(readerParams)).results()).iterator();
final CloseableIterator<T>[] itArray = Iterators.toArray(it, CloseableIterator.class);
return new CloseableIteratorWrapper<>(new Closeable() {
AtomicBoolean closed = new AtomicBoolean(false);
@Override
public void close() throws IOException {
if (!closed.getAndSet(true)) {
Arrays.stream(itArray).forEach(it -> it.close());
}
}
}, Iterators.concat(itArray));
}
use of org.locationtech.geowave.datastore.filesystem.util.FileSystemClient in project geowave by locationtech.
the class FileSystemReader method createIteratorForReader.
private CloseableIterator<T> createIteratorForReader(final FileSystemClient client, final ReaderParams<T> readerParams, final GeoWaveRowIteratorTransformer<T> rowTransformer, 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, readerParams, readerParams.getRowTransformer(), ranges, authorizations, async);
} else {
final List<CloseableIterator<GeoWaveRow>> iterators = new ArrayList<>();
final IndexFormatter indexFormatter = DataFormatterCache.getInstance().getFormatter(client.getFormat(), client.isVisibilityEnabled()).getIndexFormatter();
final String indexName = readerParams.getIndex().getName();
for (final short adapterId : readerParams.getAdapterIds()) {
final Pair<Boolean, Boolean> groupByRowAndSortByTime = FileSystemUtils.isGroupByRowAndIsSortByTime(readerParams, adapterId);
final String typeName = readerParams.getInternalAdapterStore().getTypeName(adapterId);
final String indexDirectory = indexFormatter.getDirectoryName(indexName, typeName);
final Stream<CloseableIterator<GeoWaveRow>> streamIt = FileSystemUtils.getPartitions(FileSystemUtils.getSubdirectory(client.getSubDirectory(), indexDirectory), indexFormatter, indexName, typeName).stream().map(p -> FileSystemUtils.getIndexTable(client, adapterId, typeName, indexName, p.getBytes(), groupByRowAndSortByTime.getRight()).iterator());
iterators.addAll(streamIt.collect(Collectors.toList()));
}
return wrapResults(new Closeable() {
AtomicBoolean closed = new AtomicBoolean(false);
@Override
public void close() throws IOException {
if (!closed.getAndSet(true)) {
iterators.forEach(it -> it.close());
}
}
}, Iterators.concat(iterators.iterator()), readerParams, rowTransformer, authorizations, client.isVisibilityEnabled());
}
}
Aggregations