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