protected AllocatedBuffer initAllocatedBuffer(final int partitionSize) { final int requiredCapacity = requiredCapacity(partitionSize); AllocatedBuffer allocatedBuffer = null; if (allocateInMemory) { allocatedBuffer = BufferAllocators.allocateDirect(requiredCapacity); } else { if (rawBuffer != null) { if (rawBuffer.remaining() < requiredCapacity) { throw new RuntimeException("Buffer size below required capacity of " + requiredCapacity); } allocatedBuffer = new ExternallyAllocatedBuffer(rawBuffer); } else { final File bufferFile = new File(bufferFileName); if (!bufferFile.exists()) { throw new RuntimeException("File " + bufferFileName + " does not exist"); } allocatedBuffer = BufferAllocators.allocateMappedFile(requiredCapacity, bufferFile); } } return allocatedBuffer; } }
protected AllocatedBuffer initAllocatedBuffer(final int partitionSize) { final int requiredCapacity = requiredCapacity(partitionSize); AllocatedBuffer allocatedBuffer = null; if (allocateInMemory) { allocatedBuffer = BufferAllocators.allocateDirect(requiredCapacity); } else { if (rawBuffer != null) { if (rawBuffer.remaining() < requiredCapacity) { throw new RuntimeException("Buffer size below required capacity of " + requiredCapacity); } allocatedBuffer = new ExternallyAllocatedBuffer(rawBuffer); } else { final File bufferFile = new File(bufferFileName); if (!bufferFile.exists()) { throw new RuntimeException("File " + bufferFileName + " does not exist"); } allocatedBuffer = BufferAllocators.allocateMappedFile(requiredCapacity, bufferFile); } } return allocatedBuffer; } }