Search in sources :

Example 81 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class CacheQueryBuildValueTest method testBuilderAndQuery.

/**
 * @throws Exception If failed.
 */
public void testBuilderAndQuery() throws Exception {
    Ignite node = ignite(0);
    final IgniteCache<Object, Object> cache = node.cache(DEFAULT_CACHE_NAME);
    IgniteBinary binary = node.binary();
    BinaryObjectBuilder builder = binary.builder(TestBuilderValue.class.getName());
    cache.put(0, builder.build());
    builder.setField("iVal", 1);
    cache.put(1, builder.build());
    List<Cache.Entry<Object, Object>> entries = cache.query(new SqlQuery<>(TestBuilderValue.class, "true")).getAll();
    assertEquals(2, entries.size());
}
Also used : SqlQuery(org.apache.ignite.cache.query.SqlQuery) Ignite(org.apache.ignite.Ignite) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) IgniteBinary(org.apache.ignite.IgniteBinary)

Example 82 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class IgniteCacheAbstractInsertSqlQuerySelfTest method createPerson2.

/**
 */
Object createPerson2(int id, String name, int valFld) {
    if (!isBinaryMarshaller()) {
        Person2 p = new Person2(id);
        p.name = name;
        p.IntVal = valFld;
        return p;
    } else {
        BinaryObjectBuilder o = grid(0).binary().builder("Person2");
        o.setField("id", id);
        o.setField("name", name);
        o.setField("IntVal", valFld);
        return o.build();
    }
}
Also used : BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 83 with BinaryObjectBuilder

use of org.apache.ignite.binary.BinaryObjectBuilder in project ignite by apache.

the class IgniteCacheAbstractInsertSqlQuerySelfTest method createPerson.

/**
 */
Object createPerson(int id, String name) {
    if (!isBinaryMarshaller()) {
        Person p = new Person(id);
        p.name = name;
        return p;
    } else {
        BinaryObjectBuilder o = grid(0).binary().builder("Person");
        o.setField("id", id);
        o.setField("name", name);
        return o.build();
    }
}
Also used : BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Aggregations

BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)83 BinaryObject (org.apache.ignite.binary.BinaryObject)63 Ignite (org.apache.ignite.Ignite)11 IgniteBinary (org.apache.ignite.IgniteBinary)8 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)7 Date (java.util.Date)4 HashMap (java.util.HashMap)4 BinaryType (org.apache.ignite.binary.BinaryType)4 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 GridQueryProperty (org.apache.ignite.internal.processors.query.GridQueryProperty)3 GridQueryTypeDescriptor (org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor)3 GridH2RowDescriptor (org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor)3 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)3 Column (org.h2.table.Column)3 Field (java.lang.reflect.Field)2 SQLException (java.sql.SQLException)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2