Examples of ObjectDatabase


Examples of org.locationtech.geogig.storage.ObjectDatabase

            default:
                throw new IllegalStateException("Unknown strategy: " + this.strategy);
            }

            RevTree tree = (RevTree) revObject.get();
            ObjectDatabase database = stagingDatabase();
            DepthTreeIterator iter = new DepthTreeIterator(path, metadataId, tree, database,
                    iterStrategy);
            iter.setBoundsFilter(refBoundsFilter);
            return iter;
        default:
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        if (oldTree.equals(newTree)) {
            return Iterators.emptyIterator();
        }

        ObjectDatabase leftSource = resolveSource(oldTree.getId());
        ObjectDatabase rightSource = resolveSource(newTree.getId());
        final PreOrderDiffWalk visitor = new PreOrderDiffWalk(oldTree, newTree, leftSource,
                rightSource);

        final BlockingQueue<DiffEntry> queue = new ArrayBlockingQueue<>(100);
        final DiffEntryProducer diffProducer = new DiffEntryProducer(queue);
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        progress.complete();

        MutableTree newLeftTree = treeDifference.getLeftTree();

        final ObjectDatabase repositoryDatabase = objectDatabase();
        final RevTree newRoot = newLeftTree.build(stagingDatabase(), repositoryDatabase);
        if (newRoot.trees().isPresent()) {
            for (Node n : newRoot.trees().get()) {
                if (n.getMetadataId().isPresent()) deepMove(n.getMetadataId().get());
            }
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

            @Nullable final NodeRef rightTreeRef) {

        Preconditions.checkArgument(leftTreeRef != null || rightTreeRef != null,
                "either left or right tree shall be non null");

        final ObjectDatabase repositoryDatabase = objectDatabase();
        final String treePath = rightTreeRef == null ? leftTreeRef.path() : rightTreeRef.path();

        final List<String> strippedPathFilters = stripParentAndFiltersThatDontApply(
                this.pathFilters, treePath);

        // find the diffs that apply to the path filters
        final ObjectId leftTreeId = leftTreeRef == null ? RevTree.EMPTY_TREE_ID : leftTreeRef
                .objectId();
        final ObjectId rightTreeId = rightTreeRef == null ? RevTree.EMPTY_TREE_ID : rightTreeRef
                .objectId();

        final Predicate<Bounded> existsFilter = new Predicate<Bounded>() {

            private final ObjectDatabase targetDb = repositoryDatabase;

            @Override
            public boolean apply(Bounded input) {
                ObjectId id = null;
                if (input instanceof Node && TYPE.TREE.equals(((Node) input).getType())) {
                    id = ((Node) input).getObjectId();
                } else if (input instanceof Bucket) {
                    Bucket b = (Bucket) input;
                    id = b.id();
                }
                if (id != null) {
                    if (targetDb.exists(id)) {
                        LOGGER.trace("Ignoring {}. Already exists in target database.", input);
                        return false;
                    }
                }
                return true;
            }
        };
        DiffTree diffs = command(DiffTree.class).setRecursive(false).setReportTrees(false)
                .setOldTree(leftTreeId).setNewTree(rightTreeId).setPathFilter(strippedPathFilters)
                .setCustomFilter(existsFilter);

        // move new blobs from the index to the repository (note: this could be parallelized)
        Supplier<Iterator<Node>> nodesToMove = asNodeSupplierOfNewContents(diffs,
                strippedPathFilters);
        command(DeepMove.class).setObjects(nodesToMove).call();

        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

Examples of org.locationtech.geogig.storage.ObjectDatabase

    }

    @Test
    @Ignore
    public void testBuild() {
        ObjectDatabase origin = new HeapObjectDatabse();
        origin.open();
        ObjectDatabase target = new HeapObjectDatabse();
        target.open();
        RevTree tree = root.build(origin, target);

        Iterator<NodeRef> treeRefs = new DepthTreeIterator("", ObjectId.NULL, tree, target,
                Strategy.RECURSIVE_TREES_ONLY);
        MutableTree createFromRefs = MutableTree.createFromRefs(root.getNode().getObjectId(),
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        assertFalse(diffTree.setOldVersion(Ref.HEAD).setNewVersion(Ref.HEAD).call().hasNext());
    }

    @Test
    public void testTreePathFiltering() {
        ObjectDatabase db = geogit.getContext().objectDatabase();
        RevTree tree1 = tree(100, db);
        RevTree tree2 = tree(50, db);
        RevTree root = createRoot(db, tree1, tree2);

        List<String> pathFilters = ImmutableList.of("tree1");
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        assertEquals(pathFilters.size(), diffs.size());
    }

    @Test
    public void testBoundsFiltering() {
        ObjectDatabase db = geogit.getContext().objectDatabase();
        RevTree tree1 = tree(1000, db);
        RevTree tree2 = tree(50, db);
        RevTree root = createRoot(db, tree1, tree2);

        CoordinateReferenceSystem crs = revtype.type().getCoordinateReferenceSystem();
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        assertEquals(2, diffs.size());
    }

    @Test
    public void testBoundsFilteringReprojecting() throws Exception {
        ObjectDatabase db = geogit.getContext().objectDatabase();
        RevTree tree1 = tree(1000, db);
        RevTree tree2 = tree(50, db);
        RevTree root = createRoot(db, tree1, tree2);

        CoordinateReferenceSystem nativeCrs = revtype.type().getCoordinateReferenceSystem();
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

        assertEquals(2, diffs.size());
    }

    @Test
    public void testChangeTypeFilter() {
        ObjectDatabase db = geogit.getContext().objectDatabase();
        final RevTree tree1 = tree(1000, db);
        final RevTree tree2 = tree(50, db);
        final RevTree tree2Changed;
        {
            RevTreeBuilder builder = new RevTreeBuilder(db, tree2);
            // add 10 changed features, and delete 10 more
            for (int i = 0; i < 20; i++) {
                if (i % 2 == 0) {
                    builder.remove(String.valueOf(i));
                } else {
                    builder.put(feature(i, ObjectId.forString("changed" + i)));
                }
            }
            tree2Changed = builder.build();
            db.put(tree2Changed);
            assertEquals(tree2.size() - 10, tree2Changed.size());
        }
        final RevTree root1 = createRoot(db, tree1, tree2);
        final RevTree root2 = createRoot(db, tree1, tree2Changed);
View Full Code Here

Examples of org.locationtech.geogig.storage.ObjectDatabase

    /**
     * Apply path, bounds, and changeType filtering all at once
     */
    @Test
    public void testMixedFilters() {
        ObjectDatabase db = geogit.getContext().objectDatabase();
        final RevTree tree1 = tree(1000, db);
        final RevTree tree2 = tree(50, db);
        final RevTree tree2Changed;
        {
            RevTreeBuilder builder = new RevTreeBuilder(db, tree2);
            // add 10 changed features, and delete 10 more
            for (int i = 0; i < 20; i++) {
                if (i % 2 == 0) {
                    builder.remove(String.valueOf(i));
                } else {
                    builder.put(feature(i, ObjectId.forString("changed" + i)));
                }
            }
            tree2Changed = builder.build();
            db.put(tree2Changed);
            assertEquals(tree2.size() - 10, tree2Changed.size());
        }
        final RevTree root1 = createRoot(db, tree1, tree2);
        final RevTree root2 = createRoot(db, tree1, tree2Changed);
        final ObjectId rootId1 = root1.getId();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.