use of org.locationtech.geowave.core.store.entities.GeoWaveValue 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.GeoWaveValue in project geowave by locationtech.
the class AccumuloRow method setFieldValues.
private void setFieldValues(final List<Map<Key, Value>> fieldValueMapList) {
final List<GeoWaveValue> fieldValueList = new ArrayList();
for (final Map<Key, Value> kvMap : fieldValueMapList) {
for (final Entry<Key, Value> kv : kvMap.entrySet()) {
fieldValueList.add(new GeoWaveValueImpl(kv.getKey().getColumnQualifier().getBytes(), kv.getKey().getColumnVisibility().getBytes(), kv.getValue().get()));
}
}
fieldValues = new GeoWaveValue[fieldValueList.size()];
int i = 0;
for (final GeoWaveValue gwValue : fieldValueList) {
fieldValues[i++] = gwValue;
}
}
use of org.locationtech.geowave.core.store.entities.GeoWaveValue in project geowave by locationtech.
the class CassandraRow method getFieldValues.
private static GeoWaveValue[] getFieldValues(final Row row) {
final byte[] fieldMask = row.getByteBuffer(CassandraField.GW_FIELD_MASK_KEY.getFieldName()).array();
final byte[] value = row.getByteBuffer(CassandraField.GW_VALUE_KEY.getFieldName()).array();
final byte[] visibility = row.getByteBuffer(CassandraField.GW_FIELD_VISIBILITY_KEY.getFieldName()).array();
final GeoWaveValue[] fieldValues = new GeoWaveValueImpl[1];
fieldValues[0] = new GeoWaveValueImpl(fieldMask, visibility, value);
return fieldValues;
}
use of org.locationtech.geowave.core.store.entities.GeoWaveValue in project geowave by locationtech.
the class CassandraUtils method bindDataIndexInsertion.
public static BoundStatement[] bindDataIndexInsertion(final PreparedStatement insertionStatement, final GeoWaveRow row, final boolean visibilityEnabled) {
// the data ID becomes the partition key and the only other fields are the value and adapter ID
final byte[] partitionKey = getCassandraSafePartitionKey(row.getDataId());
final BoundStatement[] retVal = new BoundStatement[row.getFieldValues().length];
int i = 0;
for (final GeoWaveValue value : row.getFieldValues()) {
final ByteBuffer nanoBuffer = ByteBuffer.allocate(8);
nanoBuffer.putLong(0, Long.MAX_VALUE - System.nanoTime());
final BoundStatementBuilder s = insertionStatement.boundStatementBuilder();
s.set(CassandraField.GW_PARTITION_ID_KEY.getBindMarkerName(), ByteBuffer.wrap(partitionKey), ByteBuffer.class);
s.set(CassandraField.GW_ADAPTER_ID_KEY.getBindMarkerName(), row.getAdapterId(), Short.class);
s.set(CassandraField.GW_VALUE_KEY.getBindMarkerName(), ByteBuffer.wrap(DataIndexUtils.serializeDataIndexValue(value, visibilityEnabled)), ByteBuffer.class);
retVal[i] = s.build();
i++;
}
return retVal;
}
use of org.locationtech.geowave.core.store.entities.GeoWaveValue in project geowave by locationtech.
the class BaseConstraintsQuery method query.
@SuppressWarnings("unchecked")
@Override
public CloseableIterator<Object> query(final DataStoreOperations datastoreOperations, final DataStoreOptions options, final PersistentAdapterStore adapterStore, final AdapterIndexMappingStore mappingStore, final InternalAdapterStore internalAdapterStore, final double[] maxResolutionSubsamplingPerDimension, final double[] targetResolutionPerDimensionForHierarchicalIndex, final Integer limit, final Integer queryMaxRangeDecomposition, final boolean delete) {
if (isAggregation()) {
if ((options == null) || !options.isServerSideLibraryEnabled()) {
// Aggregate client-side
final CloseableIterator<Object> it = super.query(datastoreOperations, options, adapterStore, mappingStore, internalAdapterStore, maxResolutionSubsamplingPerDimension, targetResolutionPerDimensionForHierarchicalIndex, limit, queryMaxRangeDecomposition, false);
return BaseDataStoreUtils.aggregate(it, (Aggregation<?, ?, Object>) aggregation.getRight(), (DataTypeAdapter) aggregation.getLeft());
} else {
// incorrect results
if (!clientFilters.isEmpty()) {
final QueryFilter f = clientFilters.get(clientFilters.size() - 1);
if (f instanceof DedupeFilter) {
// in case the list is immutable or null we need to create a new mutable list
if (distributableFilters != null) {
distributableFilters = new ArrayList<>(distributableFilters);
} else {
distributableFilters = new ArrayList<>();
}
distributableFilters.add(f);
LOGGER.warn("Aggregating results when duplicates exist in the table may result in duplicate aggregation");
}
}
try (final RowReader<GeoWaveRow> reader = getReader(datastoreOperations, options, adapterStore, mappingStore, internalAdapterStore, maxResolutionSubsamplingPerDimension, targetResolutionPerDimensionForHierarchicalIndex, limit, queryMaxRangeDecomposition, GeoWaveRowIteratorTransformer.NO_OP_TRANSFORMER, false)) {
Object mergedAggregationResult = null;
final Aggregation<?, Object, Object> agg = (Aggregation<?, Object, Object>) aggregation.getValue();
if ((reader == null) || !reader.hasNext()) {
return new CloseableIterator.Empty();
} else {
while (reader.hasNext()) {
final GeoWaveRow row = reader.next();
for (final GeoWaveValue value : row.getFieldValues()) {
if ((value.getValue() != null) && (value.getValue().length > 0)) {
if (mergedAggregationResult == null) {
mergedAggregationResult = agg.resultFromBinary(value.getValue());
} else {
mergedAggregationResult = agg.merge(mergedAggregationResult, agg.resultFromBinary(value.getValue()));
}
}
}
}
return new CloseableIterator.Wrapper<>(Iterators.singletonIterator(mergedAggregationResult));
}
} catch (final Exception e) {
LOGGER.warn("Unable to close reader for aggregation", e);
}
}
}
return super.query(datastoreOperations, options, adapterStore, mappingStore, internalAdapterStore, maxResolutionSubsamplingPerDimension, targetResolutionPerDimensionForHierarchicalIndex, limit, queryMaxRangeDecomposition, delete);
}
Aggregations