Search in sources :

Example 61 with BinaryObjectBuilder

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testRemoveFromNewObject.

/**
 */
public void testRemoveFromNewObject() {
    BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName());
    builder.setField("str", "a");
    builder.removeField("str");
    TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
}
Also used : BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 62 with BinaryObjectBuilder

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testFloatArrayField.

/**
 * @throws Exception If failed.
 */
public void testFloatArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("floatArrayField", new float[] { 1, 2, 3 });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new float[] { 1, 2, 3 }, po.<float[]>field("floatArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 63 with BinaryObjectBuilder

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testDoubleArrayField.

/**
 * @throws Exception If failed.
 */
public void testDoubleArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("doubleArrayField", new double[] { 1, 2, 3 });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new double[] { 1, 2, 3 }, po.<double[]>field("doubleArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 64 with BinaryObjectBuilder

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testFloatField.

/**
 * @throws Exception If failed.
 */
public void testFloatField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("floatField", 1.0f);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 65 with BinaryObjectBuilder

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testIntField.

/**
 * @throws Exception If failed.
 */
public void testIntField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("intField", 1);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(1, po.<Integer>field("intField").intValue());
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) 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