use of org.locationtech.geowave.core.store.entities.GeoWaveRow in project geowave by locationtech.
the class DefaultStatisticVisibility method getVisibility.
@Override
public byte[] getVisibility(final T entry, final GeoWaveRow... kvs) {
if (kvs.length == 1 && kvs[0].getFieldValues().length == 1) {
return kvs[0].getFieldValues()[0].getVisibility();
}
int lowestOrdinal = Integer.MAX_VALUE;
byte[] lowestOrdinalVisibility = null;
for (final GeoWaveRow kv : kvs) {
for (final GeoWaveValue v : kv.getFieldValues()) {
final int pos = BitmaskUtils.getLowestFieldPosition(v.getFieldMask());
if (pos == 0) {
return v.getVisibility();
}
if (pos <= lowestOrdinal) {
lowestOrdinal = pos;
lowestOrdinalVisibility = v.getVisibility();
}
}
}
return lowestOrdinalVisibility;
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRow 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.entities.GeoWaveRow 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.entities.GeoWaveRow in project geowave by locationtech.
the class NativeEntryIteratorWrapper method findNext.
protected void findNext() {
while ((nextValue == null) && hasNextScannedResult()) {
final GeoWaveRow row = getNextEncodedResult();
final T decodedValue = decodeRow(row, clientFilters, index);
if (decodedValue != null) {
nextValue = decodedValue;
return;
}
}
}
use of org.locationtech.geowave.core.store.entities.GeoWaveRow in project geowave by locationtech.
the class AccumuloKeyValuePairGenerator method constructKeyValuePairs.
public List<KeyValue> constructKeyValuePairs(final T entry) {
final List<KeyValue> keyValuePairs = new ArrayList<>();
final GeoWaveRow[] rows = BaseDataStoreUtils.getGeoWaveRows(entry, adapter, indexMapping, index, visibilityHandler);
if ((rows != null) && (rows.length > 0)) {
for (final GeoWaveRow row : rows) {
final Mutation m = AccumuloWriter.rowToMutation(row);
for (final ColumnUpdate cu : m.getUpdates()) {
keyValuePairs.add(new KeyValue(new Key(m.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(), cu.getColumnVisibility(), cu.getTimestamp()), cu.getValue()));
}
}
}
return keyValuePairs;
}
Aggregations