Search in sources :

Example 36 with BinaryObject

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

the class CacheKeepBinaryTransactionTest method testBinaryContains.

/**
 * @throws Exception If failed.
 */
public void testBinaryContains() throws Exception {
    IgniteEx ignite = grid(0);
    IgniteCache<Object, Object> cache = ignite.cache("tx-cache").withKeepBinary();
    try (Transaction tx = ignite.transactions().txStart()) {
        BinaryObject key = ignite.binary().builder("test2").setField("id", 1).build();
        assertFalse(cache.containsKey(key));
    }
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteEx(org.apache.ignite.internal.IgniteEx) BinaryObject(org.apache.ignite.binary.BinaryObject)

Example 37 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testUuidArrayField.

/**
 * @throws Exception If failed.
 */
public void testUuidArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    UUID[] arr = new UUID[] { UUID.randomUUID(), UUID.randomUUID() };
    builder.setField("uuidArrayField", arr);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) UUID(java.util.UUID) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 38 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testPlainBinaryObjectCopyFrom.

/**
 */
public void testPlainBinaryObjectCopyFrom() {
    GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
    BinaryObjectBuilderImpl builder = builder(toBinary(obj));
    assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
    GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
    assertTrue(deserialized.plainBinary != null);
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilderImpl(org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl) GridBinaryTestClasses(org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)

Example 39 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testDecimalField.

/**
 * @throws Exception If failed.
 */
public void testDecimalField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("decimalField", BigDecimal.TEN);
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder)

Example 40 with BinaryObject

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

the class BinaryObjectBuilderDefaultMappersSelfTest method testDecimalArrayField.

/**
 * @throws Exception If failed.
 */
public void testDecimalArrayField() throws Exception {
    BinaryObjectBuilder builder = builder("Class");
    builder.setField("decimalArrayField", new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN });
    BinaryObject po = builder.build();
    assertEquals(expectedHashCode("Class"), po.type().typeId());
    assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
    assertTrue(Arrays.equals(new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN }, po.<String[]>field("decimalArrayField")));
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) BigDecimal(java.math.BigDecimal)

Aggregations

BinaryObject (org.apache.ignite.binary.BinaryObject)200 BinaryObjectBuilder (org.apache.ignite.binary.BinaryObjectBuilder)55 Ignite (org.apache.ignite.Ignite)28 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)26 IgniteCache (org.apache.ignite.IgniteCache)25 HashMap (java.util.HashMap)16 Cache (javax.cache.Cache)15 ArrayList (java.util.ArrayList)13 Map (java.util.Map)13 LinkedHashMap (java.util.LinkedHashMap)12 List (java.util.List)10 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)10 IgniteEx (org.apache.ignite.internal.IgniteEx)10 BinaryObjectBuilderImpl (org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl)10 IgniteException (org.apache.ignite.IgniteException)9 GridBinaryTestClasses (org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses)9 UUID (java.util.UUID)8 BigInteger (java.math.BigInteger)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 BinaryType (org.apache.ignite.binary.BinaryType)7