Search in sources :

Example 1 with IndexCompositeWriter

use of org.locationtech.geowave.core.store.index.writer.IndexCompositeWriter in project geowave by locationtech.

the class BaseDataStore method createWriter.

@SuppressWarnings("unchecked")
private <T> Writer<T> createWriter(final InternalDataAdapter<T> adapter, final VisibilityHandler visibilityHandler, final boolean writingOriginalData, final Index... indices) {
    final boolean secondaryIndex = writingOriginalData && baseOptions.isSecondaryIndexing() && DataIndexUtils.adapterSupportsDataIndex(adapter);
    final Writer<T>[] writers = new Writer[secondaryIndex ? indices.length + 1 : indices.length];
    final VisibilityHandler resolvedVisibilityHandler = resolveVisibilityHandler(adapter, visibilityHandler);
    int i = 0;
    if (secondaryIndex) {
        final DataStoreCallbackManager callbackManager = new DataStoreCallbackManager(statisticsStore, true);
        final AdapterToIndexMapping indexMapping = indexMappingStore.getMapping(adapter.getAdapterId(), DataIndexUtils.DATA_ID_INDEX.getName());
        final List<IngestCallback<T>> callbacks = Collections.singletonList(callbackManager.getIngestCallback(adapter, indexMapping, DataIndexUtils.DATA_ID_INDEX));
        final IngestCallbackList<T> callbacksList = new IngestCallbackList<>(callbacks);
        writers[i++] = createDataIndexWriter(adapter, indexMapping, resolvedVisibilityHandler, baseOperations, baseOptions, callbacksList, callbacksList);
    }
    for (final Index index : indices) {
        final DataStoreCallbackManager callbackManager = new DataStoreCallbackManager(statisticsStore, i == 0);
        callbackManager.setPersistStats(baseOptions.isPersistDataStatistics());
        final AdapterToIndexMapping indexMapping = indexMappingStore.getMapping(adapter.getAdapterId(), index.getName());
        final List<IngestCallback<T>> callbacks = writingOriginalData ? Collections.singletonList(callbackManager.getIngestCallback(adapter, indexMapping, index)) : Collections.emptyList();
        final IngestCallbackList<T> callbacksList = new IngestCallbackList<>(callbacks);
        writers[i] = createIndexWriter(adapter, indexMapping, index, resolvedVisibilityHandler, baseOperations, baseOptions, callbacksList, callbacksList);
        if (adapter.getAdapter() instanceof IndexDependentDataAdapter) {
            writers[i] = new IndependentAdapterIndexWriter<>((IndexDependentDataAdapter<T>) adapter.getAdapter(), index, resolvedVisibilityHandler, writers[i]);
        }
        i++;
    }
    return new IndexCompositeWriter<>(writers);
}
Also used : IngestCallbackList(org.locationtech.geowave.core.store.callback.IngestCallbackList) AdapterToIndexMapping(org.locationtech.geowave.core.store.AdapterToIndexMapping) Index(org.locationtech.geowave.core.store.api.Index) IndexCompositeWriter(org.locationtech.geowave.core.store.index.writer.IndexCompositeWriter) IndexDependentDataAdapter(org.locationtech.geowave.core.store.adapter.IndexDependentDataAdapter) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) IngestCallback(org.locationtech.geowave.core.store.callback.IngestCallback) RowWriter(org.locationtech.geowave.core.store.operations.RowWriter) Writer(org.locationtech.geowave.core.store.api.Writer) IndexCompositeWriter(org.locationtech.geowave.core.store.index.writer.IndexCompositeWriter) MetadataWriter(org.locationtech.geowave.core.store.operations.MetadataWriter) IndependentAdapterIndexWriter(org.locationtech.geowave.core.store.index.writer.IndependentAdapterIndexWriter)

Aggregations

AdapterToIndexMapping (org.locationtech.geowave.core.store.AdapterToIndexMapping)1 IndexDependentDataAdapter (org.locationtech.geowave.core.store.adapter.IndexDependentDataAdapter)1 Index (org.locationtech.geowave.core.store.api.Index)1 VisibilityHandler (org.locationtech.geowave.core.store.api.VisibilityHandler)1 Writer (org.locationtech.geowave.core.store.api.Writer)1 IngestCallback (org.locationtech.geowave.core.store.callback.IngestCallback)1 IngestCallbackList (org.locationtech.geowave.core.store.callback.IngestCallbackList)1 IndependentAdapterIndexWriter (org.locationtech.geowave.core.store.index.writer.IndependentAdapterIndexWriter)1 IndexCompositeWriter (org.locationtech.geowave.core.store.index.writer.IndexCompositeWriter)1 MetadataWriter (org.locationtech.geowave.core.store.operations.MetadataWriter)1 RowWriter (org.locationtech.geowave.core.store.operations.RowWriter)1