Search in sources :

Example 91 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testOpen1.

public void testOpen1() {
    Query q = new Query("dummy");
    assertTrue("a newly created query is not open", !q.isOpen());
}
Also used : Query(org.jpl7.Query)

Example 92 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testVariableBinding2.

public void testVariableBinding2() {
    Term lhs = new Compound("p", new Term[] { new Variable("X"), new Variable("X") });
    Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
    Term goal = new Compound("=", new Term[] { lhs, rhs });
    assertFalse("two distinct Variables with same name cannot unify with distinct atoms", new Query(goal).hasSolution());
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 93 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestOLD method test10s.

@SuppressWarnings("unused")
private static void test10s() {
    // 10 successive sleep(1)
    final Query q = new Query("jpl_slow_goal");
    System.err.println("test10s:");
    Thread t = new Thread(new Runnable() {

        public void run() {
            try {
                System.err.println("q.hasSolution() ... ");
                System.err.println(q.hasSolution() ? "finished" : "failed");
            } catch (Exception e) {
                System.err.println("q.hasSolution() threw " + e);
            }
        }
    });
    // call the query in a separate thread
    t.start();
    System.err.println("pausing for 2 secs...");
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        ;
    }
    // wait a coupla seconds for it to get started
    // (new Query("set_prolog_flag(abort_with_exception,
    // true)")).hasSolution();
    System.err.println("calling q.abort()...");
    // q.abort();
    System.err.println();
}
Also used : Query(org.jpl7.Query)

Example 94 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestOLD method test10j.

private static void test10j() {
    Term l2 = Util.termArrayToList(new Term[] { new Atom("a"), new Atom("b"), new Atom("c"), new Atom("d"), new Atom("e") });
    Query q9 = new Query(new Compound("append", new Term[] { new Variable("Xs"), new Variable("Ys"), l2 }));
    Map<String, Term>[] s9s = q9.allSolutions();
    System.err.println("test10j:");
    for (int i = 0; i < s9s.length; i++) {
        System.err.println("  append(Xs,Ys,[a,b,c,d,e]) -> " + Util.toString(s9s[i]));
    }
    System.err.println();
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Map(java.util.Map) Atom(org.jpl7.Atom)

Example 95 with Query

use of org.molgenis.emx2.Query in project packages-jpl by SWI-Prolog.

the class TestOLD method main.

public static void main(String[] argv) {
    Prolog.set_default_init_args(new String[] { "libpl.dll", "-f", "none", "-g", "set_prolog_flag(debug_on_error,false)", "-q" });
    System.err.println("tag = " + Prolog.object_to_tag(new Query("hello")));
    test10k();
    test10();
    // test10h();
    // test10i();
    test10j();
    test10k();
    test10l();
    test10m();
    // test10n();
    test10o();
    // test10p();
    test10q();
    // test10r();
    // test10s();
    // test10t();
    // test10u();
    // test10v();
    String s = new String("" + '\0' + '\377');
    System.err.println("s.length = " + s.length());
    for (int i = 0; i < s.length(); i++) {
        System.err.print((new Integer(s.charAt(i))).toString() + " ");
    }
    System.err.println();
    System.err.println(new Query("atom_codes(A,[127,128,255,0])").oneSolution().toString());
}
Also used : Integer(org.jpl7.Integer) Query(org.jpl7.Query)

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)28 Test (org.junit.jupiter.api.Test)23 Atom (org.jpl7.Atom)21 Compound (org.jpl7.Compound)18 Test (org.junit.Test)18 Filter (org.hypertrace.core.documentstore.Filter)16 Query (com.google.datastore.v1.Query)14 AttributeFilter (org.hypertrace.entity.data.service.v1.AttributeFilter)14 GqlQuery (com.google.datastore.v1.GqlQuery)7 ArrayList (java.util.ArrayList)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Entity (org.hypertrace.entity.data.service.v1.Entity)6 Integer (org.jpl7.Integer)6 Query (org.molgenis.emx2.Query)6 IOException (java.io.IOException)5 Collections (java.util.Collections)5