Search in sources :

Example 16 with Query

use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.

the class Zahed method main.

public static void main(java.lang.String[] argv) {
    System.out.println("starting...");
    Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
    Query q1 = new Query(goal1);
    if (!q1.hasSolution()) {
        System.out.println("consult('zahed.pl') failed");
        return;
    }
    Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
    Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
    Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
    Compound list1 = new Compound(".", new Term[] { t1, list2 });
    Variable answer = new Variable("A");
    Compound goal2 = new Compound("gen", new Term[] { list1, answer });
    Query q2 = new Query(goal2);
    Map<String, Term> solution = q2.oneSolution();
    if (solution == null) {
        System.out.println("failed");
    } else {
        System.out.println(solution.get("A").toString());
    }
    System.out.println("finished");
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 17 with Query

use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.

the class Family method main.

public static void main(String[] argv) {
    Query q1 = new Query("consult", new Term[] { new Atom("jpl/test/family.pl") });
    System.err.println("consult " + (q1.hasSolution() ? "succeeded" : "failed"));
    for (int i = 0; i < 20; i++) {
        System.out.println("spawning client[" + i + "]");
        new Family(i).start();
    }
}
Also used : Query(org.jpl7.Query) Atom(org.jpl7.Atom)

Example 18 with Query

use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testHasMoreSolutions1.

public void testHasMoreSolutions1() {
    StringBuffer sb = new StringBuffer();
    Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
    Map<String, Term> soln;
    q.open();
    while (q.hasMoreSolutions()) {
        soln = q.nextSolution();
        sb.append(((Atom) soln.get("C")).name());
    }
    q.close();
    assertEquals("Query#hasMoreSolutions() + Query#nextSolution() work as intended", "prolog", sb.toString());
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 19 with Query

use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testJRef1.

public void testJRef1() {
    int i = 76543;
    Integer I = new Integer(i);
    Query q = new Query("jpl_call(?,intValue,[],I2)", new Term[] { Term.objectToJRef(I) });
    Term I2 = q.oneSolution().get("I2");
    assertTrue(I2.isInteger() && I2.intValue() == i);
}
Also used : Integer(org.jpl7.Integer) BigInteger(java.math.BigInteger) Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 20 with Query

use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method suite.

public static junit.framework.Test suite() {
    if (syntax.equals("traditional")) {
        JPL.setTraditional();
        Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "--traditional", "-q", "--home=../..", "--nosignals" });
    } else {
        Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "-q", "--home=../..", "--nosignals" });
    }
    assertTrue((new Query("consult", new Term[] { new Atom(test_jpl) })).hasSolution());
    assertTrue((new Query("use_module(library(jpl))")).hasSolution());
    return new TestSuite(TestJUnit.class);
}
Also used : Query(org.jpl7.Query) TestSuite(junit.framework.TestSuite) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Aggregations

Query (org.jpl7.Query)88 Term (org.jpl7.Term)52 Variable (org.jpl7.Variable)32 Query (org.hypertrace.entity.data.service.v1.Query)31 Map (java.util.Map)27 Test (org.junit.jupiter.api.Test)27 Atom (org.jpl7.Atom)21 Compound (org.jpl7.Compound)18 Filter (org.hypertrace.core.documentstore.Filter)17 Test (org.junit.Test)16 AttributeFilter (org.hypertrace.entity.data.service.v1.AttributeFilter)15 Query (com.google.datastore.v1.Query)14 ArrayList (java.util.ArrayList)10 Entity (org.hypertrace.entity.data.service.v1.Entity)9 EntityQueryRequest (org.hypertrace.entity.query.service.v1.EntityQueryRequest)8 GqlQuery (com.google.datastore.v1.GqlQuery)7 Integer (org.jpl7.Integer)6 IOException (java.io.IOException)5 Collections (java.util.Collections)5 List (java.util.List)5