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;
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations