use of org.apache.carbondata.core.memory.MemoryBlock in project carbondata by apache.
the class VarLengthColumnPageBase method ensureMemory.
/**
* reallocate memory if capacity length than current size + request size
*/
protected void ensureMemory(int requestSize) throws MemoryException {
if (totalLength + requestSize > capacity) {
int newSize = Math.max(2 * capacity, totalLength + requestSize);
MemoryBlock newBlock = UnsafeMemoryManager.allocateMemoryWithRetry(taskId, newSize);
CarbonUnsafe.getUnsafe().copyMemory(baseAddress, baseOffset, newBlock.getBaseObject(), newBlock.getBaseOffset(), capacity);
UnsafeMemoryManager.INSTANCE.freeMemory(taskId, memoryBlock);
memoryBlock = newBlock;
baseAddress = newBlock.getBaseObject();
baseOffset = newBlock.getBaseOffset();
capacity = newSize;
}
}
use of org.apache.carbondata.core.memory.MemoryBlock in project carbondata by apache.
the class UnsafeMemoryDMStore method increaseMemory.
private void increaseMemory() throws MemoryException {
MemoryBlock allocate = UnsafeMemoryManager.allocateMemoryWithRetry(taskId, allocatedSize + capacity);
getUnsafe().copyMemory(memoryBlock.getBaseObject(), memoryBlock.getBaseOffset(), allocate.getBaseObject(), allocate.getBaseOffset(), runningLength);
UnsafeMemoryManager.INSTANCE.freeMemory(taskId, memoryBlock);
allocatedSize = allocatedSize + capacity;
memoryBlock = allocate;
}
use of org.apache.carbondata.core.memory.MemoryBlock in project carbondata by apache.
the class UnsafeSortDataRows method createUnsafeRowPage.
private UnsafeCarbonRowPage createUnsafeRowPage() {
MemoryBlock baseBlock = UnsafeMemoryManager.allocateMemoryWithRetry(this.taskId, inMemoryChunkSize);
boolean isSaveToDisk = UnsafeSortMemoryManager.INSTANCE.isMemoryAvailable(baseBlock.size());
if (!isSaveToDisk) {
// merge and spill in-memory pages to disk if memory is not enough
unsafeInMemoryIntermediateFileMerger.tryTriggerInMemoryMerging(true);
}
return new UnsafeCarbonRowPage(tableFieldStat, baseBlock, taskId, true);
}
use of org.apache.carbondata.core.memory.MemoryBlock in project carbondata by apache.
the class UnsafeFixLengthColumnPage method ensureMemory.
/**
* reallocate memory if capacity length than current size + request size
*/
protected void ensureMemory(int requestSize) {
checkDataFileSize();
if (totalLength + requestSize > capacity) {
int newSize = Math.max(2 * capacity, totalLength + requestSize);
MemoryBlock newBlock = UnsafeMemoryManager.allocateMemoryWithRetry(taskId, newSize);
CarbonUnsafe.getUnsafe().copyMemory(baseAddress, baseOffset, newBlock.getBaseObject(), newBlock.getBaseOffset(), totalLength);
UnsafeMemoryManager.INSTANCE.freeMemory(taskId, memoryBlock);
memoryBlock = newBlock;
baseAddress = newBlock.getBaseObject();
baseOffset = newBlock.getBaseOffset();
capacity = newSize;
}
}
use of org.apache.carbondata.core.memory.MemoryBlock in project carbondata by apache.
the class UnsafeMemoryManager method allocateMemory.
public synchronized MemoryBlock allocateMemory(long memoryRequested) {
if (memoryUsed + memoryRequested <= totalMemory) {
MemoryBlock allocate = allocator.allocate(memoryRequested);
memoryUsed += allocate.size();
LOGGER.info("Memory block is created with size " + allocate.size() + " Total memory used " + memoryUsed + " memory left " + (getAvailableMemory()));
return allocate;
}
return null;
}
Aggregations