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