use of org.locationtech.geowave.core.store.adapter.RowMergingDataAdapter in project geowave by locationtech.
the class DataStoreUtils method mergeData.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static boolean mergeData(final DataStoreOperations operations, final Integer maxRangeDecomposition, final Index index, final PersistentAdapterStore adapterStore, final InternalAdapterStore internalAdapterStore, final AdapterIndexMappingStore adapterIndexMappingStore) {
final RowDeleter deleter = operations.createRowDeleter(index.getName(), adapterStore, internalAdapterStore);
try {
final Map<Short, InternalDataAdapter> mergingAdapters = new HashMap<>();
final InternalDataAdapter<?>[] adapters = adapterStore.getAdapters();
for (final InternalDataAdapter<?> adapter : adapters) {
if ((adapter.getAdapter() instanceof RowMergingDataAdapter) && (((RowMergingDataAdapter) adapter.getAdapter()).getTransform() != null)) {
mergingAdapters.put(adapter.getAdapterId(), adapter);
}
}
final ReaderParamsBuilder<GeoWaveRow> paramsBuilder = new ReaderParamsBuilder<>(index, adapterStore, adapterIndexMappingStore, internalAdapterStore, GeoWaveRowIteratorTransformer.NO_OP_TRANSFORMER).isClientsideRowMerging(true).maxRangeDecomposition(maxRangeDecomposition);
final short[] adapterIds = new short[1];
for (final Entry<Short, InternalDataAdapter> adapter : mergingAdapters.entrySet()) {
adapterIds[0] = adapter.getKey();
paramsBuilder.adapterIds(adapterIds);
try (final RowWriter writer = operations.createWriter(index, adapter.getValue());
final RowReader<GeoWaveRow> reader = operations.createReader(paramsBuilder.build())) {
final RewritingMergingEntryIterator<?> iterator = new RewritingMergingEntryIterator(adapterStore, adapterIndexMappingStore, index, reader, Maps.transformValues(mergingAdapters, v -> v.getAdapter()), writer, deleter);
while (iterator.hasNext()) {
iterator.next();
}
} catch (final Exception e) {
LOGGER.error("Exception occurred while merging data.", e);
throw new RuntimeException(e);
}
}
} finally {
try {
deleter.close();
} catch (final Exception e) {
LOGGER.warn("Exception occurred when closing deleter.", e);
}
}
return true;
}
use of org.locationtech.geowave.core.store.adapter.RowMergingDataAdapter in project geowave by locationtech.
the class MergingEntryIterator method getNextEncodedResult.
@Override
protected GeoWaveRow getNextEncodedResult() {
GeoWaveRow nextResult = scannerIt.next();
final short internalAdapterId = nextResult.getAdapterId();
final RowMergingDataAdapter mergingAdapter = mergingAdapters.get(internalAdapterId);
if ((mergingAdapter != null) && (mergingAdapter.getTransform() != null)) {
final RowTransform rowTransform = getRowTransform(internalAdapterId, mergingAdapter);
// This iterator expects a single GeoWaveRow w/ multiple fieldValues
nextResult = mergeSingleRowValues(nextResult, rowTransform);
}
return nextResult;
}
use of org.locationtech.geowave.core.store.adapter.RowMergingDataAdapter in project geowave by locationtech.
the class BaseFilteredIndexQuery method getRowTransformer.
private <T> GeoWaveRowIteratorTransformer<T> getRowTransformer(final DataStoreOptions options, final PersistentAdapterStore adapterStore, final AdapterIndexMappingStore mappingStore, final double[] maxResolutionSubsamplingPerDimension, final boolean decodePersistenceEncoding) {
@Nullable final QueryFilter[] clientFilters = getClientFilters(options);
final DataIndexRetrieval dataIndexRetrieval = getDataIndexRetrieval();
if ((options == null) || options.requiresClientSideMerging()) {
final Map<Short, RowMergingDataAdapter> mergingAdapters = getMergingAdapters(adapterStore);
if (!mergingAdapters.isEmpty()) {
return new GeoWaveRowIteratorTransformer<T>() {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Iterator<T> apply(final Iterator<GeoWaveRow> input) {
return new MergingEntryIterator(adapterStore, mappingStore, index, input, clientFilters, scanCallback, mergingAdapters, maxResolutionSubsamplingPerDimension, dataIndexRetrieval);
}
};
}
}
return new GeoWaveRowIteratorTransformer<T>() {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Iterator<T> apply(final Iterator<GeoWaveRow> input) {
return (Iterator<T>) GeoWaveRowIteratorFactory.iterator(adapterStore, mappingStore, index, input, clientFilters, scanCallback, getFieldBitmask(), // enabled.
((options != null) && options.isServerSideLibraryEnabled()) ? null : maxResolutionSubsamplingPerDimension, decodePersistenceEncoding, dataIndexRetrieval);
}
};
}
Aggregations