use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.
the class EntryEventImplTest method verifyExportOldValueWithSerializedStoredObjectAndUnretainedOldReferenceOk.
@Test
public void verifyExportOldValueWithSerializedStoredObjectAndUnretainedOldReferenceOk() {
LocalRegion region = mock(LocalRegion.class);
when(region.getOffHeap()).thenReturn(true);
StoredObject oldValue = mock(StoredObject.class);
when(oldValue.isSerialized()).thenReturn(true);
Object oldValueDeserialized = "oldValueDeserialized";
when(oldValue.getValueAsDeserializedHeapObject()).thenReturn(oldValueDeserialized);
OldValueImporter ovImporter = mock(OldValueImporter.class);
when(ovImporter.isUnretainedOldReferenceOk()).thenReturn(true);
EntryEventImpl e = createEntryEvent(region, null);
e.setOldValue(oldValue);
e.exportOldValue(ovImporter);
verify(ovImporter).importOldObject(oldValue, true);
}
use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.
the class OffHeapByteBufferByteSourceJUnitTest method createByteSource.
@Override
protected ByteSource createByteSource(byte[] bytes) {
StoredObject so = MemoryAllocatorImpl.getAllocator().allocateAndInitialize(bytes, false, false);
if (so instanceof OffHeapStoredObject) {
OffHeapStoredObject c = (OffHeapStoredObject) so;
ByteBuffer bb = c.createDirectByteBuffer();
if (bb == null) {
fail("could not create a direct ByteBuffer for an off-heap Chunk");
}
return ByteSourceFactory.create(bb);
} else {
// So for this test just wrap the original bytes.
return ByteSourceFactory.wrap(bytes);
}
}
use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.
the class AbstractRegionEntry method checkOffHeapEquals.
private static boolean checkOffHeapEquals(@Unretained StoredObject ohVal, @Unretained Object obj) {
if (ohVal.isSerializedPdxInstance()) {
PdxInstance pi = InternalDataSerializer.readPdxInstance(ohVal.getSerializedValue(), GemFireCacheImpl.getForPdx("Could not check value equality"));
return checkPdxEquals(pi, obj);
}
if (obj instanceof StoredObject) {
return ohVal.checkDataEquals((StoredObject) obj);
} else {
byte[] serializedObj;
if (obj instanceof CachedDeserializable) {
CachedDeserializable cdObj = (CachedDeserializable) obj;
if (!ohVal.isSerialized()) {
assert cdObj.isSerialized();
return false;
}
serializedObj = cdObj.getSerializedValue();
} else if (obj instanceof byte[]) {
if (ohVal.isSerialized()) {
return false;
}
serializedObj = (byte[]) obj;
} else {
if (!ohVal.isSerialized()) {
return false;
}
if (obj == null || obj == Token.NOT_AVAILABLE || Token.isInvalidOrRemoved(obj)) {
return false;
}
serializedObj = EntryEventImpl.serialize(obj);
}
return ohVal.checkDataEquals(serializedObj);
}
}
use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.
the class DummyQRegion method asList.
@Override
public List asList() {
if (valueInList == null) {
valueInList = new ArrayList(1);
}
valueInList.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);
}
valueInList.add(val);
return valueInList;
}
use of org.apache.geode.internal.offheap.StoredObject in project geode by apache.
the class GetOperationContextImpl method getValue.
@Override
public Object getValue() {
Object result = super.getValue();
if (result instanceof StoredObject) {
StoredObject so = (StoredObject) result;
checkForReleasedOffHeapValue(so);
// since they called getValue they don't care if it is serialized or deserialized so return it
// as serialized
result = so.getValueAsHeapByteArray();
}
return result;
}
Aggregations