public RefCountedMemory copy(long newSize) { RefCountedMemory copy = new RefCountedMemory(newSize); copy.put(0, this, 0, Math.min(size(), newSize)); return copy; }
public RefCountedMemory copy(long newSize) { RefCountedMemory copy = new RefCountedMemory(newSize); copy.put(0, this, 0, Math.min(size(), newSize)); return copy; }
public RefCountedMemory copy(long newSize) { RefCountedMemory copy = new RefCountedMemory(newSize); copy.put(0, this, 0, Math.min(size(), newSize)); return copy; }
public RefCountedMemory copy(long newSize) { RefCountedMemory copy = new RefCountedMemory(newSize); copy.put(0, this, 0, Math.min(size(), newSize)); return copy; }
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; }
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; }
private RefCountedMemory serialize(V value) { long serializedSize = serializer.serializedSize(value, ENCODED_TYPE_SIZES); if (serializedSize > Integer.MAX_VALUE) throw new IllegalArgumentException("Unable to allocate " + serializedSize + " bytes"); RefCountedMemory freeableMemory; try { freeableMemory = new RefCountedMemory(serializedSize); } catch (OutOfMemoryError e) { return null; } try { serializer.serialize(value, new EncodedDataOutputStream(new MemoryOutputStream(freeableMemory))); } catch (IOException e) { freeableMemory.unreference(); throw new RuntimeException(e); } return freeableMemory; }
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; }