use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class WriteBackTest method testSiblingsNested.
@Test
public void testSiblingsNested() {
RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
RevTree tree1 = new RevTreeBuilder(odb).put(blob("blob")).build();
RevTree tree2 = new RevTreeBuilder(odb).put(blob("blob")).build();
ObjectId newRootId1 = writeBack.setAncestor(oldRoot).setChildPath("subtree1/level2").setTree(tree1).call();
ObjectId newRootId2 = writeBack.setAncestor(odb.getTree(newRootId1).builder(odb)).setChildPath("subtree2/level2/level3").setTree(tree2).call();
// created the intermediate tree node?
DepthSearch depthSearch = new DepthSearch(odb);
assertTrue(depthSearch.find(newRootId2, "subtree1").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree1/level2").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree1/level2/blob").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree2").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree2/level2").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3").isPresent());
assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3/blob").isPresent());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method testChildrenChildrenNestedTrees.
@Test
public void testChildrenChildrenNestedTrees() {
RevTreeBuilder rootBuilder = new RevTreeBuilder(odb, childrenFeatureTypesTree);
childTree1.put(featureRef("tree1", 1000));
createFeatureTypesTree(rootBuilder, "tree1", childTree1);
RevTree newRoot = rootBuilder.build();
assertEquals(1, count(childrenFeatureTypesTree, newRoot).featureCount());
childTree2.remove("tree2/2");
createFeatureTypesTree(rootBuilder, "tree2", childTree2);
newRoot = rootBuilder.build();
assertEquals(2, count(childrenFeatureTypesTree, newRoot).featureCount());
childTree2.put(Node.create("tree2/1", FAKE_FEATURE_ID_CHANGED, ObjectId.NULL, TYPE.FEATURE, null));
createFeatureTypesTree(rootBuilder, "tree2", childTree2);
newRoot = rootBuilder.build();
assertEquals(3, count(childrenFeatureTypesTree, newRoot).featureCount());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method testBucketChildrenDeeperBuckets.
@Test
public void testBucketChildrenDeeperBuckets() {
final RevTree deepTree = createFeaturesTree("", 20000 + RevTree.NORMALIZED_SIZE_LIMIT).build();
// sanity check
assertTrue(deepTree.buckets().isPresent());
{
// sanity check to ensure we're testing with a tree with depth > 1 (i.e. at least two
// levels of buckets)
final int maxDepth = depth(deepTree, 0);
assertTrue(maxDepth > 1);
}
RevTreeBuilder builder = new RevTreeBuilder(odb, deepTree);
{
final int count = (int) (deepTree.size() - RevTree.NORMALIZED_SIZE_LIMIT);
for (int i = 0; i < count; i++) {
String path = String.valueOf(i);
builder.remove(path);
}
}
RevTree changed = builder.build();
assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, changed.size());
// sanity check
assertTrue(changed.features().isPresent());
assertFalse(changed.buckets().isPresent());
final long expected = deepTree.size() - changed.size();
assertEquals(expected, count(deepTree, changed).featureCount());
assertEquals(expected, count(changed, deepTree).featureCount());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DiffCountConsumerTest method testBucketChildren.
@Test
public void testBucketChildren() {
RevTreeBuilder builder = new RevTreeBuilder(odb, bucketsFeatureTree);
RevTree changed;
for (int i = 0; i < RevTree.NORMALIZED_SIZE_LIMIT; i++) {
builder.remove(String.valueOf(i));
}
changed = builder.build();
assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, changed.size());
assertFalse(changed.buckets().isPresent());
assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, count(bucketsFeatureTree, changed).featureCount());
assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, count(changed, bucketsFeatureTree).featureCount());
}
use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.
the class DepthTreeIteratorTest method testRecursiveTreesOnly.
@Test
public void testRecursiveTreesOnly() {
assertEquals(0, list(emptyTree, Strategy.RECURSIVE_TREES_ONLY).size());
assertEquals(0, list(featuresLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
assertEquals(treesLeafTree.numTrees(), list(treesLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
assertEquals(mixedLeafTree.numTrees(), list(mixedLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
assertEquals(0, list(featuresBucketsTree, Strategy.RECURSIVE_TREES_ONLY).size());
int numSubTrees = RevTree.NORMALIZED_SIZE_LIMIT + 1;
int featuresPerTree = RevTree.NORMALIZED_SIZE_LIMIT + 1;
RevTreeBuilder builder = createTreesTree(source, numSubTrees, featuresPerTree, metadataId);
for (int i = 0; i < 25000; i++) {
builder.put(featureNode("f", i));
}
RevTree mixedBucketsTree = builder.build();
Stopwatch sw = Stopwatch.createStarted();
assertEquals(numSubTrees, list(mixedBucketsTree, Strategy.RECURSIVE_TREES_ONLY).size());
sw.stop();
System.err.println(sw);
}
Aggregations