use of org.locationtech.geogig.storage.BulkOpListener.CountingListener in project GeoGig by boundlessgeo.
the class BinaryPackedChanges method ingest.
/**
* Read in the changes from the provided input stream and call the provided callback for each
* change. The input stream represents the output of another {@code BinaryPackedChanges}
* instance.
*
* @param in the stream to read from
* @param callback the callback to call for each item
*/
public void ingest(final InputStream in, Callback callback) {
PacketReadingIterator readingIterator = new PacketReadingIterator(in);
Iterator<RevObject> asObjects = asObjects(readingIterator, callback);
ObjectDatabase objectDatabase = repository.objectDatabase();
CountingListener listener = BulkOpListener.newCountingListener();
objectDatabase.putAll(asObjects, listener);
LOGGER.info("Ingested %,d objects. Inserted: %,d. Already existing: %,d\n", listener.inserted() + listener.found(), listener.inserted(), listener.found());
this.filtered = readingIterator.isFiltered();
}
use of org.locationtech.geogig.storage.BulkOpListener.CountingListener in project GeoGig by boundlessgeo.
the class LocalRemoteRepo method copy.
private void copy(Set<ObjectId> ids, ObjectDatabase from, ObjectDatabase to, ProgressListener progress) {
if (ids.isEmpty()) {
return;
}
CountingListener countingListener = BulkOpListener.newCountingListener();
to.putAll(from.getAll(ids), countingListener);
int inserted = countingListener.inserted();
progress.setProgress(progress.getProgress() + inserted);
}
use of org.locationtech.geogig.storage.BulkOpListener.CountingListener in project GeoGig by boundlessgeo.
the class BinaryPackedObjects method ingest.
/**
* @return the number of objects parsed from the input stream
*/
public IngestResults ingest(final InputStream in, final Callback callback) {
Iterator<RevObject> objects = streamToObjects(in);
BulkOpListener listener = new BulkOpListener() {
@Override
public void inserted(final ObjectId objectId, @Nullable Integer storageSizeBytes) {
callback.callback(new Supplier<RevObject>() {
@Override
public RevObject get() {
return database.get(objectId);
}
});
}
};
CountingListener countingListener = BulkOpListener.newCountingListener();
listener = BulkOpListener.composite(countingListener, listener);
database.putAll(objects, listener);
return new IngestResults(countingListener.inserted(), countingListener.found());
}
Aggregations