Search in sources :

Example 1 with AbstractAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding 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 AbstractAdapterPersistenceEncoding

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

the class ExpressionQueryFilter method accept.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public boolean accept(final CommonIndexModel indexModel, final IndexedPersistenceEncoding<?> persistenceEncoding) {
    if ((filter != null) && (indexModel != null) && (adapter != null) && (indexMapping != null)) {
        final Map<String, Object> fieldValues = Maps.newHashMap();
        if (!referencedFieldsInitialized) {
            initReferencedFields();
        }
        final PersistentDataset<?> commonData = persistenceEncoding.getCommonData();
        PersistentDataset<Object> adapterExtendedValues = null;
        for (final String field : referencedFields) {
            if (fieldValues.containsKey(field)) {
                continue;
            }
            if (fieldToIndexFieldMap.containsKey(field)) {
                final IndexFieldMapper<?, ?> mapper = fieldToIndexFieldMap.get(field);
                final Object indexValue = commonData.getValue(mapper.indexFieldName());
                ((IndexFieldMapper) mapper).toAdapter(indexValue, new MapRowBuilder(fieldValues));
            } else {
                final Object value = commonData.getValue(field);
                if (value != null) {
                    fieldValues.put(field, value);
                } else {
                    if (adapterExtendedValues == null) {
                        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());
                            }
                        }
                    }
                    fieldValues.put(field, adapterExtendedValues.getValue(field));
                }
            }
        }
        return filter.evaluate(fieldValues);
    }
    return true;
}
Also used : AbstractAdapterPersistenceEncoding(org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding) IndexFieldMapper(org.locationtech.geowave.core.store.api.IndexFieldMapper) MapRowBuilder(org.locationtech.geowave.core.store.adapter.MapRowBuilder)

Example 3 with AbstractAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding 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 4 with AbstractAdapterPersistenceEncoding

use of org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding 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

AbstractAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding)4 IndexedAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)3 MultiFieldPersistentDataset (org.locationtech.geowave.core.store.data.MultiFieldPersistentDataset)3 IndexImpl (org.locationtech.geowave.core.store.index.IndexImpl)2 MapRowBuilder (org.locationtech.geowave.core.store.adapter.MapRowBuilder)1 IndexFieldMapper (org.locationtech.geowave.core.store.api.IndexFieldMapper)1 PersistentDataset (org.locationtech.geowave.core.store.data.PersistentDataset)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1