/** * Return an estimate of the amount of heap memory used for the object. * If it is not a byte[] then account for CachedDeserializable overhead. * when it is wrapped by a CachedDeserializable. */ public static int calcMemSize(Object o) { return calcMemSize(o, null, true); } public static int calcMemSize(Object o, ObjectSizer os, boolean addOverhead) {
@Override public int getValueSizeInBytes() { return CachedDeserializableFactory.getByteSize(this.value); } }
static Object readSerializedValue(byte[] valueBytes, Version version, ByteArrayDataInput in, boolean forceDeserialize) { if (forceDeserialize || CachedDeserializableFactory.preferObject()) { // deserialize checking for product version change return EntryEventImpl.deserialize(valueBytes, version, in); } else { // TODO: upgrades: is there a case where GemFire values are internal // ones that need to be upgraded transparently; probably messages // being persisted (gateway events?) return CachedDeserializableFactory.create(valueBytes); } }
/** * Return how much memory this object will consume * if it is in serialized form */ public static int calcSerializedMemSize(Object o) { int result = calcSerializedSize(o); result += Sizeable.PER_OBJECT_OVERHEAD; if (!(o instanceof byte[])) { result += overhead(); } return result; } }
static int calcMemSize(Object value) { if (value == null || value instanceof Token) { return 0; } if (!(value instanceof byte[]) && !CachedDeserializableFactory.preferObject() && !(value instanceof CachedDeserializable) && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) { // ezoerner:20090401 it's possible this value is a Delta throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " + value.getClass() + "): " + value); } try { return CachedDeserializableFactory.calcMemSize(value); } catch (IllegalArgumentException e) { return 0; } } }
int result; if (o instanceof byte[]) { result = getByteSize((byte[])o) - Sizeable.PER_OBJECT_OVERHEAD; } else if (o instanceof byte[][]) { result = getArrayOfBytesSize((byte[][])o, false); } else if (o instanceof Sizeable) { result = ((Sizeable)o).getSizeInBytes() + 4; if (!preferObject() && o instanceof CachedDeserializable) { result -= overhead();
public void run() { TestSerializable.throwExceptionOnDeserialization = !CachedDeserializableFactory .preferObject(); } });
int result; if (o instanceof byte[]) { result = getByteSize((byte[])o) - Sizeable.PER_OBJECT_OVERHEAD; } else if (o instanceof byte[][]) { result = getArrayOfBytesSize((byte[][])o, false); } else if (o instanceof CachedDeserializable) { result = ((CachedDeserializable)o).getSizeInBytes() + 4 - overhead(); } else if (o instanceof Sizeable) { result = ((Sizeable)o).getSizeInBytes() + 4;
for (byte[] bytes : (byte[][])obj) { if (bytes != null) { objSize += CachedDeserializableFactory.getByteSize(bytes); cd = CachedDeserializableFactory.create(obj, objSize); cd = CachedDeserializableFactory.create(b); if (ev != null) { ev.newValueBytes = b;
if (tmpValue != null) { if (entry.isEagerDeserialize()) { tmpValue = CachedDeserializableFactory.create(tmpValue, CachedDeserializableFactory.getArrayOfBytesSize( (byte[][])tmpValue, true)); entry.setSerialized(false); tmpValue = CachedDeserializableFactory.create(keyObject, CachedDeserializableFactory.getByteSize(tmpBytes)); entry.setSerialized(false); if (entry.isSerialized()) { tmpValue = CachedDeserializableFactory .create((byte[])tmpValue); tmpValue = CachedDeserializableFactory.create((byte[])tmpValue); : Token.INVALID; } else if (entry.isSerialized()) { tmpValue = CachedDeserializableFactory.create((byte[])tmpValue);
static Object readSerializedValue(byte[] valueBytes, Version version, ByteArrayDataInput in, boolean forceDeserialize) { if (forceDeserialize) { // deserialize checking for product version change return EntryEventImpl.deserialize(valueBytes, version, in); } else { // TODO: upgrades: is there a case where GemFire values are internal // ones that need to be upgraded transparently; probably messages // being persisted (gateway events?) return CachedDeserializableFactory.create(valueBytes); } }
/** * Creates and returns an instance of CachedDeserializable that contains the * specified byte array. */ static CachedDeserializable createNoCheck(final byte[] v) { if (STORE_ALL_VALUE_FORMS) { return new StoreAllCachedDeserializable(v); } else if (PREFER_DESERIALIZED) { if (isPdxEncoded(v) && cachePrefersPdx()) { return new PreferBytesCachedDeserializable(v); } else { return new VMCachedDeserializable(v); } } else { return new PreferBytesCachedDeserializable(v); } }
int vSize = CachedDeserializableFactory.calcSerializedMemSize(v); assertEquals(200000+CachedDeserializableFactory.overhead() - vSize, evictionSizeAfterGet - finalEvictionSize1);
size += CachedDeserializableFactory.overhead();
/** * Creates and returns an instance of CachedDeserializable that contains the * specified object (that is not a byte[]). */ public static CachedDeserializable create(Object object, int serializedSize) { if (STORE_ALL_VALUE_FORMS) { return new StoreAllCachedDeserializable(object); } else if (PREFER_DESERIALIZED) { if (object instanceof PdxInstance && cachePrefersPdx()) { return new PreferBytesCachedDeserializable(object); } else { return new VMCachedDeserializable(object, serializedSize); } } else { return new PreferBytesCachedDeserializable(object); } }
if (o instanceof byte[]) { result = getByteSize((byte[])o); addOverhead = false; } else if (o == null) { result = getArrayOfBytesSize((byte[][])o, true); addOverhead = false; } else if (o instanceof Long) { } else if (o instanceof Sizeable) { result = ((Sizeable)o).getSizeInBytes(); if (!preferObject() && o instanceof CachedDeserializable) { result += overhead();
/** * Given a VALUE_IS_* constant convert and return the corresponding DESERIALIZATION_POLICY_*. */ public static byte valueIsToDeserializationPolicy(boolean oldValueIsSerialized) { if (!oldValueIsSerialized) return DESERIALIZATION_POLICY_NONE; if (CachedDeserializableFactory.preferObject()) return DESERIALIZATION_POLICY_EAGER; return DESERIALIZATION_POLICY_LAZY; }
static int calcMemSize(Object value) { if (value == null || value instanceof Token) { return 0; } if (value instanceof GatewaySenderEventImpl) { return ((GatewaySenderEventImpl)value).getSerializedValueSize(); } if (!(value instanceof byte[]) && !CachedDeserializableFactory.preferObject() && !(value instanceof CachedDeserializable) && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) { // ezoerner:20090401 it's possible this value is a Delta throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " + value.getClass() + "): " + value); } try { return CachedDeserializableFactory.calcMemSize(value); } catch (IllegalArgumentException e) { return 0; } }
if (o instanceof byte[]) { result = getByteSize((byte[])o); addOverhead = false; } else if (o == null) { result = getArrayOfBytesSize((byte[][])o, true); addOverhead = false; } else if (o instanceof CachedDeserializable) { result += overhead();
/** * Return how much memory this object will consume * if it is in serialized form * @since 6.1.2.9 */ public static int calcSerializedMemSize(Object o) { int result = calcSerializedSize(o); result += Sizeable.PER_OBJECT_OVERHEAD; if (!(o instanceof byte[])) { result += overhead(); } return result; } }