Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.RevTreeBuilder


        final StagingDatabase stagingDatabase = stagingDatabase();

        final RevTree currentLeftTree = stagingDatabase.getTree(leftTreeId);

        final RevTreeBuilder builder = currentLeftTree.builder(repositoryDatabase);

        // remove the exists filter, we need to create the new trees taking into account all the
        // nodes
        diffs.setCustomFilter(null);
        Iterator<DiffEntry> iterator = diffs.get();
        if (!strippedPathFilters.isEmpty()) {
            final Set<String> expected = Sets.newHashSet(strippedPathFilters);
            iterator = Iterators.filter(iterator, new Predicate<DiffEntry>() {
                @Override
                public boolean apply(DiffEntry input) {
                    boolean applies;
                    if (input.isDelete()) {
                        applies = expected.contains(input.oldName());
                    } else {
                        applies = expected.contains(input.newName());
                    }
                    return applies;
                }
            });
        }

        for (; iterator.hasNext();) {
            final DiffEntry diff = iterator.next();
            if (diff.isDelete()) {
                builder.remove(diff.oldName());
            } else {
                NodeRef newObject = diff.getNewObject();
                Node node = newObject.getNode();
                builder.put(node);
            }
        }

        final RevTree newTree = builder.build();
        repositoryDatabase.put(newTree);
        return newTree;
    }
View Full Code Here


    public RevTree build(ObjectDatabase origin, ObjectDatabase target) {
        final ObjectId nodeId = node.getObjectId();
        final RevTree tree = origin.getTree(nodeId);

        RevTreeBuilder builder = tree.builder(target).clearSubtrees();

        for (MutableTree childTree : this.childTrees.values()) {
            String name;
            ObjectId newObjectId;
            ObjectId metadataId;
            Envelope bounds;
            {
                RevTree newChild = childTree.build(origin, target);
                target.put(newChild);
                Node oldNode = childTree.getNode();
                name = oldNode.getName();
                newObjectId = newChild.getId();
                metadataId = oldNode.getMetadataId().or(ObjectId.NULL);
                bounds = SpatialOps.boundsOf(newChild);
            }
            Node newNode = Node.create(name, newObjectId, metadataId, TYPE.TREE, bounds);
            builder.put(newNode);
        }
        RevTree newTree = builder.build();
        if (!this.node.getObjectId().equals(newTree.getId())) {
            target.put(newTree);
            Envelope bounds = SpatialOps.boundsOf(newTree);
            this.node = Node.create(node.getName(), newTree.getId(),
                    node.getMetadataId().or(ObjectId.NULL), TYPE.TREE, bounds);
View Full Code Here

        fakeGeogig = new GeoGIG(injector);
        Repository fakeRepo = fakeGeogig.getOrCreateRepository();
        odb = fakeRepo.objectDatabase();
        search = new DepthSearch(odb);

        RevTreeBuilder root = new RevTreeBuilder(odb);
        root = addTree(root, "path/to/tree1", "node11", "node12", "node13");
        root = addTree(root, "path/to/tree2", "node21", "node22", "node23");
        root = addTree(root, "tree3", "node31", "node32", "node33");
        RevTree rootTree = root.build();
        odb.put(rootTree);
        rootTreeId = rootTree.getId();
    }
View Full Code Here

        Context mockInjector = mock(Context.class);
        when(mockInjector.objectDatabase()).thenReturn(odb);
        CreateTree op = new CreateTree().setIndex(false);
        op.setContext(mockInjector);
        RevTreeBuilder subTreeBuilder =op.call();
       
        if (singleNodeNames != null) {
            for (String singleNodeName : singleNodeNames) {
                String nodePath = NodeRef.appendChild(treePath, singleNodeName);
                ObjectId fakeFeatureOId = ObjectId.forString(nodePath);
                ObjectId fakeTypeOId = ObjectId.NULL;// forString(treePath);
                subTreeBuilder.put(Node.create(singleNodeName, fakeFeatureOId, fakeTypeOId,
                        TYPE.FEATURE, null));
            }
        }

        RevTree subtree = subTreeBuilder.build();
        WriteBack writeBack = fakeGeogig.command(WriteBack.class).setAncestor(root)
                .setChildPath(treePath).setTree(subtree).setMetadataId(fakeTreeMetadataId);
        ObjectId newRootId = writeBack.call();

        return fakeGeogig.command(RevObjectParse.class).setObjectId(newRootId).call(RevTree.class)
View Full Code Here

        testResultingTreeSize(56789);
        // testResultingTreeSize(1234567);
    }

    private void testResultingTreeSize(int numEntries) {
        RevTreeBuilder builder = createTree(numEntries, true);
        RevTree tree = builder.build();
        final long declaredSize = tree.size();

        Iterator<NodeRef> it = new DepthTreeIterator("", ObjectId.NULL, tree, odb,
                Strategy.RECURSIVE_FEATURES_ONLY);
        long itSize = 0;
View Full Code Here

                String name = "Feature." + random;
                ObjectId newid = ObjectId.forString(name + "changed");
                Node ref = Node.create(name, newid, ObjectId.NULL, TYPE.FEATURE, null);
                randomEdits.put(random, ref);
            }
            RevTreeBuilder mutable = tree.builder(odb);
            sw.reset().start();
            for (Node ref : randomEdits.values()) {
                mutable.put(ref);
            }
            mutable.build();
            sw.stop();
            System.err.println(randomEdits.size() + " random modifications in " + sw);
        }

        // CharSequence treeStr =
View Full Code Here

                }
            }
            assertEquals(100, removedKeys.size());
        }

        final RevTreeBuilder builder = tree.builder(odb);
        for (String key : removedKeys) {
            assertTrue(builder.get(key).isPresent());
            builder.remove(key);
            assertFalse(builder.get(key).isPresent());
        }

        final RevTree tree2 = builder.build();

        for (String key : removedKeys) {
            assertFalse(repo.getTreeChild(tree2, key).isPresent());
        }
    }
View Full Code Here

                }
            }
            assertTrue(removedKeys.size() > 0);
        }

        RevTreeBuilder builder = tree.builder(odb);
        for (String key : removedKeys) {
            assertTrue(key, builder.get(key).isPresent());
            builder.remove(key);
            assertFalse(key, builder.get(key).isPresent());
        }

        for (String key : removedKeys) {
            assertFalse(builder.get(key).isPresent());
        }

        final RevTree tree2 = builder.build();

        for (String key : removedKeys) {
            assertFalse(key, repo.getTreeChild(tree2, key).isPresent());
        }
    }
View Full Code Here

    }

    private ObjectId createAndSaveTree(final int numEntries, final boolean insertInAscendingKeyOrder)
            throws Exception {

        RevTreeBuilder treeBuilder = createTree(numEntries, insertInAscendingKeyOrder);
        RevTree tree = treeBuilder.build();
        odb.put(tree);
        return tree.getId();
    }
View Full Code Here

        odb.put(tree);
        return tree.getId();
    }

    private RevTreeBuilder createTree(final int numEntries, final boolean insertInAscendingKeyOrder) {
        RevTreeBuilder tree = new RevTreeBuilder(odb);

        final int increment = insertInAscendingKeyOrder ? 1 : -1;
        final int from = insertInAscendingKeyOrder ? 0 : numEntries - 1;
        final int breakAt = insertInAscendingKeyOrder ? numEntries : -1;
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.RevTreeBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.