use of org.apache.hadoop.hive.common.io.Allocator.AllocatorOutOfMemoryException in project hive by apache.
the class TestBuddyAllocator method allocateAndUseBuffer.
private void allocateAndUseBuffer(BuddyAllocator a, MemoryBuffer[][] allocs, long[][] testValues, int allocCount, int index, int sizeLog2) throws Exception {
allocs[index] = new MemoryBuffer[allocCount];
testValues[index] = new long[allocCount];
int size = (1 << sizeLog2) - 1;
try {
a.allocateMultiple(allocs[index], size);
} catch (AllocatorOutOfMemoryException ex) {
LOG.error("Failed to allocate " + allocCount + " of " + size + "; " + a.debugDump());
throw ex;
}
// LOG.info("Allocated " + allocCount + " of " + size + "; " + a.debugDump());
for (int j = 0; j < allocCount; ++j) {
MemoryBuffer mem = allocs[index][j];
long testValue = testValues[index][j] = rdm.nextLong();
int pos = mem.getByteBufferRaw().position();
mem.getByteBufferRaw().putLong(pos, testValue);
int halfLength = mem.getByteBufferRaw().remaining() >> 1;
if (halfLength + 8 <= mem.getByteBufferRaw().remaining()) {
mem.getByteBufferRaw().putLong(pos + halfLength, testValue);
}
}
}
Aggregations