public Object getDeserializedValue() { final Object val = basicGetNewValue(); if (val instanceof CachedDeserializable) { return ((CachedDeserializable) val).getDeserializedForReading(); } else { return val; } }
/** * If new value is off-heap return the StoredObject form (unretained OFF_HEAP_REFERENCE). Its * refcount is not inced by this call and the returned object can only be safely used for the * lifetime of the EntryEventImpl instance that returned the value. Else return the raw form. */ @Unretained(ENTRY_EVENT_NEW_VALUE) public Object getRawNewValue() { return basicGetNewValue(); }
@Unretained(ENTRY_EVENT_NEW_VALUE) public Object getValue() { return basicGetNewValue(); }
public String getNewValueStringForm() { return StringUtils.forceToString(basicGetNewValue()); }
/** * If the new value is stored off-heap return a retained OFF_HEAP_REFERENCE (caller must release). * * @return a retained OFF_HEAP_REFERENCE if the new value is off-heap; otherwise returns null */ @Retained(ENTRY_EVENT_NEW_VALUE) public StoredObject getOffHeapNewValue() { return convertToStoredObject(basicGetNewValue()); }
/** * Compute an estimate of the size of the new value for a PR. Since PR's always store values in a * cached deserializable we need to compute its size as a blob. * * @return the size of serialized bytes for the new value */ public int getNewValSizeForPR() { int newSize = 0; Object v = basicGetNewValue(); if (v != null) { try { newSize = CachedDeserializableFactory.calcSerializedSize(v) + CachedDeserializableFactory.overhead(); } catch (IllegalArgumentException iae) { logger.warn("DataStore failed to calculate size of new value", iae); newSize = 0; } } return newSize; }
/** * @param isSynced true if RegionEntry currently under synchronization */ private void makeSerializedNewValue(boolean isSynced) { Object obj = basicGetNewValue(); // ezoerner:20080611 In the case where there is an unapplied // delta, do not apply the delta or serialize yet unless entry is // under synchronization (isSynced is true) if (isSynced) { this.setSerializationDeferred(false); } basicSetNewValue(getCachedDeserializable(obj, this), false); }
validateValue(event.basicGetNewValue());
public byte[] getSerializedValue() { if (this.newValueBytes == null) { final Object val; val = basicGetNewValue(); if (val instanceof byte[]) { return (byte[]) val; } else if (val instanceof CachedDeserializable) { return ((CachedDeserializable) val).getSerializedValue(); } try { return CacheServerHelper.serialize(val); } catch (IOException ioe) { throw new GemFireIOException("unexpected exception", ioe); } } else { return this.newValueBytes; } }
/** * Like getRawNewValue except that if the result is an off-heap reference then copy it to the * heap. Note: to prevent the heap copy use getRawNewValue instead */ public Object getRawNewValueAsHeapObject() { Object result = basicGetNewValue(); if (mayHaveOffHeapReferences()) { result = OffHeapHelper.copyIfNeeded(result, getRegion().getCache()); } return result; }
@Test public void putWithNonTombstoneNewValue_callsBasicPutPart3WithTrue() { when(event.basicGetNewValue()).thenReturn("newValue"); doPut(); verify(internalRegion, times(1)).basicPutPart3(any(), any(), anyBoolean(), anyLong(), eq(true), anyBoolean(), anyBoolean(), any(), anyBoolean()); }
@Test public void putWithTombstoneNewValue_callsBasicPutPart3WithFalse() { when(event.basicGetNewValue()).thenReturn(Token.TOMBSTONE); doPut(); verify(internalRegion, times(1)).basicPutPart3(any(), any(), anyBoolean(), anyLong(), eq(false), anyBoolean(), anyBoolean(), any(), anyBoolean()); }
/** * @return null if new value is not serialized; otherwise returns a SerializedCacheValueImpl * containing the new value. */ @Override public SerializedCacheValue<?> getSerializedNewValue() { // In the case where there is a delta that has not been applied yet, // do not apply it here since it would not produce a serialized new // value (return null instead to indicate the new value is not // in serialized form). @Unretained(ENTRY_EVENT_NEW_VALUE) final Object tmp = basicGetNewValue(); if (tmp instanceof CachedDeserializable) { CachedDeserializable cd = (CachedDeserializable) tmp; if (!cd.isSerialized()) { return null; } byte[] bytes = this.newValueBytes; if (bytes == null) { bytes = this.cachedSerializedNewValue; } return new SerializedCacheValueImpl(this, getRegion(), this.re, cd, bytes); } else { // Note we return null even if cachedSerializedNewValue is not null. // This is because some callers of this method use it to indicate // that a CacheDeserializable should be created during deserialization. return null; } }
void putValueTXEntry(final TXEntryState tx) { Object v = basicGetNewValue(); if (v == null) { if (deltaBytes != null) { // since newValue is null, and we have deltaBytes // there must be a nearSidePendingValue processDeltaBytes(tx.getNearSidePendingValue()); v = basicGetNewValue(); } else { v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID; } } if (this.op != Operation.LOCAL_INVALIDATE && this.op != Operation.LOCAL_DESTROY) { // fix for bug 34387 Object pv = v; if (mayHaveOffHeapReferences()) { pv = OffHeapHelper.copyIfNeeded(v, getRegion().getCache()); } tx.setPendingValue(pv); } tx.setCallbackArgument(getCallbackArgument()); }
@Override protected void doAfterCompletionActions(boolean disabledEviction) { try { if (isCompleted()) { final boolean invokeListeners = getEvent().basicGetNewValue() != Token.TOMBSTONE; getOwner().basicPutPart3(getEvent(), getRegionEntry(), isOwnerInitialized(), getLastModifiedTime(), invokeListeners, isIfNew(), isIfOld(), getExpectedOldValue(), isRequireOldValue()); } } finally { finishEviction(disabledEviction); } }
Object nv = basicGetNewValue(); if (nv != null) { if (nv == Token.NOT_AVAILABLE) {
Object nv = basicGetNewValue(); this.offHeapOk = false;
Object nv = basicGetNewValue(); if (StoredObject.isOffHeapReference(nv)) { ReferenceCountHelper.setReferenceCountOwner(this);
basicSetNewValue(other.basicGetNewValue(), false); this.newValueBytes = other.newValueBytes; this.cachedSerializedNewValue = other.cachedSerializedNewValue;
validateArguments(key, event.basicGetNewValue(), callbackArg);