Example usage for org.apache.spark.unsafe.array LongArray LongArray

List of usage examples for org.apache.spark.unsafe.array LongArray LongArray

Introduction

In this page you can find the example usage for org.apache.spark.unsafe.array LongArray LongArray.

Prototype

public LongArray(MemoryBlock memory) 

Source Link

Usage

From source file:edu.ucla.cs.wis.bigdatalog.spark.storage.map.BytesToBytesMap.java

License:Apache License

/**
 * Allocates a LongArray of `size`.//from w w  w .j a  v a2  s.  c om
 */
public LongArray allocateArray(long size) {
    long required = size * 8L;
    MemoryBlock page = memoryManager.allocatePage(required);
    if (page == null || page.size() < required) {
        long got = 0;
        if (page != null) {
            got = page.size();
            memoryManager.freePage(page);
        }
        //memoryManager.showMemoryUsage();
        throw new OutOfMemoryError("Unable to acquire " + required + " bytes of memory, got " + got);
    }
    used += required;
    return new LongArray(page);
}