Search in sources :

Example 1 with Deduplicator

use of org.locationtech.geogig.storage.Deduplicator in project GeoGig by boundlessgeo.

the class WalkGraph method runInternal.

@Override
public void runInternal(GeogigCLI cli) throws IOException {
    String ref;
    if (refList.isEmpty()) {
        ref = null;
    } else {
        ref = refList.get(0);
    }
    Deduplicator deduplicator = cli.getGeogig().command(CreateDeduplicator.class).call();
    try {
        Iterator<RevObject> iter = //
        cli.getGeogig().command(WalkGraphOp.class).setReference(//
        ref).setDeduplicator(//
        deduplicator).call();
        final ConsoleReader console = cli.getConsole();
        if (!iter.hasNext()) {
            if (ref == null) {
                console.println("The working tree is empty");
            } else {
                console.println("The specified path is empty");
            }
            return;
        }
        Function<RevObject, CharSequence> printFunctor = new Function<RevObject, CharSequence>() {

            @Override
            public CharSequence apply(RevObject input) {
                if (verbose) {
                    return String.format("%s: %s %s", input.getId(), input.getType(), input);
                } else {
                    return String.format("%s: %s", input.getId(), input.getType());
                }
            }
        };
        Iterator<CharSequence> lines = Iterators.transform(iter, printFunctor);
        while (lines.hasNext()) {
            console.println(lines.next());
        }
        console.flush();
    } finally {
        deduplicator.release();
    }
}
Also used : WalkGraphOp(org.locationtech.geogig.api.plumbing.WalkGraphOp) Function(com.google.common.base.Function) ConsoleReader(jline.console.ConsoleReader) RevObject(org.locationtech.geogig.api.RevObject) CreateDeduplicator(org.locationtech.geogig.api.plumbing.CreateDeduplicator) Deduplicator(org.locationtech.geogig.storage.Deduplicator) CreateDeduplicator(org.locationtech.geogig.api.plumbing.CreateDeduplicator)

Example 2 with Deduplicator

use of org.locationtech.geogig.storage.Deduplicator in project GeoGig by boundlessgeo.

the class HttpRemoteRepo method pushNewData.

/**
     * Push all new objects from the specified {@link Ref} to the remote.
     * 
     * @param ref the local ref that points to new commit data
     * @param refspec the remote branch to push to
     */
@Override
public void pushNewData(Ref ref, String refspec, ProgressListener progress) throws SynchronizationException {
    Optional<Ref> remoteRef = HttpUtils.getRemoteRef(repositoryURL, refspec);
    checkPush(ref, remoteRef);
    beginPush();
    progress.setDescription("Uploading objects to " + refspec);
    progress.setProgress(0);
    CommitTraverser traverser = getPushTraverser(remoteRef);
    traverser.traverse(ref.getObjectId());
    List<ObjectId> toSend = new LinkedList<ObjectId>(traverser.commits);
    Collections.reverse(toSend);
    Set<ObjectId> have = new HashSet<ObjectId>(traverser.have);
    Deduplicator deduplicator = deduplicationService.createDeduplicator();
    try {
        sendPackedObjects(toSend, have, deduplicator, progress);
    } finally {
        deduplicator.release();
    }
    ObjectId originalRemoteRefValue = ObjectId.NULL;
    if (remoteRef.isPresent()) {
        originalRemoteRefValue = remoteRef.get().getObjectId();
    }
    String nameToSet = remoteRef.isPresent() ? remoteRef.get().getName() : Ref.HEADS_PREFIX + refspec;
    endPush(nameToSet, ref.getObjectId(), originalRemoteRefValue.toString());
}
Also used : Ref(org.locationtech.geogig.api.Ref) ObjectId(org.locationtech.geogig.api.ObjectId) Deduplicator(org.locationtech.geogig.storage.Deduplicator) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

Deduplicator (org.locationtech.geogig.storage.Deduplicator)2 Function (com.google.common.base.Function)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 ConsoleReader (jline.console.ConsoleReader)1 ObjectId (org.locationtech.geogig.api.ObjectId)1 Ref (org.locationtech.geogig.api.Ref)1 RevObject (org.locationtech.geogig.api.RevObject)1 CreateDeduplicator (org.locationtech.geogig.api.plumbing.CreateDeduplicator)1 WalkGraphOp (org.locationtech.geogig.api.plumbing.WalkGraphOp)1