Search in sources :

Example 1 with IndexedAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding in project geowave by locationtech.

the class AggregationIterator method aggregateRow.

protected void aggregateRow(final Text currentRow, final CommonIndexModel model, final CommonIndexedPersistenceEncoding persistenceEncoding) {
    if (adapter == null) {
        aggregationFunction.aggregate(null, persistenceEncoding);
        endRowOfAggregation = currentRow;
    } else if (((Short) (persistenceEncoding.getInternalAdapterId())).equals((adapter.getAdapterId()))) {
        final PersistentDataset<Object> adapterExtendedValues = new MultiFieldPersistentDataset<>();
        if (persistenceEncoding instanceof AbstractAdapterPersistenceEncoding) {
            ((AbstractAdapterPersistenceEncoding) persistenceEncoding).convertUnknownValues(adapter, model);
            final PersistentDataset<Object> existingExtValues = ((AbstractAdapterPersistenceEncoding) persistenceEncoding).getAdapterExtendedData();
            if (existingExtValues != null) {
                adapterExtendedValues.addValues(existingExtValues.getValues());
            }
        }
        final IndexedAdapterPersistenceEncoding encoding = new IndexedAdapterPersistenceEncoding(persistenceEncoding.getInternalAdapterId(), persistenceEncoding.getDataId(), persistenceEncoding.getInsertionPartitionKey(), persistenceEncoding.getInsertionSortKey(), persistenceEncoding.getDuplicateCount(), persistenceEncoding.getCommonData(), new MultiFieldPersistentDataset<byte[]>(), adapterExtendedValues);
        // the data adapter can't use the numeric index strategy and only
        // the common index model to decode which is the case for feature
        // data, we pass along a null strategy to eliminate the necessity to
        // send a serialization of the strategy in the options of this
        // iterator
        final Object row = adapter.decode(encoding, indexMapping, new IndexImpl(null, model));
        if (row != null) {
            // for now ignore field info
            aggregationFunction.aggregate(adapter, row);
            endRowOfAggregation = currentRow;
        }
    }
}
Also used : AbstractAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding) PersistentDataset(org.locationtech.geowave.core.store.data.PersistentDataset) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset)

Example 2 with IndexedAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding in project geowave by locationtech.

the class CQLQueryFilterTest method getEncodings.

private static List<IndexedAdapterPersistenceEncoding> getEncodings(final Index index, final AdapterPersistenceEncoding encoding) {
    final InsertionIds ids = encoding.getInsertionIds(index);
    final ArrayList<IndexedAdapterPersistenceEncoding> encodings = new ArrayList<>();
    for (final SinglePartitionInsertionIds partitionIds : ids.getPartitionKeys()) {
        for (final byte[] sortKey : partitionIds.getSortKeys()) {
            encodings.add(new IndexedAdapterPersistenceEncoding(encoding.getInternalAdapterId(), encoding.getDataId(), partitionIds.getPartitionKey(), sortKey, ids.getSize(), encoding.getCommonData(), encoding.getUnknownData(), encoding.getAdapterExtendedData()));
        }
    }
    return encodings;
}
Also used : SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) ArrayList(java.util.ArrayList) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)

Example 3 with IndexedAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding in project geowave by locationtech.

the class BaseDataStoreUtils method getDecodedRow.

/**
 * build a persistence encoding object first, pass it through the client filters and if its
 * accepted, use the data adapter to decode the persistence model into the native data type
 */
private static <T> Object getDecodedRow(final GeoWaveRow row, final IntermediaryReadEntryInfo<T> decodePackage, final byte[] fieldSubsetBitmask, final QueryFilter[] clientFilters, final ScanCallback<T, GeoWaveRow> scanCallback, final DataIndexRetrieval dataIndexRetrieval) {
    final boolean isSecondaryIndex = dataIndexRetrieval != null;
    final IndexedAdapterPersistenceEncoding encodedRow;
    if (isSecondaryIndex) {
        // this implies its a Secondary Index and the actual values must be looked up
        if (dataIndexRetrieval instanceof BatchDataIndexRetrieval) {
            if (decodePackage.getIndex().getIndexModel().useInSecondaryIndex()) {
                encodedRow = new PartialAsyncPersistenceEncoding(decodePackage.getDataAdapter().getAdapterId(), row.getDataId(), row.getPartitionKey(), row.getSortKey(), row.getNumberOfDuplicates(), (BatchDataIndexRetrieval) dataIndexRetrieval, decodePackage.getDataAdapter(), decodePackage.getIndex().getIndexModel(), decodePackage.getIndexMapping(), fieldSubsetBitmask, Suppliers.memoize(() -> dataIndexRetrieval.getData(decodePackage.getDataAdapter().getAdapterId(), row.getDataId())));
            } else {
                encodedRow = new FullAsyncPersistenceEncoding(decodePackage.getDataAdapter().getAdapterId(), row.getDataId(), row.getPartitionKey(), row.getSortKey(), row.getNumberOfDuplicates(), (BatchDataIndexRetrieval) dataIndexRetrieval);
            }
        } else {
            encodedRow = new LazyReadPersistenceEncoding(decodePackage.getDataAdapter().getAdapterId(), row.getDataId(), row.getPartitionKey(), row.getSortKey(), row.getNumberOfDuplicates(), decodePackage.getDataAdapter(), decodePackage.getIndex().getIndexModel(), decodePackage.getIndexMapping(), fieldSubsetBitmask, Suppliers.memoize(() -> dataIndexRetrieval.getData(decodePackage.getDataAdapter().getAdapterId(), row.getDataId())));
        }
    } else {
        encodedRow = new LazyReadPersistenceEncoding(decodePackage.getDataAdapter().getAdapterId(), row.getDataId(), row.getPartitionKey(), row.getSortKey(), row.getNumberOfDuplicates(), decodePackage.getDataAdapter(), decodePackage.getIndex().getIndexModel(), decodePackage.getIndexMapping(), fieldSubsetBitmask, row.getFieldValues(), false);
    }
    final BiFunction<IndexedAdapterPersistenceEncoding, Integer, Object> function = ((r, initialFilter) -> {
        final int i = clientFilterProgress(clientFilters, decodePackage.getIndex().getIndexModel(), r, initialFilter);
        if (i < 0) {
            if (!decodePackage.isDecodeRow()) {
                return r;
            }
            final T decodedRow = decodePackage.getDataAdapter().decode(r, decodePackage.getIndexMapping(), isSecondaryIndex ? DataIndexUtils.DATA_ID_INDEX : decodePackage.getIndex());
            if (r.isAsync()) {
                return i;
            }
            if ((scanCallback != null)) {
                scanCallback.entryScanned(decodedRow, row);
            }
            return decodedRow;
        }
        if (r.isAsync()) {
            return i;
        }
        return null;
    });
    final Object obj = function.apply(encodedRow, 0);
    if ((obj instanceof Integer) && encodedRow.isAsync()) {
        // the data will not need to be repeated
        return (((AsyncPersistenceEncoding) encodedRow).getFieldValuesFuture().thenApply(fv -> new LazyReadPersistenceEncoding(decodePackage.getDataAdapter().getAdapterId(), row.getDataId(), row.getPartitionKey(), row.getSortKey(), row.getNumberOfDuplicates(), decodePackage.getDataAdapter(), decodePackage.getIndex().getIndexModel(), decodePackage.getIndexMapping(), fieldSubsetBitmask, fv, true))).thenApply((r) -> function.apply(r, (Integer) obj));
    }
    return obj;
}
Also used : BatchDataIndexRetrieval(org.locationtech.geowave.core.store.base.dataidx.BatchDataIndexRetrieval) PartialAsyncPersistenceEncoding(org.locationtech.geowave.core.store.adapter.PartialAsyncPersistenceEncoding) LazyReadPersistenceEncoding(org.locationtech.geowave.core.store.adapter.LazyReadPersistenceEncoding) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding) FullAsyncPersistenceEncoding(org.locationtech.geowave.core.store.adapter.FullAsyncPersistenceEncoding) IndexDimensionHint(org.locationtech.geowave.core.index.IndexDimensionHint)

Example 4 with IndexedAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding in project geowave by locationtech.

the class HBaseDistributableFilter method getAdapterEncoding.

public IndexedAdapterPersistenceEncoding getAdapterEncoding(final InternalDataAdapter<?> dataAdapter) {
    final PersistentDataset<Object> adapterExtendedValues = new MultiFieldPersistentDataset<>();
    if (persistenceEncoding instanceof AbstractAdapterPersistenceEncoding) {
        ((AbstractAdapterPersistenceEncoding) persistenceEncoding).convertUnknownValues(dataAdapter, model);
        final PersistentDataset<Object> existingExtValues = ((AbstractAdapterPersistenceEncoding) persistenceEncoding).getAdapterExtendedData();
        if (existingExtValues != null) {
            adapterExtendedValues.addValues(existingExtValues.getValues());
        }
    }
    adapterEncoding = new IndexedAdapterPersistenceEncoding(persistenceEncoding.getInternalAdapterId(), persistenceEncoding.getDataId(), persistenceEncoding.getInsertionPartitionKey(), persistenceEncoding.getInsertionSortKey(), persistenceEncoding.getDuplicateCount(), persistenceEncoding.getCommonData(), new MultiFieldPersistentDataset<byte[]>(), adapterExtendedValues);
    return adapterEncoding;
}
Also used : AbstractAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)

Example 5 with IndexedAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding in project geowave by locationtech.

the class CQLQueryFilter method accept.

@Override
public boolean accept(final CommonIndexModel indexModel, final IndexedPersistenceEncoding persistenceEncoding) {
    if ((filter != null) && (indexModel != null) && (adapter != null)) {
        final PersistentDataset<Object> adapterExtendedValues = new MultiFieldPersistentDataset<>();
        if (persistenceEncoding instanceof AbstractAdapterPersistenceEncoding) {
            ((AbstractAdapterPersistenceEncoding) persistenceEncoding).convertUnknownValues(adapter, indexModel);
            final PersistentDataset<Object> existingExtValues = ((AbstractAdapterPersistenceEncoding) persistenceEncoding).getAdapterExtendedData();
            if (persistenceEncoding.isAsync()) {
                return false;
            }
            if (existingExtValues != null) {
                adapterExtendedValues.addValues(existingExtValues.getValues());
            }
        }
        final IndexedAdapterPersistenceEncoding encoding = new IndexedAdapterPersistenceEncoding(persistenceEncoding.getInternalAdapterId(), persistenceEncoding.getDataId(), persistenceEncoding.getInsertionPartitionKey(), persistenceEncoding.getInsertionSortKey(), persistenceEncoding.getDuplicateCount(), persistenceEncoding.getCommonData(), new MultiFieldPersistentDataset<byte[]>(), adapterExtendedValues);
        final SimpleFeature feature = (SimpleFeature) adapter.decode(encoding, indexMapping, new IndexImpl(// because we
        null, // options of this iterator
        indexModel));
        if (feature == null) {
            return false;
        }
        return filter.evaluate(feature);
    }
    return true;
}
Also used : AbstractAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding) MultiFieldPersistentDataset(org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) IndexedAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Aggregations

IndexedAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)5 AbstractAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding)3 MultiFieldPersistentDataset (org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset)3 IndexImpl (org.locationtech.geowave.core.store.index.IndexImpl)2 ArrayList (java.util.ArrayList)1 IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)1 SinglePartitionInsertionIds (org.locationtech.geowave.core.index.SinglePartitionInsertionIds)1 FullAsyncPersistenceEncoding (org.locationtech.geowave.core.store.adapter.FullAsyncPersistenceEncoding)1 LazyReadPersistenceEncoding (org.locationtech.geowave.core.store.adapter.LazyReadPersistenceEncoding)1 PartialAsyncPersistenceEncoding (org.locationtech.geowave.core.store.adapter.PartialAsyncPersistenceEncoding)1 BatchDataIndexRetrieval (org.locationtech.geowave.core.store.base.dataidx.BatchDataIndexRetrieval)1 PersistentDataset (org.locationtech.geowave.core.store.data.PersistentDataset)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1