use of org.apache.geode.internal.cache.CachedDeserializable in project geode by apache.
the class DummyQRegion method getValues.
@Override
public SelectResults getValues() {
if (values == null) {
values = new ResultsBag(((HasCachePerfStats) getRegion().getCache()).getCachePerfStats());
values.setElementType(valueType);
}
values.clear();
Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
if (val instanceof StoredObject) {
@Retained @Released StoredObject ohval = (StoredObject) val;
try {
val = ohval.getDeserializedValue(getRegion(), this.entry);
} finally {
ohval.release();
}
} else if (val instanceof CachedDeserializable) {
val = ((CachedDeserializable) val).getDeserializedValue(getRegion(), this.entry);
}
values.add(val);
return values;
}
use of org.apache.geode.internal.cache.CachedDeserializable in project geode by apache.
the class DummyQRegion method toArray.
@Override
public Object[] toArray() {
if (valueInArray == null) {
valueInArray = new Object[1];
}
Object val = this.entry.getValueOffHeapOrDiskWithoutFaultIn((LocalRegion) getRegion());
if (val instanceof StoredObject) {
@Retained @Released StoredObject ohval = (StoredObject) val;
try {
val = ohval.getDeserializedValue(getRegion(), this.entry);
} finally {
ohval.release();
}
} else if (val instanceof CachedDeserializable) {
val = ((CachedDeserializable) val).getDeserializedValue(getRegion(), this.entry);
}
valueInArray[0] = val;
return valueInArray;
}
use of org.apache.geode.internal.cache.CachedDeserializable in project geode by apache.
the class SerialGatewaySenderQueue method optimalGet.
/**
* Does a get that gets the value without fault values in from disk.
*/
private AsyncEvent optimalGet(Long k) {
// Get the object at that key (to remove the index).
LocalRegion lr = (LocalRegion) this.region;
Object o = null;
try {
o = lr.getValueInVMOrDiskWithoutFaultIn(k);
if (o != null && o instanceof CachedDeserializable) {
o = ((CachedDeserializable) o).getDeserializedValue(lr, lr.getRegionEntry(k));
}
} catch (EntryNotFoundException ok) {
// just return null;
}
// bug #46023 do not return a destroyed entry marker
if (o == Token.TOMBSTONE) {
o = null;
}
return (AsyncEvent) o;
}
use of org.apache.geode.internal.cache.CachedDeserializable in project geode by apache.
the class Get70 method getEntryRetained.
/**
* Same as getValueAndIsObject but the returned value can be a retained off-heap reference.
*/
@Retained
public Entry getEntryRetained(Region region, Object key, Object callbackArg, ServerConnection servConn) {
// Region.Entry entry;
String regionName = region.getFullPath();
if (servConn != null) {
servConn.setModificationInfo(true, regionName, key);
}
VersionTag versionTag = null;
// LocalRegion lregion = (LocalRegion)region;
// entry = lregion.getEntry(key, true);
boolean isObject = true;
@Retained Object data = null;
ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
VersionTagHolder versionHolder = new VersionTagHolder();
data = ((LocalRegion) region).getRetained(key, callbackArg, true, true, id, versionHolder, true);
versionTag = versionHolder.getVersionTag();
// If it is Token.REMOVED, Token.DESTROYED,
// Token.INVALID, or Token.LOCAL_INVALID
// set it to null. If it is NOT_AVAILABLE, get the value from
// disk. If it is already a byte[], set isObject to false.
boolean wasInvalid = false;
if (data == Token.REMOVED_PHASE1 || data == Token.REMOVED_PHASE2 || data == Token.DESTROYED) {
data = null;
} else if (data == Token.INVALID || data == Token.LOCAL_INVALID) {
// fix for bug 35884
data = null;
wasInvalid = true;
} else if (data instanceof byte[]) {
isObject = false;
} else if (data instanceof CachedDeserializable) {
CachedDeserializable cd = (CachedDeserializable) data;
isObject = cd.isSerialized();
if (cd.usesHeapForStorage()) {
data = cd.getValue();
}
}
Entry result = new Entry();
result.value = data;
result.isObject = isObject;
result.keyNotPresent = !wasInvalid && (data == null || data == Token.TOMBSTONE);
result.versionTag = versionTag;
return result;
}
use of org.apache.geode.internal.cache.CachedDeserializable in project geode by apache.
the class PutAllOperationContextJUnitTest method testCachedDeserializable.
/**
* Make sure that we do not expose the internal CachedDeserializable to customers
*/
@Test
public void testCachedDeserializable() {
LinkedHashMap<String, Object> m = new LinkedHashMap<>();
Object v = Integer.valueOf(99);
CachedDeserializable cd = CachedDeserializableFactory.create(v, 24);
m.put("cd", cd);
PutAllOperationContext paoc = new PutAllOperationContext(m);
Map<String, Object> opMap = paoc.getMap();
assertEquals(1, opMap.size());
assertEquals(true, opMap.containsKey("cd"));
assertEquals(v, opMap.get("cd"));
assertEquals(true, opMap.containsValue(v));
assertEquals(false, opMap.containsValue("junk"));
Collection<Object> values = opMap.values();
assertEquals(1, values.size());
assertEquals(v, values.iterator().next());
Set<Map.Entry<String, Object>> entries = opMap.entrySet();
assertEquals(1, entries.size());
Map.Entry me = entries.iterator().next();
assertEquals("cd", me.getKey());
assertEquals(v, me.getValue());
assertEquals(cd, m.get("cd"));
String opMapStr = opMap.toString();
assertEquals("expected " + opMapStr + " to not contain CachedDeserializable", false, opMapStr.contains("CachedDeserializable"));
HashMap<String, Object> hm = new HashMap<>(opMap);
assertEquals(hm, opMap);
assertEquals(opMap, hm);
assertEquals(hm.hashCode(), opMap.hashCode());
}
Aggregations