org.apache.ignite.binary.BinaryObject Java Examples

The following examples show how to use org.apache.ignite.binary.BinaryObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GridCacheBinaryObjectsAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
@SuppressWarnings("unchecked")
@Test
public void testCrossFormatObjectsIdentity() {
    IgniteCache c = binKeysCache();

    c.put(new ComplexBinaryFieldsListHashedKey(), "zzz");

    // Now let's build an identical key for get
    BinaryObjectBuilder bldr = grid(0).binary().builder(ComplexBinaryFieldsListHashedKey.class.getName());

    bldr.setField("firstField", 1);
    bldr.setField("secondField", "value");
    bldr.setField("thirdField", 0x1020304050607080L);

    BinaryObject binKey = bldr.build();

    assertEquals("zzz", c.get(binKey));
}
 
Example #2
Source File: CacheGetEntryAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache Cache.
 * @param i Key.
 * @param oneEntry If {@code true} then single entry is tested.
 */
private void checkBinaryRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry) {
    IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();

    if (oneEntry) {
        CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);

        assertNull(e);
    }
    else {
        Set<Integer> set = new HashSet<>();

        for (int j = 0; j < 10; j++)
            set.add(i + j);

        Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);

        assertTrue(es.isEmpty());
    }
}
 
Example #3
Source File: CacheEntryPredicateContainsValue.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public boolean apply(GridCacheEntryEx e) {
    CacheObject val = peekVisibleValue(e);

    if (this.val == null && val == null)
        return true;

    if (this.val == null || val == null)
        return false;

    GridCacheContext cctx = e.context();

    if (this.val instanceof BinaryObject && val instanceof BinaryObject)
        return F.eq(val, this.val);

    Object thisVal = CU.value(this.val, cctx, false);
    Object cacheVal = CU.value(val, cctx, false);

    return F.eq(thisVal, cacheVal);
}
 
Example #4
Source File: BinaryObjectBuilderDefaultMappersSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
@SuppressWarnings("unchecked")
@Test
public void testCopyFromInnerObjects() {
    ArrayList<Object> list = new ArrayList<>();
    list.add(new GridBinaryTestClasses.TestObjectAllTypes());
    list.add(list.get(0));

    GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(list);

    BinaryObjectBuilderImpl builder = builder(toBinary(c));
    builder.<List>getField("foo").add("!!!");

    BinaryObject res = builder.build();

    GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();

    List deserializedList = (List)deserialized.foo;

    assertSame(deserializedList.get(0), deserializedList.get(1));
    assertEquals("!!!", deserializedList.get(2));
    assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
}
 
Example #5
Source File: UnwrapMvccDataEntry.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Object unwrappedValue() {
    try {
        if (val == null)
            return null;

        if (keepBinary && val instanceof BinaryObject)
            return val;

        return val.value(cacheObjValCtx, false);
    }
    catch (Exception e) {
        cacheObjValCtx.kernalContext().log(UnwrapMvccDataEntry.class)
            .error("Unable to convert value [" + value() + "]", e);
        return null;
    }
}
 
Example #6
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testBinaryObject() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));

    SimpleObject obj = simpleObject();

    BinaryObject po = marshal(obj, marsh);

    BinaryObject po0 = marshalUnmarshal(po, marsh);

    assertTrue(po.hasField("b"));
    assertTrue(po.hasField("s"));
    assertTrue(po.hasField("i"));
    assertTrue(po.hasField("l"));
    assertTrue(po.hasField("f"));
    assertTrue(po.hasField("d"));
    assertTrue(po.hasField("c"));
    assertTrue(po.hasField("bool"));

    assertFalse(po.hasField("no_such_field"));

    assertEquals(obj, po.deserialize());
    assertEquals(obj, po0.deserialize());
}
 
Example #7
Source File: RecommendationBinaryDatasetDataBuilder.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public RecommendationDatasetData<Serializable, Serializable> build(LearningEnvironment env,
    Iterator<UpstreamEntry<Object, BinaryObject>> upstreamData, long upstreamDataSize, EmptyContext ctx) {
    List<ObjectSubjectRatingTriplet<Serializable, Serializable>> ratings = new ArrayList<>();
    while (upstreamData.hasNext()) {
        UpstreamEntry<Object, BinaryObject> e = upstreamData.next();
        BinaryObject val = e.getValue();

        Serializable objId = val.field(objFieldName);
        Serializable subjId = val.field(subjFieldName);
        Number rating = val.field(ratingFieldName);

        ratings.add(new ObjectSubjectRatingTriplet<>(objId, subjId, rating.doubleValue()));
    }

    return new RecommendationDatasetData<>(ratings);
}
 
Example #8
Source File: ComputeClientTask.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(
    int gridSize,
    Collection<BinaryObject> arg
) {
    Collection<ComputeClientJob> jobs = new ArrayList<>();

    Collection<BinaryObject> employees = new ArrayList<>();

    // Split provided collection into batches and
    // create a job for each batch.
    for (BinaryObject employee : arg) {
        employees.add(employee);

        if (employees.size() == 3) {
            jobs.add(new ComputeClientJob(employees));

            employees = new ArrayList<>(3);
        }
    }

    if (!employees.isEmpty())
        jobs.add(new ComputeClientJob(employees));

    return jobs;
}
 
Example #9
Source File: UnwrapMvccDataEntry.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public Object unwrappedKey() {
    try {
        if (keepBinary && key instanceof BinaryObject)
            return key;

        Object unwrapped = key.value(cacheObjValCtx, false);

        if (unwrapped instanceof BinaryObject) {
            if (keepBinary)
                return unwrapped;
            unwrapped = ((BinaryObject)unwrapped).deserialize();
        }

        return unwrapped;
    }
    catch (Exception e) {
        cacheObjValCtx.kernalContext().log(UnwrapMvccDataEntry.class)
            .error("Unable to convert key [" + key + "]", e);

        return null;
    }
}
 
Example #10
Source File: VisorQueryUtils.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param o Object.
 * @return String representation of value.
 */
private static String valueOf(Object o) {
    if (o == null)
        return "null";

    if (o instanceof byte[])
        return "size=" + ((byte[])o).length;

    if (o instanceof Byte[])
        return "size=" + ((Byte[])o).length;

    if (o instanceof Object[])
        return "size=" + ((Object[])o).length + ", values=[" + mkString((Object[])o, 120) + "]";

    if (o instanceof BinaryObject)
        return binaryToString((BinaryObject)o);

    return o.toString();
}
 
Example #11
Source File: GridCacheQueueAdapter.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void clear(int batchSize) throws IgniteException {
    A.ensure(batchSize >= 0, "Batch size cannot be negative: " + batchSize);

    try {
        Object obj = cache.invoke(queueKey, new ClearProcessor(id)).get();

        if (obj == null)
            return;

        IgniteBiTuple<Long, Long> t = obj instanceof BinaryObject ? ((BinaryObject)obj).deserialize()
            : (IgniteBiTuple<Long, Long>)obj;

        checkRemoved(t.get1());

        removeKeys(cache, id, queueName, collocated, t.get1(), t.get2(), batchSize);
    }
    catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
}
 
Example #12
Source File: GridCacheBinaryObjectsAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testGetAsync() throws Exception {
    IgniteCache<Integer, TestObject> c = jcache(0);

    for (int i = 0; i < ENTRY_CNT; i++)
        c.put(i, new TestObject(i));

    for (int i = 0; i < ENTRY_CNT; i++) {
        TestObject obj = c.getAsync(i).get();

        assertNotNull(obj);

        assertEquals(i, obj.val);
    }

    IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();

    for (int i = 0; i < ENTRY_CNT; i++) {
        BinaryObject po = kpc.getAsync(i).get();

        assertEquals(i, (int)po.field("val"));
    }
}
 
Example #13
Source File: IgniteBinaryTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
private void assertBinaryObjectsEqual(BinaryObject exp, BinaryObject actual) throws Exception {
    assertBinaryTypesEqual(exp.type(), actual.type());

    for (String f : exp.type().fieldNames()) {
        Object expVal = exp.field(f);

        Class<?> cls = expVal.getClass();

        if (cls.getMethod("equals", Object.class).getDeclaringClass() == cls)
            assertEquals(expVal, actual.field(f));
    }

    if (exp.type().isEnum())
        assertEquals(exp.enumOrdinal(), actual.enumOrdinal());
}
 
Example #14
Source File: DynamicEnableIndexingAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
protected void loadData(IgniteEx node, int start, int end) {
    try (IgniteDataStreamer<Object, Object> streamer = node.dataStreamer(POI_CACHE_NAME)) {
        Random rnd = ThreadLocalRandom.current();

        for (int i = start; i < end; i++) {
            BinaryObject bo = node.binary().builder(POI_CLASS_NAME)
                .setField(NAME_FIELD_NAME, "POI_" + i, String.class)
                .setField(LATITUDE_FIELD_NAME, rnd.nextDouble(), Double.class)
                .setField(LONGITUDE_FIELD_NAME, rnd.nextDouble(), Double.class)
                .build();

            streamer.addData(i, bo);
        }
    }
}
 
Example #15
Source File: DynamicEnableIndexingAbstractTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
protected void performQueryingIntegrityCheck(Ignite ig, int key) throws Exception {
    IgniteCache<Object, Object> cache = ig.cache(POI_CACHE_NAME).withKeepBinary();

    String sql = String.format("DELETE FROM %s WHERE %s = %d", POI_TABLE_NAME, ID_FIELD_NAME, key);
    List<List<?>> res = cache.query(new SqlFieldsQuery(sql).setSchema(POI_SCHEMA_NAME)).getAll();

    assertEquals(1, res.size());
    assertNull(cache.get(key));

    sql = String.format("INSERT INTO %s(%s) VALUES (%s)", POI_TABLE_NAME,
        String.join(",", ID_FIELD_NAME, NAME_FIELD_NAME), String.join(",", String.valueOf(key), "'test'"));

    res = cache.query(new SqlFieldsQuery(sql).setSchema(POI_SCHEMA_NAME)).getAll();

    assertEquals(1, res.size());
    assertNotNull(cache.get(key));

    sql = String.format("UPDATE %s SET %s = '%s' WHERE ID = %d", POI_TABLE_NAME, NAME_FIELD_NAME, "POI_" + key, key);
    res = cache.query(new SqlFieldsQuery(sql).setSchema(POI_SCHEMA_NAME)).getAll();

    assertEquals(1, res.size());
    assertEquals("POI_" + key, ((BinaryObject)cache.get(key)).field(NAME_FIELD_NAME));

    assertIndexUsed(cache, "SELECT * FROM " + POI_TABLE_NAME + " WHERE ID = " + key, KEY_PK_IDX_NAME);
}
 
Example #16
Source File: CacheClientBinaryQueryExample.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Queries employees that work for organization with provided name.
 *
 * @param cache Ignite cache.
 */
private static void sqlJoinQuery(IgniteCache<BinaryObject, BinaryObject> cache) {
    SqlFieldsQuery qry = new SqlFieldsQuery(
        "select e.* from Employee e, \"" + ORGANIZATION_CACHE_NAME + "\".Organization as org " +
            "where e.organizationId = org.keyId and org.name = ?");

    String organizationName = "GridGain";

    QueryCursor<List<?>> employees = cache.query(qry.setArgs(organizationName));

    System.out.println();
    System.out.println(">>> Employees working for " + organizationName + ':');

    for (List<?> row : employees.getAll())
        System.out.println(">>>     " + row);
}
 
Example #17
Source File: IgniteDialect.java    From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void insertOrUpdateTuple(EntityKey key, TuplePointer tuplePointer, TupleContext tupleContext) throws TupleAlreadyExistsException {
	IgniteCache<Object, BinaryObject> entityCache = provider.getEntityCache( key.getMetadata() );
	Tuple tuple = tuplePointer.getTuple();

	Object keyObject = null;
	BinaryObjectBuilder builder = null;
	IgniteTupleSnapshot tupleSnapshot = (IgniteTupleSnapshot) tuple.getSnapshot();
	keyObject = tupleSnapshot.getCacheKey();
	if ( tuple.getSnapshotType() == SnapshotType.UPDATE ) {
		builder = provider.createBinaryObjectBuilder( tupleSnapshot.getCacheValue() );
	}
	else {
		builder = provider.createBinaryObjectBuilder( provider.getEntityTypeName( key.getMetadata().getTable() ) );
	}
	for ( String columnName : tuple.getColumnNames() ) {
		Object value = tuple.get( columnName );
		if ( value != null ) {
			builder.setField( StringHelper.realColumnName( columnName ), value );
		}
		else {
			builder.removeField( StringHelper.realColumnName( columnName ) );
		}
	}
	BinaryObject valueObject = builder.build();
	entityCache.put( keyObject, valueObject );
	tuplePointer.setTuple( new Tuple( new IgniteTupleSnapshot( keyObject, valueObject, key.getMetadata() ), SnapshotType.UPDATE ) );
}
 
Example #18
Source File: DynamicIndexAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Put key to cache.
 *
 * @param node Node.
 * @param id ID.
 */
protected static void put(Ignite node, long id) {
    BinaryObject key = key(node, id);
    BinaryObject val = value(node, id);

    cache(node).put(key, val);
}
 
Example #19
Source File: InterceptorCacheConfigVariationsFullApiTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Nullable @Override public V onBeforePut(Cache.Entry<K, V> e, V newVal) {
    if (validate) {
        validateEntry(e);

        if (newVal != null)
            assertFalse("NewVal: " + newVal, newVal instanceof BinaryObject);
    }

    return newVal;
}
 
Example #20
Source File: GridDataStreamerImplSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 *  Tries to propagate cache with binary objects created using the builder.
 *
 * @throws Exception If failed.
 */
@Test
public void testAddBinaryCreatedWithBuilder() throws Exception {
    try {
        binaries = true;

        startGrids(2);

        awaitPartitionMapExchange();

        Ignite g0 = grid(0);

        IgniteDataStreamer<Integer, BinaryObject> dataLdr = g0.dataStreamer(DEFAULT_CACHE_NAME);

        for (int i = 0; i < 500; i++) {
            BinaryObjectBuilder obj = g0.binary().builder("NoExistedClass");

            obj.setField("id", i);
            obj.setField("name", "name = " + i);

            dataLdr.addData(i, obj.build());
        }

        dataLdr.close(false);

        assertEquals(500, g0.cache(DEFAULT_CACHE_NAME).size(CachePeekMode.ALL));
        assertEquals(500, grid(1).cache(DEFAULT_CACHE_NAME).size(CachePeekMode.ALL));
    }
    finally {
        G.stopAll(true);
    }
}
 
Example #21
Source File: BinaryArrayIdentityResolver.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected boolean equals0(BinaryObject o1, BinaryObject o2) {
    if (o1 instanceof BinaryObjectEx && o2 instanceof BinaryObjectEx) {
        BinaryObjectEx ex1 = (BinaryObjectEx)o1;
        BinaryObjectEx ex2 = (BinaryObjectEx)o2;

        if (ex1.typeId() != ex2.typeId())
            return false;

        if (ex1 instanceof BinaryObjectExImpl) {
            // Handle regular object.
            assert ex2 instanceof BinaryObjectExImpl;

            BinaryObjectExImpl exx1 = (BinaryObjectExImpl)ex1;
            BinaryObjectExImpl exx2 = (BinaryObjectExImpl)ex2;

            if (exx1.hasArray())
                return exx2.hasArray() ? equalsHeap(exx1, exx2) : equalsHeapOffheap(exx1, exx2);
            else
                return exx2.hasArray() ? equalsHeapOffheap(exx2, exx1) : equalsOffheap(exx1, exx2);
        }
        else {
            // Handle enums.
            assert ex1 instanceof BinaryEnumObjectImpl;
            assert ex2 instanceof BinaryEnumObjectImpl;

            return ex1.enumOrdinal() == ex2.enumOrdinal();
        }
    }

    BinaryObject o = o1 instanceof BinaryObjectEx ? o2 : o1;

    throw new BinaryObjectException("Array identity resolver cannot be used with provided BinaryObject " +
        "implementation: " + o.getClass().getName());
}
 
Example #22
Source File: BinaryPlainBinaryObject.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeTo(BinaryWriterExImpl writer, BinaryBuilderSerializer ctx) {
    BinaryObject val = binaryObj;

    if (val instanceof BinaryObjectOffheapImpl)
        val = ((BinaryObjectOffheapImpl)val).heapCopy();

    writer.doWriteBinaryObject((BinaryObjectImpl)val);
}
 
Example #23
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param obj Simple object.
 * @param po Binary object.
 */
private void checkSimpleObjectData(SimpleObject obj, BinaryObject po) {
    assertEquals(obj.b, (byte)po.field("b"));
    assertEquals(obj.s, (short)po.field("s"));
    assertEquals(obj.i, (int)po.field("i"));
    assertEquals(obj.l, (long)po.field("l"));
    assertEquals(obj.f, (float)po.field("f"), 0);
    assertEquals(obj.d, (double)po.field("d"), 0);
    assertEquals(obj.c, (char)po.field("c"));
    assertEquals(obj.bool, (boolean)po.field("bool"));
    assertEquals(obj.str, po.field("str"));
    assertEquals(obj.uuid, po.field("uuid"));
    assertEquals(obj.date, po.field("date"));
    assertEquals(Date.class, obj.date.getClass());
    assertEquals(obj.ts, po.field("ts"));
    assertArrayEquals(obj.bArr, (byte[])po.field("bArr"));
    assertArrayEquals(obj.sArr, (short[])po.field("sArr"));
    assertArrayEquals(obj.iArr, (int[])po.field("iArr"));
    assertArrayEquals(obj.lArr, (long[])po.field("lArr"));
    assertArrayEquals(obj.fArr, (float[])po.field("fArr"), 0);
    assertArrayEquals(obj.dArr, (double[])po.field("dArr"), 0);
    assertArrayEquals(obj.cArr, (char[])po.field("cArr"));
    assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("boolArr"));
    assertArrayEquals(obj.strArr, (String[])po.field("strArr"));
    assertArrayEquals(obj.uuidArr, (UUID[])po.field("uuidArr"));
    assertArrayEquals(obj.dateArr, (Date[])po.field("dateArr"));
    assertArrayEquals(obj.objArr, (Object[])po.field("objArr"));
    assertEquals(obj.col, po.field("col"));
    assertEquals(obj.map, po.field("map"));
    assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((BinaryObject)po.field("enumVal")).enumOrdinal()));
    assertArrayEquals(ordinals(obj.enumArr), ordinals((BinaryObject[])po.field("enumArr")));
    assertNull(po.field("unknown"));

    assertEquals(obj, po.deserialize());
}
 
Example #24
Source File: IgnitePdsCacheObjectBinaryProcessorOnDiscoveryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param ig Ig.
 * @param typeName Type name.
 * @param fields Fields.
 */
@SafeVarargs
private final BinaryObject addBinaryType(Ignite ig, String typeName, IgniteBiTuple<String, Class<?>>... fields) {
    BinaryObjectBuilder builder = ig.binary().builder(typeName);

    if (fields != null) {
        for (IgniteBiTuple<String,Class<?>> field: fields)
            builder.setField(field.get1(), field.get2());
    }

    return builder.build();
}
 
Example #25
Source File: CacheObjectBinaryProcessorImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object field(Object obj, String fieldName) {
    if (obj == null)
        return null;

    return isBinaryObject(obj) ? ((BinaryObject)obj).field(fieldName) : null;
}
 
Example #26
Source File: GridJettyObjectMapper.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void serialize(BinaryObjectImpl bin, JsonGenerator gen, SerializerProvider ser) throws IOException {
    try {
        BinaryType meta = bin.rawType();

        // Serialize to JSON if we have metadata.
        if (meta != null && !F.isEmpty(meta.fieldNames())) {
            gen.writeStartObject();

            for (String name : meta.fieldNames()) {
                Object val = bin.field(name);

                if (val instanceof BinaryObjectImpl) {
                    BinaryObjectImpl ref = (BinaryObjectImpl)val;

                    if (ref.hasCircularReferences())
                        throw ser.mappingException("Failed convert to JSON object for circular references");
                }

                if (val instanceof BinaryEnumObjectImpl)
                    gen.writeObjectField(name, ((BinaryObject)val).enumName());
                else
                    gen.writeObjectField(name, val);
            }

            gen.writeEndObject();
        }
        else {
            // Otherwise serialize as Java object.
            Object obj = bin.deserialize();

            gen.writeObject(obj);
        }
    }
    catch (BinaryObjectException ignore) {
        gen.writeNull();
    }
}
 
Example #27
Source File: GridCacheBinaryObjectsAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testTransform() throws Exception {
    IgniteCache<Integer, BinaryObject> c = keepBinaryCache();

    checkTransform(primaryKey(c));

    if (cacheMode() != CacheMode.LOCAL) {
        checkTransform(backupKey(c));

        if (nearConfiguration() != null)
            checkTransform(nearKey(c));
    }
}
 
Example #28
Source File: IgniteBinaryImpl.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public BinaryObjectBuilder builder(BinaryObject binaryObj) {
    guard();

    try {
        return proc.builder(binaryObj);
    }
    finally {
        unguard();
    }
}
 
Example #29
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testWriteReplaceInheritable() throws Exception {
    ImmutableList<String> obj = ImmutableList.of("This is a test");

    BinaryMarshaller marsh = binaryMarshaller(Collections.singleton(
        new BinaryTypeConfiguration(obj.getClass().getName())
    ));

    BinaryObject po = marshal(obj, marsh);

    Object des = po.deserialize();

    assertEquals(obj, des);
}
 
Example #30
Source File: IndexingSpiQuerySelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void store(@Nullable String cacheName, Object key, Object val, long expirationTime)
    throws IgniteSpiException {
    assertFalse(key instanceof BinaryObject);
    assertFalse(val instanceof BinaryObject);

    idx.put(key, val);
}