use of org.apache.ignite.internal.binary.BinaryObjectOffheapImpl in project ignite by apache.
the class GridCacheBinaryObjectsAbstractSelfTest method checkGetAllTx.
/**
* @param concurrency Concurrency.
* @param isolation Isolation.
*/
private void checkGetAllTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> c = jcache(0);
IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; i++) c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; ) {
Set<Integer> keys = new HashSet<>();
for (int j = 0; j < 10; j++) keys.add(i++);
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, TestObject> objs = c.getAll(keys);
assertEquals(10, objs.size());
for (Map.Entry<Integer, TestObject> e : objs.entrySet()) assertEquals(e.getKey().intValue(), e.getValue().val);
tx.commit();
}
}
for (int i = 0; i < ENTRY_CNT; ) {
Set<Integer> keys = new HashSet<>();
for (int j = 0; j < 10; j++) keys.add(i++);
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, BinaryObject> objs = kpc.getAll(keys);
assertEquals(10, objs.size());
for (Map.Entry<Integer, BinaryObject> e : objs.entrySet()) {
BinaryObject val = e.getValue();
assertEquals(new Integer(e.getKey().intValue()), val.field("val"));
kpc.put(e.getKey(), val);
assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
}
tx.commit();
}
}
}
use of org.apache.ignite.internal.binary.BinaryObjectOffheapImpl in project ignite by apache.
the class GridCacheBinaryObjectsAbstractSelfTest method checkGetAsyncTx.
/**
* @param concurrency Concurrency.
* @param isolation Isolation.
*/
private void checkGetAsyncTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> c = jcache(0);
IgniteCache<Integer, BinaryObject> kbCache = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; i++) c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
TestObject obj = c.getAsync(i).get();
assertEquals(i, obj.val);
tx.commit();
}
}
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
BinaryObject val = kbCache.getAsync(i).get();
assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
assertEquals(i, (int) val.field("val"));
kbCache.putAsync(i, val).get();
tx.commit();
}
}
}
use of org.apache.ignite.internal.binary.BinaryObjectOffheapImpl in project ignite by apache.
the class GridCacheBinaryObjectsAbstractSelfTest method checkGetAllAsyncTx.
/**
* @param concurrency Concurrency.
* @param isolation Isolation.
*/
private void checkGetAllAsyncTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
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; ) {
Set<Integer> keys = new HashSet<>();
for (int j = 0; j < 10; j++) keys.add(i++);
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, TestObject> objs = c.getAllAsync(keys).get();
assertEquals(10, objs.size());
for (Map.Entry<Integer, TestObject> e : objs.entrySet()) assertEquals(e.getKey().intValue(), e.getValue().val);
tx.commit();
}
}
IgniteCache<Integer, BinaryObject> cache = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; ) {
Set<Integer> keys = new HashSet<>();
for (int j = 0; j < 10; j++) keys.add(i++);
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, BinaryObject> objs = cache.getAllAsync(keys).get();
assertEquals(10, objs.size());
for (Map.Entry<Integer, BinaryObject> e : objs.entrySet()) {
BinaryObject val = e.getValue();
assertEquals(new Integer(e.getKey().intValue()), val.field("val"));
assertFalse("Key=" + e.getKey(), val instanceof BinaryObjectOffheapImpl);
}
tx.commit();
}
}
}
use of org.apache.ignite.internal.binary.BinaryObjectOffheapImpl in project ignite by apache.
the class GridCacheBinaryObjectsAbstractSelfTest method checkGetTx.
/**
* @param concurrency Concurrency.
* @param isolation Isolation.
*/
private void checkGetTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> c = jcache(0);
IgniteCache<Integer, BinaryObject> kbCache = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; i++) c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
TestObject obj = c.get(i);
assertEquals(i, obj.val);
tx.commit();
}
}
for (int i = 0; i < ENTRY_CNT; i++) {
try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
BinaryObject val = kbCache.get(i);
assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
assertEquals(i, (int) val.field("val"));
kbCache.put(i, val);
tx.commit();
}
}
}
use of org.apache.ignite.internal.binary.BinaryObjectOffheapImpl in project ignite by apache.
the class BinaryPlainBinaryObject method writeTo.
/**
* {@inheritDoc}
*/
@Override
public void writeTo(BinaryWriterExImpl writer, BinaryBuilderSerializer ctx) {
BinaryObject val = binaryObj;
if (val instanceof BinaryObjectOffheapImpl)
val = ((BinaryObjectOffheapImpl) val).heapCopy();
writer.doWriteBinaryObject((BinaryObjectImpl) val);
}
Aggregations