use of org.apache.ignite.cache.CacheEntry in project ignite by apache.
the class WithKeepBinaryCacheFullApiTest method testPutAllGetAll.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("serial")
@Test
public void testPutAllGetAll() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override
public void run() throws Exception {
final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {
{
for (int i = 0; i < CNT; i++) add(key(i));
}
};
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
for (Object val : cache.getAll(keys).values()) assertNull(val);
}
});
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Collection<CacheEntry> entries = cache.<CacheEntry>getEntries(keys);
for (CacheEntry e : entries) assertNull(e.getValue());
}
});
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Map keyValMap = new LinkedHashMap() {
{
for (Object key : keys) {
Object val = value(valueOf(key));
put(key, val);
}
}
};
cache.putAll(keyValMap);
Set<Map.Entry<BinaryObject, BinaryObject>> set = cache.getAll(keys).entrySet();
for (Map.Entry<BinaryObject, BinaryObject> e : set) {
Object expVal = value(valueOf(e.getKey().deserialize()));
assertEquals(expVal, e.getValue().deserialize());
}
Collection<CacheEntry<BinaryObject, BinaryObject>> entries = cache.getEntries(keys);
for (CacheEntry<BinaryObject, BinaryObject> e : entries) {
assertTrue(e.getKey() instanceof BinaryObject);
Object expVal = value(valueOf(e.getKey().deserialize()));
assertEquals(expVal, e.getValue().deserialize());
}
cache.removeAll(keys);
}
});
}
}, PLANE_OBJECT, SERIALIZABLE);
}
use of org.apache.ignite.cache.CacheEntry in project ignite by apache.
the class WithKeepBinaryCacheFullApiTest method testPutAllGetAllAsync.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("serial")
@Test
public void testPutAllGetAllAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override
public void run() throws Exception {
final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {
{
for (int i = 0; i < CNT; i++) add(key(i));
}
};
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Map res = (Map) cache.getAllAsync(keys).get();
for (Object val : res.values()) assertNull(val);
}
});
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Collection<CacheEntry> entries = (Collection<CacheEntry>) cache.<CacheEntry>getEntriesAsync(keys).get();
for (CacheEntry e : entries) assertNull(e.getValue());
}
});
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Map keyValMap = new LinkedHashMap() {
{
for (Object key : keys) {
Object val = value(valueOf(key));
put(key, val);
}
}
};
cache.putAllAsync(keyValMap).get();
Set<Map.Entry<BinaryObject, BinaryObject>> set = ((Map) cache.getAllAsync(keys).get()).entrySet();
for (Map.Entry<BinaryObject, BinaryObject> e : set) {
Object expVal = value(valueOf(e.getKey().deserialize()));
assertEquals(expVal, e.getValue().deserialize());
}
Collection<CacheEntry<BinaryObject, BinaryObject>> entries = (Collection<CacheEntry<BinaryObject, BinaryObject>>) cache.getEntriesAsync(keys).get();
for (CacheEntry<BinaryObject, BinaryObject> e : entries) {
assertTrue(e.getKey() instanceof BinaryObject);
Object expVal = value(valueOf(e.getKey().deserialize()));
assertEquals(expVal, e.getValue().deserialize());
}
cache.removeAllAsync(keys).get();
}
});
}
}, PLANE_OBJECT, SERIALIZABLE);
}
use of org.apache.ignite.cache.CacheEntry in project ignite by apache.
the class WithKeepBinaryCacheFullApiTest method testRemovePutGetAsync.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("serial")
@Test
public void testRemovePutGetAsync() throws Exception {
runInAllDataModes(new TestRunnable() {
@Override
public void run() throws Exception {
final IgniteCache cache = jcache().withKeepBinary();
final Set keys = new LinkedHashSet() {
{
for (int i = 0; i < CNT; i++) add(key(i));
}
};
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
for (Object key : keys) cache.removeAsync(key).get();
}
});
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
for (Object key : keys) {
assertNull(cache.getAsync(key).get());
assertNull(cache.getEntryAsync(key).get());
}
}
});
for (final Object key : keys) {
runInAllTxModes(new TestRunnable() {
@Override
public void run() throws Exception {
Object val = value(valueOf(key));
cache.putAsync(key, val).get();
BinaryObject retVal = (BinaryObject) cache.getAsync(key).get();
assertEquals(val, retVal.deserialize());
CacheEntry<BinaryObject, BinaryObject> e = (CacheEntry<BinaryObject, BinaryObject>) cache.getEntryAsync(key).get();
assertEquals(key, deserializeBinary(e.getKey()));
assertEquals(val, e.getValue().deserialize());
}
});
}
}
}, PLANE_OBJECT, SERIALIZABLE);
}
Aggregations