use of org.apache.cassandra.io.util.MemoryOutputStream in project cassandra by apache.
the class SerializingCache method serialize.
private RefCountedMemory serialize(V value) {
long serializedSize = serializer.serializedSize(value);
if (serializedSize > Integer.MAX_VALUE)
throw new IllegalArgumentException(String.format("Unable to allocate %s", FBUtilities.prettyPrintMemory(serializedSize)));
RefCountedMemory freeableMemory;
try {
freeableMemory = new RefCountedMemory(serializedSize);
} catch (OutOfMemoryError e) {
return null;
}
try {
serializer.serialize(value, new WrappedDataOutputStreamPlus(new MemoryOutputStream(freeableMemory)));
} catch (IOException e) {
freeableMemory.unreference();
throw new RuntimeException(e);
}
return freeableMemory;
}
use of org.apache.cassandra.io.util.MemoryOutputStream in project eiger by wlloyd.
the class SerializingCache method serialize.
private FreeableMemory serialize(V value) {
long serializedSize = serializer.serializedSize(value);
if (serializedSize > Integer.MAX_VALUE)
throw new IllegalArgumentException("Unable to allocate " + serializedSize + " bytes");
FreeableMemory freeableMemory;
try {
freeableMemory = new FreeableMemory(serializedSize);
} catch (OutOfMemoryError e) {
return null;
}
try {
serializer.serialize(value, new DataOutputStream(new MemoryOutputStream(freeableMemory)));
} catch (IOException e) {
throw new IOError(e);
}
return freeableMemory;
}
Aggregations