Search in sources :

Example 1 with MapRowBuilder

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

Aggregations

AbstractAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.AbstractAdapterPersistenceEncoding)1 MapRowBuilder (org.locationtech.geowave.core.store.adapter.MapRowBuilder)1 IndexFieldMapper (org.locationtech.geowave.core.store.api.IndexFieldMapper)1