Examples of LogOp


Examples of org.locationtech.geogig.api.porcelain.LogOp

        sw.stop();
        System.err.println(numberFormat.format(numBranches) + " branches with "
                + numberFormat.format(numCommits) + " comits each created in " + sw.toString());
        System.err.flush();

        LogOp op = geogig.command(LogOp.class);
        for (ObjectId id : ids) {
            op.addCommit(id);
        }
        sw.reset().start();
        Iterator<RevCommit> commits = op.call();
        sw.stop();
        System.err.println("LogOp took " + sw.toString());

        benchmarkIteration(commits);

        op = geogig.command(LogOp.class).setTopoOrder(true);
        for (ObjectId id : ids) {
            op.addCommit(id);
        }
        sw.reset().start();
        commits = op.call();
        sw.stop();
        System.err.println("LogOp using --topo-order took " + sw.toString());
        benchmarkIteration(commits);

        super.tearDown();
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

    public void runInternal(GeogigCLI cli) throws IOException {
        checkParameter(!args.commits.isEmpty(), "No starting commit provided");

        geogig = cli.getGeogig();

        LogOp op = geogig.command(LogOp.class).setTopoOrder(args.topo)
                .setFirstParentOnly(args.firstParent);

        for (String commit : args.commits) {
            if (commit.contains("..")) {
                checkParameter(args.commits.size() == 1,
                        "Only one value accepted when using <since>..<until> syntax");
                List<String> sinceUntil = ImmutableList.copyOf((Splitter.on("..").split(commit)));
                checkParameter(sinceUntil.size() == 2 || sinceUntil.size() == 1,
                        "Invalid refSpec format, expected [<commit> ...]|[<since>..<until>]: %s",
                        commit);
                String sinceRefSpec;
                String untilRefSpec;
                if (sinceUntil.size() == 1) {
                    // just until was given
                    sinceRefSpec = null;
                    untilRefSpec = sinceUntil.get(0);
                } else {
                    sinceRefSpec = sinceUntil.get(0);
                    untilRefSpec = sinceUntil.get(1);
                }
                if (sinceRefSpec != null) {
                    Optional<ObjectId> since;
                    since = geogig.command(RevParse.class).setRefSpec(sinceRefSpec).call();
                    checkParameter(since.isPresent(), "Object not found '%s'", sinceRefSpec);
                    op.setSince(since.get());
                }
                if (untilRefSpec != null) {
                    Optional<ObjectId> until;
                    until = geogig.command(RevParse.class).setRefSpec(untilRefSpec).call();
                    checkParameter(until.isPresent(), "Object not found '%s'", sinceRefSpec);
                    op.setUntil(until.get());
                }
            } else {
                Optional<ObjectId> commitId = geogig.command(RevParse.class).setRefSpec(commit)
                        .call();
                checkParameter(commitId.isPresent(), "Object not found '%s'", commit);
                checkParameter(geogig.getRepository().commitExists(commitId.get()),
                        "%s does not resolve to a commit", commit);
                op.addCommit(commitId.get());
            }
        }
        if (args.author != null && !args.author.isEmpty()) {
            op.setAuthor(args.author);
        }
        if (args.committer != null && !args.committer.isEmpty()) {
            op.setCommiter(args.committer);
        }
        if (args.skip != null) {
            op.setSkip(args.skip.intValue());
        }
        if (args.limit != null) {
            op.setLimit(args.limit.intValue());
        }
        if (args.since != null || args.until != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (args.since != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(args.since).call());
            }
            if (args.until != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(args.until).call());
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }
        if (!args.pathNames.isEmpty()) {
            for (String s : args.pathNames) {
                op.addPath(s);
            }
        }
        Iterator<RevCommit> log = op.call();
        console = cli.getConsole();

        RawPrinter printer = new RawPrinter(args.changed);
        while (log.hasNext()) {
            printer.print(log.next());
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

        assertEquals(c2, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());

        // test log using first parent only. It should not contain commit 2)
        LogOp op = geogig.command(LogOp.class).setFirstParentOnly(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c3, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());
        assertFalse(iterator.hasNext());

        // Test topological order
        op = geogig.command(LogOp.class).setTopoOrder(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

        assertEquals(mergeCommit, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c2, iterator.next());

        // test log using first parent only. It should not contain commit 2)
        LogOp op = geogig.command(LogOp.class).addPath(pointsName + "/" + idP2)
                .setFirstParentOnly(true);
        iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(mergeCommit, iterator.next());
        assertFalse(iterator.hasNext());
    }
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

        insertAndAdd(points3);
        final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
        insertAndAdd(lines1);
        final RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();

        LogOp op = geogig.command(LogOp.class);
        op.addCommit(c2.getId());
        op.addCommit(c4.getId());
        Iterator<RevCommit> iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(c4, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c3, iterator.next());
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

        insertAndAdd(points3);
        geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
        insertAndAdd(lines1);
        geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();

        LogOp op = geogig.command(LogOp.class).addCommit(c2.getId());
        Iterator<RevCommit> iterator = op.call();
        assertNotNull(iterator);
        assertTrue(iterator.hasNext());
        assertEquals(c2, iterator.next());
        assertTrue(iterator.hasNext());
        assertEquals(c1, iterator.next());
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

        checkParameter(!(args.stats && args.oneline),
                "--name-only and --oneline cannot be used together");

        geogig = cli.getGeogig();

        LogOp op = geogig.command(LogOp.class).setTopoOrder(args.topo)
                .setFirstParentOnly(args.firstParent);

        refs = Maps.newHashMap();
        if (args.decoration) {
            Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
            refs.put(head.get().getObjectId(), Ref.HEAD);
            ImmutableSet<Ref> set = geogig.command(ForEachRef.class)
                    .setPrefixFilter(Ref.REFS_PREFIX).call();
            for (Ref ref : set) {
                ObjectId id = ref.getObjectId();
                if (refs.containsKey(id)) {
                    refs.put(id, refs.get(id) + ", " + ref.getName());
                } else {
                    refs.put(id, ref.getName());
                }
            }
        }
        if (args.all) {
            ImmutableSet<Ref> refs = geogig.command(ForEachRef.class)
                    .setPrefixFilter(Ref.REFS_PREFIX).call();
            List<ObjectId> list = Lists.newArrayList();
            for (Ref ref : refs) {
                list.add(ref.getObjectId());
            }
            Optional<Ref> head = geogig.command(RefParse.class).setName(Ref.HEAD).call();
            if (head.isPresent()) {
                Ref ref = head.get();
                if (ref instanceof SymRef) {
                    ObjectId id = ref.getObjectId();
                    list.remove(id);
                    list.add(id);// put the HEAD ref in the last position, to give it preference
                }
            }
            for (ObjectId id : list) {
                op.addCommit(id);
            }
        } else if (args.branch != null) {
            Optional<Ref> obj = geogig.command(RefParse.class).setName(args.branch).call();
            checkParameter(obj.isPresent(), "Wrong branch name: " + args.branch);
            op.addCommit(obj.get().getObjectId());
        }

        if (args.author != null && !args.author.isEmpty()) {
            op.setAuthor(args.author);
        }
        if (args.committer != null && !args.committer.isEmpty()) {
            op.setCommiter(args.committer);
        }
        if (args.skip != null) {
            op.setSkip(args.skip.intValue());
        }
        if (args.limit != null) {
            op.setLimit(args.limit.intValue());
        }
        if (args.since != null || args.until != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (args.since != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(args.since).call());
            }
            if (args.until != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(args.until).call());
                if (args.all) {
                    throw new InvalidParameterException(
                            "Cannot specify 'until' commit when listing all branches");
                }
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }
        if (!args.sinceUntilPaths.isEmpty()) {
            List<String> sinceUntil = ImmutableList.copyOf((Splitter.on("..")
                    .split(args.sinceUntilPaths.get(0))));
            checkParameter(sinceUntil.size() == 1 || sinceUntil.size() == 2,
                    "Invalid refSpec format, expected [<until>]|[<since>..<until>]: %s",
                    args.sinceUntilPaths.get(0));

            String sinceRefSpec;
            String untilRefSpec;
            if (sinceUntil.size() == 1) {
                // just until was given
                sinceRefSpec = null;
                untilRefSpec = sinceUntil.get(0);
            } else {
                sinceRefSpec = sinceUntil.get(0);
                untilRefSpec = sinceUntil.get(1);
            }
            if (sinceRefSpec != null) {
                Optional<ObjectId> since;
                since = geogig.command(RevParse.class).setRefSpec(sinceRefSpec).call();
                checkParameter(since.isPresent(), "Object not found '%s'", sinceRefSpec);
                op.setSince(since.get());
            }
            if (untilRefSpec != null) {
                if (args.all) {
                    throw new InvalidParameterException(
                            "Cannot specify 'until' commit when listing all branches");
                }
                Optional<ObjectId> until;
                until = geogig.command(RevParse.class).setRefSpec(untilRefSpec).call();
                checkParameter(until.isPresent(), "Object not found '%s'", sinceRefSpec);
                op.setUntil(until.get());
            }
        }
        if (!args.pathNames.isEmpty()) {
            for (String s : args.pathNames) {
                op.addPath(s);
            }
        }
        Iterator<RevCommit> log = op.call();
        this.console = cli.getConsole();
        if (!log.hasNext()) {
            console.println("No commits to show");
            console.flush();
            return;
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

     */
    @Override
    public void run(CommandContext context) {
        final Context geogig = this.getCommandLocator(context);
        final List<FeatureTypeStats> stats = Lists.newArrayList();
        LogOp logOp = geogig.command(LogOp.class).setFirstParentOnly(true);
        final Iterator<RevCommit> log;
        if (since != null && !since.trim().isEmpty()) {
            Date untilTime = new Date();
            Date sinceTime = new Date(geogig.command(ParseTimestamp.class).setString(since).call());
            logOp.setTimeRange(new Range<Date>(Date.class, sinceTime, untilTime));
        }
        if (this.until != null) {
            Optional<ObjectId> until;
            until = geogig.command(RevParse.class).setRefSpec(this.until).call();
            Preconditions.checkArgument(until.isPresent(), "Object not found '%s'", this.until);
            logOp.setUntil(until.get());
        }

        LsTreeOp lsTreeOp = geogig.command(LsTreeOp.class)
                .setStrategy(LsTreeOp.Strategy.TREES_ONLY);
        if (path != null && !path.trim().isEmpty()) {
            lsTreeOp.setReference(path);
            logOp.addPath(path);
        }
        final Iterator<NodeRef> treeIter = lsTreeOp.call();

        while (treeIter.hasNext()) {
            NodeRef node = treeIter.next();
            stats.add(new FeatureTypeStats(node.path(), context.getGeoGIG().getRepository()
                    .getTree(node.objectId()).size()));
        }
        log = logOp.call();

        RevCommit firstCommit = null;
        RevCommit lastCommit = null;
        int totalCommits = 0;
        final List<RevPerson> authors = Lists.newArrayList();
View Full Code Here

Examples of org.locationtech.geogig.api.porcelain.LogOp

     */
    @Override
    public void run(final CommandContext context) {
        final Context geogig = this.getCommandLocator(context);

        LogOp op = geogig.command(LogOp.class).setFirstParentOnly(firstParentOnly);

        if (skip != null) {
            op.setSkip(skip.intValue());
        }
        if (limit != null) {
            op.setLimit(limit.intValue());
        }

        if (this.sinceTime != null || this.untilTime != null) {
            Date since = new Date(0);
            Date until = new Date();
            if (this.sinceTime != null) {
                since = new Date(geogig.command(ParseTimestamp.class).setString(this.sinceTime)
                        .call());
            }
            if (this.untilTime != null) {
                until = new Date(geogig.command(ParseTimestamp.class).setString(this.untilTime)
                        .call());
            }
            op.setTimeRange(new Range<Date>(Date.class, since, until));
        }

        if (this.since != null) {
            Optional<ObjectId> since;
            since = geogig.command(RevParse.class).setRefSpec(this.since).call();
            Preconditions.checkArgument(since.isPresent(), "Object not found '%s'", this.since);
            op.setSince(since.get());
        }
        if (this.until != null) {
            Optional<ObjectId> until;
            until = geogig.command(RevParse.class).setRefSpec(this.until).call();
            Preconditions.checkArgument(until.isPresent(), "Object not found '%s'", this.until);
            op.setUntil(until.get());
        }
        if (paths != null && !paths.isEmpty()) {
            for (String path : paths) {
                op.addPath(path);
            }
        }

        final Iterator<RevCommit> log = op.call();

        Iterators.advance(log, page * elementsPerPage);

        if (countChanges) {
            final String pathFilter;
View Full Code Here

Examples of solver.constraints.nary.cnf.LogOp

            solver.makeLessOrEqual(
                solver.makeDifference(b1, b2), 0));
        */

                // b1 -> b2
                LogOp t = LogOp.implies(b1, b2);
                SatFactory.addClauses(t, solver);

                // solver.post(IntConstraintFactory.arithm(b1, "<=", b2));


            }
        }

        //   forall(w in Women, o in Men)
        //      cp.post(rankWomen[w,o] < rankWomen[w,husband[w]] =>
        //              rankMen[o,wife[o]] < rankMen[o,w]);
        for (int w = 0; w < n; w++) {
            for (int o = 0; o < n; o++) {
        /*
        IntVar b1 = solver.makeIsGreaterCstVar(
                        solver.makeElement(rankWomen[w], husband[w]).var(),
                        rankWomen[w][o]);
        */
                IntVar v1 = enumerated("v1", 0, n - 1, solver);
                solver.post(element(v1, rankWomen[w], husband[w], 0, "detect"));

                BoolVar b1 = bool("b1", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b1,
                        arithm(v1, ">", rankWomen[w][o]),
                        arithm(v1, "<=", rankWomen[w][o])
                ));


        /*
        IntVar b2 = solver.makeIsLessCstVar(
                        solver.makeElement(rankMen[o], wife[o]).var(),
                        rankMen[o][w]);
        */
                IntVar v2 = enumerated("v2", 0, n - 1, solver);
                solver.post(element(v2, rankMen[o], wife[o], 0, "detect"));

                BoolVar b2 = bool("b2", solver);
                solver.post(LogicalConstraintFactory.ifThenElse(b2,
                        arithm(v2, "<", rankMen[o][w]),
                        arithm(v2, ">=", rankMen[o][w])
                ));


        /*
        solver.addConstraint(
            solver.makeLessOrEqual(
                solver.makeDifference(b1, b2), 0));
        }
        */

                // b1 -> b2
                LogOp t = LogOp.implies(b1, b2);
                SatFactory.addClauses(t, solver);

                // solver.post(IntConstraintFactory.arithm(b1, "<=", b2));

            }
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.