Search in sources :

Example 1 with PartialAsyncPersistenceEncoding

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

Aggregations

IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 FullAsyncPersistenceEncoding (org.locationtech.geowave.core.store.adapter.FullAsyncPersistenceEncoding)1 IndexedAdapterPersistenceEncoding (org.locationtech.geowave.core.store.adapter.IndexedAdapterPersistenceEncoding)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