use of org.locationtech.geogig.api.Bucket in project GeoGig by boundlessgeo.
the class WriteTree2Test method verifyTree.
private void verifyTree(ObjectDatabase objectDb, String path, ObjectId repoTreeId) {
assertTrue(String.format("tree '%s' (%s) is not present", path, repoTreeId), objectDb.exists(repoTreeId));
RevTree tree = objectDb.getTree(repoTreeId);
Iterator<Node> children = tree.children();
while (children.hasNext()) {
final Node node = children.next();
if (TYPE.TREE.equals(node.getType())) {
path = NodeRef.appendChild(path, node.getName());
ObjectId objectId = node.getObjectId();
verifyRepositoryTree(path, objectId);
} else if (TYPE.FEATURE.equals(node.getType())) {
verifyFeature(node);
} else {
throw new IllegalStateException(node.getType().toString());
}
verifyMetadata(node);
}
if (tree.buckets().isPresent()) {
ImmutableCollection<Bucket> buckets = tree.buckets().get().values();
for (Bucket b : buckets) {
ObjectId bucketTreeId = b.id();
verifyRepositoryTree(path + "/" + bucketTreeId.toString().substring(0, 8), bucketTreeId);
}
}
}
use of org.locationtech.geogig.api.Bucket in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method depth.
private int depth(RevTree deepTree, int currDepth) {
if (!deepTree.buckets().isPresent()) {
return currDepth;
}
int depth = currDepth;
for (Bucket bucket : deepTree.buckets().get().values()) {
RevTree bucketTree = odb.get(bucket.id(), RevTree.class);
int d = depth(bucketTree, currDepth + 1);
depth = Math.max(depth, d);
}
return depth;
}
use of org.locationtech.geogig.api.Bucket in project GeoGig by boundlessgeo.
the class PostOrderDiffWalkTest method testBucketBucketFlat.
@Test
public void testBucketBucketFlat() {
RevTree left = createFeaturesTree(leftSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 1).build();
RevTree right = createFeaturesTree(rightSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 2).build();
PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
visitor.walk(testConsumer);
List<Bounded> leftCalls = testConsumer.orderedLeft;
List<Bounded> rightCalls = testConsumer.orderedRight;
// System.err.println(leftCalls);
// System.err.println(rightCalls);
Node lroot = nodeFor(left);
Node rroot = nodeFor(right);
assertEquals(3, leftCalls.size());
assertEquals(3, rightCalls.size());
assertNull(leftCalls.get(0));
assertTrue(leftCalls.get(1) instanceof Bucket);
assertEquals(lroot, leftCalls.get(2));
assertEquals(rroot, rightCalls.get(2));
assertTrue(rightCalls.get(1) instanceof Bucket);
assertTrue(rightCalls.get(0) instanceof Node);
assertEquals(RevObject.TYPE.FEATURE, ((Node) rightCalls.get(0)).getType());
}
use of org.locationtech.geogig.api.Bucket in project GeoGig by boundlessgeo.
the class PreOrderDiffWalkTest method testBucketLeafSimple.
@Test
public void testBucketLeafSimple() {
final int leftsize = 1 + RevTree.NORMALIZED_SIZE_LIMIT;
RevTree left = createFeaturesTree(leftSource, "f", leftsize).build();
RevTree right = createFeaturesTree(rightSource, "f", 1).build();
PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
// consume all
when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
visitor.walk(consumer);
// there's only the root tree
verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
// there's only one feature on the right tree, so all right trees features fall on a single
// bucket
final int leftBucketCount = left.buckets().get().size();
final int expectedBucketCalls = leftBucketCount - 1;
verify(consumer, times(expectedBucketCalls)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
verify(consumer, times(leftsize - 1)).feature(any(Node.class), (Node) isNull());
verify(consumer, times(expectedBucketCalls)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
verifyNoMoreInteractions(consumer);
}
use of org.locationtech.geogig.api.Bucket in project GeoGig by boundlessgeo.
the class PreOrderDiffWalkTest method testBucketBucketFlat.
@Test
public void testBucketBucketFlat() {
RevTree left = createFeaturesTree(leftSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 1).build();
RevTree right = createFeaturesTree(rightSource, "f", RevTree.NORMALIZED_SIZE_LIMIT + 2).build();
PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
visitor.walk(consumer);
verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
verify(consumer, times(1)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
verify(consumer, times(1)).feature((Node) isNull(), any(Node.class));
verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
verify(consumer, times(1)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
verifyNoMoreInteractions(consumer);
}
Aggregations