Package org.locationtech.geogig.api

Examples of org.locationtech.geogig.api.Node$TreeNode


            final Map<String, NodeRef> entries) {

        List<NodeRef> refsByDepth = Lists.newArrayList(entries.values());
        Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR);

        Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null);
        MutableTree root = new MutableTree(rootNode);

        Envelope bounds = new Envelope();

        for (NodeRef entry : refsByDepth) {
            Node node = entry.getNode();
            node.expand(bounds);
            String parentPath = entry.getParentPath();
            root.setChild(parentPath, node);
        }
        // recreate root node with the appropriate bounds
        rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds);
View Full Code Here


            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);
View Full Code Here

        }
    }

    @Override
    public boolean tree(Node left, Node right) {
        final Node node = left == null ? right : left;
        if (NodeRef.ROOT.equals(node.getName())) {
            // ignore the call on the root tree and follow the traversal
            return true;
        }
        if (left == null || right == null) {
            addTreeFeatures(node.getObjectId(), left != null, right != null);
            if (left == null) {
                count.addedTrees(1);
            } else {
                count.removedTrees(1);
            }
View Full Code Here

        SortedMap<NodeRef, NodeRef> matches = newTreeMap();

        for (Map.Entry<String, MutableTree> right : entriesOnlyOnRight.entrySet()) {
            for (Map.Entry<String, MutableTree> left : entriesOnlyOnLeft.entrySet()) {

                Node leftNode = left.getValue().getNode();
                Node rightNode = right.getValue().getNode();

                if (rightNode.getObjectId().equals(leftNode.getObjectId())) {
                    String leftParent = NodeRef.parentPath(left.getKey());
                    String rightParent = NodeRef.parentPath(right.getKey());

                    NodeRef leftRef = new NodeRef(leftNode, leftParent, ObjectId.NULL);
                    NodeRef rightRef = new NodeRef(rightNode, rightParent, ObjectId.NULL);
View Full Code Here

            entriesOnlyOnRight.remove(renamedTo.path());
        }

        SortedSet<NodeRef> newTreeRefs = Sets.newTreeSet();
        for (Map.Entry<String, MutableTree> newTree : entriesOnlyOnRight.entrySet()) {
            Node node = newTree.getValue().getNode();
            String parentPath = NodeRef.parentPath(newTree.getKey());
            // pass NULL to the NodeRef metadataId, to it defers to the one in the Node in case it
            // has one (see NodeRef.getMetadataId())
            ObjectId metadataId = ObjectId.NULL;
            NodeRef ref = new NodeRef(node, parentPath, metadataId);
View Full Code Here

        for (Map.Entry<String, MutableTree> e : leftEntries.entrySet()) {
            final String nodePath = e.getKey();

            final MutableTree leftTree = e.getValue();
            final Node leftNode = leftTree.getNode();

            @Nullable
            final MutableTree rightTree = rightEntries.get(nodePath);
            final Node rightNode = rightTree == null ? null : rightTree.getNode();

            if (leftNode.equals(rightNode)) {
                final Optional<ObjectId> leftMetadata = leftNode.getMetadataId();
                final Optional<ObjectId> rightMetadata = rightNode.getMetadataId();
                if (!leftMetadata.equals(rightMetadata)) {
                    String parentPath = NodeRef.parentPath(nodePath);
                    NodeRef leftRef = new NodeRef(leftNode, parentPath, ObjectId.NULL);
                    NodeRef rightRef = new NodeRef(rightNode, parentPath, ObjectId.NULL);
                    matches.put(leftRef, rightRef);
View Full Code Here

    private void testOrder(final int count) throws Exception {

        List<Node> expected = new ArrayList<Node>(count);
        for (int i = 0; i < count; i++) {
            Node node = node(i);
            index.add(node);
            expected.add(node);
        }
        Collections.sort(expected, new NodeStorageOrder());

        Iterator<Node> nodeIterator = index.nodes();
        List<Node> actual = Lists.newArrayList(nodeIterator);

        assertEquals(expected.size(), actual.size());
        for (int i = 0; i < expected.size(); i++) {
            Node expectedNode = expected.get(i);
            Node actualNode = actual.get(i);
            assertEquals("At index " + i, expectedNode, actualNode);
        }
    }
View Full Code Here

    @Test
    public void testInsertSingle() throws Exception {
        Name name = points1.getType().getName();
        String parentPath = name.getLocalPart();
        Node ref = workTree.insert(parentPath, points1);
        ObjectId objectId = ref.getObjectId();

        assertEquals(objectId, workTree.findUnstaged(appendChild(pointsName, idP1)).get()
                .getObjectId());
    }
View Full Code Here

        List<Node> targetList = new LinkedList<Node>();
        workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, 3);

        assertEquals(3, targetList.size());

        Node ref1 = targetList.get(0);
        Node ref2 = targetList.get(1);
        Node ref3 = targetList.get(2);

        assertEquals(ref1.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get()
                .getObjectId());
        assertEquals(ref2.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP2)).get()
                .getObjectId());
        assertEquals(ref3.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP3)).get()
                .getObjectId());
    }
View Full Code Here

        List<Node> targetList = new LinkedList<Node>();
        workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, 1);

        assertEquals(1, targetList.size());

        Node ref1 = targetList.get(0);
        assertEquals(ref1.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP1)).get()
                .getObjectId());

        featureList.clear();
        featureList.add(new FeatureToDelete(pointsType, idP1));
        featureList.add(points2);
        featureList.add(points3);

        targetList.clear();

        workTree.insert(pointsName, featureList.iterator(), LISTENER, targetList, 3);

        assertEquals(2, targetList.size());

        Node ref2 = targetList.get(0);
        Node ref3 = targetList.get(1);

        assertFalse(workTree.findUnstaged(appendChild(pointsName, idP1)).isPresent());
        assertEquals(ref2.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP2)).get()
                .getObjectId());
        assertEquals(ref3.getObjectId(), workTree.findUnstaged(appendChild(pointsName, idP3)).get()
                .getObjectId());
    }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.api.Node$TreeNode

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.