Search in sources :

Example 1 with WriteResults

use of org.locationtech.geowave.core.store.api.WriteResults in project geowave by locationtech.

the class IndexCompositeWriter method internalWrite.

protected WriteResults internalWrite(final T entry, final Function<Writer<T>, WriteResults> internalWriter) {
    final Map<String, List<SinglePartitionInsertionIds>> insertionIdsPerIndex = new HashMap<>();
    for (final Writer<T> indexWriter : writers) {
        final WriteResults ids = internalWriter.apply(indexWriter);
        for (final String indexName : ids.getWrittenIndexNames()) {
            List<SinglePartitionInsertionIds> partitionInsertionIds = insertionIdsPerIndex.get(indexName);
            if (partitionInsertionIds == null) {
                partitionInsertionIds = new ArrayList<>();
                insertionIdsPerIndex.put(indexName, partitionInsertionIds);
            }
            partitionInsertionIds.addAll(ids.getInsertionIdsWritten(indexName).getPartitionKeys());
        }
    }
    return new WriteResults(Maps.transformValues(insertionIdsPerIndex, v -> new InsertionIds(v)));
}
Also used : Arrays(java.util.Arrays) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) Function(java.util.function.Function) Maps(com.google.common.collect.Maps) ArrayList(java.util.ArrayList) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) List(java.util.List) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) Writer(org.locationtech.geowave.core.store.api.Writer) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) Map(java.util.Map) Index(org.locationtech.geowave.core.store.api.Index) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with WriteResults

use of org.locationtech.geowave.core.store.api.WriteResults in project geowave by locationtech.

the class BaseDataStoreIngestDriver method write.

@Override
protected void write(final Writer writer, final GeoWaveData<?> geowaveData) {
    Object obj = geowaveData.getValue();
    if (ingestOptions.getTransform() != null) {
        obj = ((Function) ingestOptions.getTransform()).apply(obj);
    }
    if ((ingestOptions.getFilter() != null) && !((Predicate) ingestOptions.getFilter()).test(geowaveData.getValue())) {
        return;
    }
    final WriteResults results = writer.write(obj);
    if (ingestOptions.getCallback() != null) {
        ((IngestCallback) ingestOptions.getCallback()).dataWritten(results, obj);
    }
}
Also used : WriteResults(org.locationtech.geowave.core.store.api.WriteResults) IngestCallback(org.locationtech.geowave.core.store.api.IngestOptions.IngestCallback) Predicate(java.util.function.Predicate)

Example 3 with WriteResults

use of org.locationtech.geowave.core.store.api.WriteResults in project geowave by locationtech.

the class IndependentAdapterIndexWriter method internalWrite.

private WriteResults internalWrite(final T entry, final Function<T, WriteResults> internalWriter) {
    final Iterator<T> indexedEntries = adapter.convertToIndex(index, entry);
    final Map<String, List<SinglePartitionInsertionIds>> insertionIdsPerIndex = new HashMap<>();
    while (indexedEntries.hasNext()) {
        final WriteResults ids = internalWriter.apply(indexedEntries.next());
        for (final String indexName : ids.getWrittenIndexNames()) {
            List<SinglePartitionInsertionIds> partitionInsertionIds = insertionIdsPerIndex.get(indexName);
            if (partitionInsertionIds == null) {
                partitionInsertionIds = new ArrayList<>();
                insertionIdsPerIndex.put(indexName, partitionInsertionIds);
            }
            partitionInsertionIds.addAll(ids.getInsertionIdsWritten(indexName).getPartitionKeys());
        }
    }
    return new WriteResults(Maps.transformValues(insertionIdsPerIndex, v -> new InsertionIds(v)));
}
Also used : SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) Iterator(java.util.Iterator) IndexDependentDataAdapter(org.locationtech.geowave.core.store.adapter.IndexDependentDataAdapter) HashMap(java.util.HashMap) Function(java.util.function.Function) Maps(com.google.common.collect.Maps) ArrayList(java.util.ArrayList) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) List(java.util.List) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) Writer(org.locationtech.geowave.core.store.api.Writer) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) Map(java.util.Map) Index(org.locationtech.geowave.core.store.api.Index) WriteResults(org.locationtech.geowave.core.store.api.WriteResults) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) HashMap(java.util.HashMap) SinglePartitionInsertionIds(org.locationtech.geowave.core.index.SinglePartitionInsertionIds) InsertionIds(org.locationtech.geowave.core.index.InsertionIds) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

WriteResults (org.locationtech.geowave.core.store.api.WriteResults)3 Maps (com.google.common.collect.Maps)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Function (java.util.function.Function)2 InsertionIds (org.locationtech.geowave.core.index.InsertionIds)2 SinglePartitionInsertionIds (org.locationtech.geowave.core.index.SinglePartitionInsertionIds)2 Index (org.locationtech.geowave.core.store.api.Index)2 VisibilityHandler (org.locationtech.geowave.core.store.api.VisibilityHandler)2 Writer (org.locationtech.geowave.core.store.api.Writer)2 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 Predicate (java.util.function.Predicate)1 IndexDependentDataAdapter (org.locationtech.geowave.core.store.adapter.IndexDependentDataAdapter)1 IngestCallback (org.locationtech.geowave.core.store.api.IngestOptions.IngestCallback)1