public static ValueWrapper createValueWrapperFromEntry(DiskEntry entry, InternalRegion region,
        EntryEventImpl event) {
      if (event != null) {
        // For off-heap it should be faster to pass a reference to the
        // StoredObject instead of using the cached byte[] (unless it is also compressed).
        // Since NIO is used if the chunk of memory is large we can write it
        // to the file using the off-heap memory with no extra copying.
        // So we give preference to getRawNewValue over getCachedSerializedNewValue
        final Object rawValue = event.getRawNewValue();
        if (wrapOffHeapReference(rawValue)) {
          return new OffHeapValueWrapper((StoredObject) rawValue);
        }
        if (event.getCachedSerializedNewValue() != null) {
          return new ByteArrayValueWrapper(true, event.getCachedSerializedNewValue());
        }
        if (rawValue != null) {
          return createValueWrapper(rawValue, event);
        }
      }
      @Retained
      final Object value = entry.getValueRetain(region, true);
      try {
        return createValueWrapper(value, event);
      } finally {
        OffHeapHelper.release(value);
      }
    }
Returns true if the given object is off-heap and it is worth wrapping a reference to it
instead of copying its data to the heap. Currently all StoredObject's with a refCount are
wrapped.
geode-core/src/main/java/org/apache/geode/internal/cache/entries/DiskEntry.java