Search in sources :

Example 1 with AllocatorOutOfMemoryException

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);
        }
    }
}
Also used : MemoryBuffer(org.apache.hadoop.hive.common.io.encoded.MemoryBuffer) AllocatorOutOfMemoryException(org.apache.hadoop.hive.common.io.Allocator.AllocatorOutOfMemoryException)

Aggregations

AllocatorOutOfMemoryException (org.apache.hadoop.hive.common.io.Allocator.AllocatorOutOfMemoryException)1 MemoryBuffer (org.apache.hadoop.hive.common.io.encoded.MemoryBuffer)1