Search in sources :

Example 1 with GeoWaveValue

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;
}
Also used : GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue)

Example 2 with GeoWaveValue

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;
    }
}
Also used : GeoWaveValueImpl(org.locationtech.geowave.core.store.entities.GeoWaveValueImpl) ArrayList(java.util.ArrayList) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue) Value(org.apache.accumulo.core.data.Value) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue) Key(org.apache.accumulo.core.data.Key) GeoWaveKey(org.locationtech.geowave.core.store.entities.GeoWaveKey)

Example 3 with GeoWaveValue

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;
}
Also used : GeoWaveValueImpl(org.locationtech.geowave.core.store.entities.GeoWaveValueImpl) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue)

Example 4 with GeoWaveValue

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;
}
Also used : BoundStatementBuilder(com.datastax.oss.driver.api.core.cql.BoundStatementBuilder) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue) BoundStatement(com.datastax.oss.driver.api.core.cql.BoundStatement) ByteBuffer(java.nio.ByteBuffer)

Example 5 with GeoWaveValue

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);
}
Also used : GeoWaveRow(org.locationtech.geowave.core.store.entities.GeoWaveRow) GeoWaveValue(org.locationtech.geowave.core.store.entities.GeoWaveValue) Aggregation(org.locationtech.geowave.core.store.api.Aggregation) QueryFilter(org.locationtech.geowave.core.store.query.filter.QueryFilter) CoordinateRangeQueryFilter(org.locationtech.geowave.core.store.query.filter.CoordinateRangeQueryFilter) DedupeFilter(org.locationtech.geowave.core.store.query.filter.DedupeFilter)

Aggregations

GeoWaveValue (org.locationtech.geowave.core.store.entities.GeoWaveValue)21 GeoWaveValueImpl (org.locationtech.geowave.core.store.entities.GeoWaveValueImpl)8 ArrayList (java.util.ArrayList)7 ByteArray (org.locationtech.geowave.core.index.ByteArray)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GeoWaveKeyImpl (org.locationtech.geowave.core.store.entities.GeoWaveKeyImpl)3 GeoWaveRow (org.locationtech.geowave.core.store.entities.GeoWaveRow)3 GeoWaveRowImpl (org.locationtech.geowave.core.store.entities.GeoWaveRowImpl)3 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)2 BoundStatement (com.datastax.oss.driver.api.core.cql.BoundStatement)2 ByteBuffer (java.nio.ByteBuffer)2 Iterator (java.util.Iterator)2 Entry (java.util.Map.Entry)2 Key (org.apache.accumulo.core.data.Key)2 Value (org.apache.accumulo.core.data.Value)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Put (org.apache.hadoop.hbase.client.Put)2 RowMutations (org.apache.hadoop.hbase.client.RowMutations)2