Search in sources :

Example 1 with CountingListener

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();
}
Also used : CountingListener(org.locationtech.geogig.storage.BulkOpListener.CountingListener) RevObject(org.locationtech.geogig.api.RevObject) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase)

Example 2 with CountingListener

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);
}
Also used : CountingListener(org.locationtech.geogig.storage.BulkOpListener.CountingListener)

Example 3 with CountingListener

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());
}
Also used : CountingListener(org.locationtech.geogig.storage.BulkOpListener.CountingListener) RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) BulkOpListener(org.locationtech.geogig.storage.BulkOpListener) Nullable(javax.annotation.Nullable)

Aggregations

CountingListener (org.locationtech.geogig.storage.BulkOpListener.CountingListener)3 RevObject (org.locationtech.geogig.api.RevObject)2 Nullable (javax.annotation.Nullable)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 BulkOpListener (org.locationtech.geogig.storage.BulkOpListener)1 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)1