Search in sources :

Example 1 with DataIndexReaderParams

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

the class DataIndexUtils method delete.

public static void delete(final DataStoreOperations operations, final PersistentAdapterStore adapterStore, final AdapterIndexMappingStore mappingStore, final InternalAdapterStore internalAdapterStore, final Pair<String[], InternalDataAdapter<?>> fieldSubsets, final Pair<InternalDataAdapter<?>, Aggregation<?, ?, ?>> aggregation, final String[] additionalAuthorizations, final ScanCallback<?, ?> scanCallback, final short adapterId, final byte[] startDataId, final byte[] endDataId) {
    // TODO within the datastores delete by range is not supported (the deletion logic expect Data
    // IDs to be non-null within reader params and deletions don't have logic for handling ranges
    // for now, although less efficient, let's query by prefix and then delete by the returned IDs
    final DataIndexReaderParams readerParams = new DataIndexReaderParamsBuilder<>(adapterStore, mappingStore, internalAdapterStore).additionalAuthorizations(additionalAuthorizations).isAuthorizationsLimiting(false).adapterId(adapterId).dataIdsByRange(startDataId, endDataId).fieldSubsets(fieldSubsets).aggregation(aggregation).build();
    final List<byte[]> dataIds = new ArrayList<>();
    try (RowReader<GeoWaveRow> reader = operations.createReader(readerParams)) {
        while (reader.hasNext()) {
            dataIds.add(reader.next().getDataId());
        }
    }
    delete(operations, adapterStore, mappingStore, internalAdapterStore, fieldSubsets, aggregation, additionalAuthorizations, scanCallback, adapterId, dataIds.toArray(new byte[dataIds.size()][]));
}
Also used : GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) ArrayList(java.util.ArrayList) DataIndexReaderParams(org.locationtech.geowave.core.store.operations.DataIndexReaderParams)

Example 2 with DataIndexReaderParams

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

the class DataIndexUtils method delete.

public static void delete(final DataStoreOperations operations, final PersistentAdapterStore adapterStore, final AdapterIndexMappingStore mappingStore, final InternalAdapterStore internalAdapterStore, final Pair<String[], InternalDataAdapter<?>> fieldSubsets, final Pair<InternalDataAdapter<?>, Aggregation<?, ?, ?>> aggregation, final String[] additionalAuthorizations, final ScanCallback scanCallback, final short adapterId, final byte[]... dataIds) {
    final DataIndexReaderParams readerParams = new DataIndexReaderParamsBuilder<>(adapterStore, mappingStore, internalAdapterStore).additionalAuthorizations(additionalAuthorizations).isAuthorizationsLimiting(false).adapterId(adapterId).dataIds(dataIds).fieldSubsets(fieldSubsets).aggregation(aggregation).build();
    if (scanCallback != null) {
        // callback but for now we can explicitly read before deleting)
        try (RowReader<GeoWaveRow> rowReader = operations.createReader(readerParams)) {
            final NativeEntryIteratorWrapper scanCallBackIterator = new NativeEntryIteratorWrapper(adapterStore, mappingStore, DataIndexUtils.DATA_ID_INDEX, rowReader, null, scanCallback, BaseDataStoreUtils.getFieldBitmask(fieldSubsets, DataIndexUtils.DATA_ID_INDEX), null, !BaseDataStoreUtils.isCommonIndexAggregation(aggregation), null);
            // just drain the iterator so the scan callback is properly exercised
            scanCallBackIterator.forEachRemaining(it -> {
            });
        }
    }
    operations.delete(readerParams);
}
Also used : GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) DataIndexReaderParams(org.locationtech.geowave.core.store.operations.DataIndexReaderParams) NativeEntryIteratorWrapper(org.locationtech.geowave.core.store.util.NativeEntryIteratorWrapper)

Aggregations

GeoWaveRow (org.locationtech.geowave.core.store.entities.GeoWaveRow)2 DataIndexReaderParams (org.locationtech.geowave.core.store.operations.DataIndexReaderParams)2 ArrayList (java.util.ArrayList)1 NativeEntryIteratorWrapper (org.locationtech.geowave.core.store.util.NativeEntryIteratorWrapper)1