use of org.locationtech.geowave.core.store.operations.RowDeleter 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.operations.RowDeleter in project geowave by locationtech.
the class AccumuloOperations method createDeleter.
@Override
public <T> Deleter<T> createDeleter(final ReaderParams<T> readerParams) {
final ScannerBase scanner = getScanner(readerParams, true);
if (readerParams.isMixedVisibility() || (scanner == null) || !options.isServerSideLibraryEnabled()) {
// currently scanner shouldn't be null, but in the future this could
// be used to imply that range or bulk delete is unnecessary and we
// instead simply delete by row ID
// however it has been discovered the batch deletion doesn't work
// with Accumulo's WholeRowIterator so if there are mixed
// visibilities, meaning a single row with varying visibilities for
// different fields we would not be assured we are properly
// combining the visibilities of a single row without
// WholeRowIterator so therefore we need to backup to using the
// slower delete by row technique
final RowDeleter rowDeleter = createRowDeleter(readerParams.getIndex().getName(), readerParams.getAdapterStore(), readerParams.getInternalAdapterStore(), readerParams.getAdditionalAuthorizations());
if (rowDeleter != null) {
return new QueryAndDeleteByRow<>(rowDeleter, createReader(readerParams));
}
return new QueryAndDeleteByRow<>();
}
addConstraintsScanIteratorSettings(readerParams, scanner, options);
// removing the "novalue" iterator means the batch deleter will return
// values which is essential to maintaining stats
// this is applicable to accumulo versions < 1.9
scanner.removeScanIterator(BatchDeleter.class.getName() + ".NOVALUE");
// this is applicable to accumulo versions >= 1.9
scanner.removeScanIterator(BatchDeleter.class.getName().replaceAll("[.]", "_") + "_NOVALUE");
return new AccumuloDeleter<>((BatchDeleter) scanner, getClientSideFilterRanges(readerParams), readerParams.getRowTransformer(), readerParams.getIndex().getIndexStrategy().getPartitionKeyLength(), readerParams.isMixedVisibility() && !readerParams.isServersideAggregation(), readerParams.isClientsideRowMerging(), true);
}
use of org.locationtech.geowave.core.store.operations.RowDeleter in project geowave by locationtech.
the class HBaseOperations method deleteAll.
@Override
public boolean deleteAll(final String indexName, final String typeName, final Short adapterId, final String... additionalAuthorizations) {
RowDeleter deleter = null;
Iterable<Result> scanner = null;
try {
deleter = createRowDeleter(indexName, // these params aren't needed for hbase
null, null, additionalAuthorizations);
Index index = null;
try (final CloseableIterator<GeoWaveMetadata> it = createMetadataReader(MetadataType.INDEX).query(new MetadataQuery(StringUtils.stringToBinary(indexName), null, additionalAuthorizations))) {
if (!it.hasNext()) {
LOGGER.warn("Unable to find index to delete");
return false;
}
final GeoWaveMetadata indexMd = it.next();
index = (Index) URLClassloaderUtils.fromBinary(indexMd.getValue());
}
final Scan scan = new Scan();
scan.addFamily(StringUtils.stringToBinary(ByteArrayUtils.shortToString(adapterId)));
scanner = getScannedResults(scan, indexName);
for (final Result result : scanner) {
deleter.delete(new HBaseRow(result, index.getIndexStrategy().getPartitionKeyLength()));
}
return true;
} catch (final Exception e) {
LOGGER.warn("Unable to close deleter", e);
} finally {
if ((scanner != null) && (scanner instanceof ResultScanner)) {
((ResultScanner) scanner).close();
}
if (deleter != null) {
try {
deleter.close();
} catch (final Exception e) {
LOGGER.warn("Unable to close deleter", e);
}
}
}
return false;
}
Aggregations