use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class AddOpTest method testAddNewPathUsingPathFilter.
@Test
public void testAddNewPathUsingPathFilter() throws Exception {
insert(points1);
insert(points2);
geogig.command(AddOp.class).addPattern("Points/Points.1").call();
List<DiffEntry> unstaged = toList(repo.index().getStaged(null));
assertEquals(unstaged.toString(), 2, unstaged.size());
assertEquals(ChangeType.ADDED, unstaged.get(0).changeType());
assertEquals(RevObject.TYPE.TREE, unstaged.get(0).getNewObject().getType());
assertEquals("Points", unstaged.get(0).newName());
RevFeatureType ft = RevFeatureTypeImpl.build(pointsType);
ObjectId expectedTreeMdId = ft.getId();
assertEquals(expectedTreeMdId, unstaged.get(0).getNewObject().getMetadataId());
assertEquals(ChangeType.ADDED, unstaged.get(1).changeType());
assertEquals(RevObject.TYPE.FEATURE, unstaged.get(1).getNewObject().getType());
assertEquals("Points.1", unstaged.get(1).newName());
assertFalse("feature node's metadata id should not be set, as it uses the parent tree one", unstaged.get(1).getNewObject().getNode().getMetadataId().isPresent());
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class RevTreeSerializationTest method testRoundTripBucketsFull.
@Test
public void testRoundTripBucketsFull() {
ObjectId id = ObjectId.forString("fake");
long size = 100000000;
int childTreeCount = 0;
Map<Integer, Bucket> bucketTrees = createBuckets(32);
final RevTreeImpl tree = RevTreeImpl.createNodeTree(id, size, childTreeCount, bucketTrees);
RevTree roundTripped = read(tree.getId(), write(tree));
assertTreesAreEqual(tree, roundTripped);
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class SQLiteGraphDatabase method put.
@Override
public boolean put(ObjectId commitId, ImmutableList<ObjectId> parentIds) {
String node = commitId.toString();
boolean added = put(node, cx);
// TODO: if node was node added should we severe existing parent relationships?
for (ObjectId p : parentIds) {
relate(node, p.toString(), cx);
}
return added;
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class MongoObjectDatabase method putAll.
@Override
public void putAll(Iterator<? extends RevObject> objects, BulkOpListener listener) {
Preconditions.checkNotNull(executor, "executor service not set");
if (!objects.hasNext()) {
return;
}
final int bulkSize = 1000;
final int maxRunningTasks = 10;
final AtomicBoolean cancelCondition = new AtomicBoolean();
List<ObjectId> ids = Lists.newArrayListWithCapacity(bulkSize);
List<Future<?>> runningTasks = new ArrayList<Future<?>>(maxRunningTasks);
BulkWriteOperation bulkOperation = collection.initializeOrderedBulkOperation();
try {
while (objects.hasNext()) {
RevObject object = objects.next();
bulkOperation.insert(toDocument(object));
ids.add(object.getId());
if (ids.size() == bulkSize || !objects.hasNext()) {
InsertTask task = new InsertTask(bulkOperation, listener, ids, cancelCondition);
runningTasks.add(executor.submit(task));
if (objects.hasNext()) {
bulkOperation = collection.initializeOrderedBulkOperation();
ids = Lists.newArrayListWithCapacity(bulkSize);
}
}
if (runningTasks.size() == maxRunningTasks) {
waitForTasks(runningTasks);
}
}
waitForTasks(runningTasks);
} catch (RuntimeException e) {
cancelCondition.set(true);
throw e;
}
}
use of org.locationtech.geogig.api.ObjectId in project GeoGig by boundlessgeo.
the class MongoStagingDatabase method getConflict.
@Override
public Optional<Conflict> getConflict(@Nullable String namespace, String path) {
DBObject query = new BasicDBObject();
query.put("path", path);
if (namespace != null) {
query.put("namespace", namespace);
}
DBObject result = conflicts.findOne(query);
if (result == null) {
return Optional.absent();
} else {
ObjectId ancestor = ObjectId.valueOf((String) result.get("ancestor"));
ObjectId ours = ObjectId.valueOf((String) result.get("ours"));
ObjectId theirs = ObjectId.valueOf((String) result.get("theirs"));
return Optional.of(new Conflict(path, ancestor, ours, theirs));
}
}
Aggregations