Java Code Examples for org.apache.arrow.memory.BufferAllocator#getHeadroom()

The following examples show how to use org.apache.arrow.memory.BufferAllocator#getHeadroom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalSortTracer.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
public void setExternalSortAllocatorState(final BufferAllocator sortAllocator) {
  /* this is the parent allocator passed to ExternalSortOperator as part of
   * operator context. it is then used by MemoryRun and DiskRunManager to create
   * child allocators.
   */
  if (sortAllocator == null) {
    sortAllocatorState.valid = false;
  } else {
    sortAllocatorState.valid = true;
    sortAllocatorState.name = sortAllocator.getName();
    sortAllocatorState.allocatedMemory = sortAllocator.getAllocatedMemory();
    sortAllocatorState.peakAllocation = sortAllocator.getPeakMemoryAllocation();
    sortAllocatorState.maxAllowed = sortAllocator.getLimit();
    sortAllocatorState.headRoom = sortAllocator.getHeadroom();
    sortAllocatorState.initReservation = sortAllocator.getInitReservation();
  }
}
 
Example 2
Source File: ExternalSortTracer.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
ReserveMemoryForSpillOOMEvent(final long initReservation, final long maxAllocation,
                              final BufferAllocator oldSpillCopyAllocator) {
  this.failedInitReservation = initReservation;
  this.failedMaxAllocation = maxAllocation;
  if (oldSpillCopyAllocator != null) {
    this.previousAllocatedMemory = oldSpillCopyAllocator.getAllocatedMemory();
    this.previousHeadRoom = oldSpillCopyAllocator.getHeadroom();
    this.previousMaxAllocation = oldSpillCopyAllocator.getLimit();
    this.previousInitReservation = oldSpillCopyAllocator.getInitReservation();
  } else {
    this.previousAllocatedMemory = 0L;
    this.previousHeadRoom = 0L;
    this.previousMaxAllocation = 0L;
    this.previousInitReservation = 0L;
  }
}
 
Example 3
Source File: ExternalSortTracer.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public void setSpillCopyAllocatorState(final BufferAllocator spillCopyAllocator) {
  if (spillCopyAllocator == null) {
    spillCopyAllocatorState.valid = false;
  } else {
    spillCopyAllocatorState.valid = true;
    spillCopyAllocatorState.name = spillCopyAllocator.getName();
    spillCopyAllocatorState.allocatedMemory = spillCopyAllocator.getAllocatedMemory();
    spillCopyAllocatorState.peakAllocation = spillCopyAllocator.getPeakMemoryAllocation();
    spillCopyAllocatorState.maxAllowed = spillCopyAllocator.getLimit();
    spillCopyAllocatorState.headRoom = spillCopyAllocator.getHeadroom();
    spillCopyAllocatorState.initReservation = spillCopyAllocator.getInitReservation();
  }
}
 
Example 4
Source File: ExternalSortTracer.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public void setDiskRunCopyAllocatorState(final BufferAllocator diskRunCopyAllocator) {
  if (diskRunCopyAllocator == null) {
    diskRunCopyAllocatorState.valid = false;
  } else {
    diskRunCopyAllocatorState.valid = true;
    diskRunCopyAllocatorState.name = diskRunCopyAllocator.getName();
    diskRunCopyAllocatorState.allocatedMemory = diskRunCopyAllocator.getAllocatedMemory();
    diskRunCopyAllocatorState.peakAllocation = diskRunCopyAllocator.getPeakMemoryAllocation();
    diskRunCopyAllocatorState.maxAllowed = diskRunCopyAllocator.getLimit();
    diskRunCopyAllocatorState.headRoom = diskRunCopyAllocator.getHeadroom();
    diskRunCopyAllocatorState.initReservation = diskRunCopyAllocator.getInitReservation();
  }
}
 
Example 5
Source File: AllocatorUtil.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures there is headroom in the allocator. Throws an exception if not sufficient.
 * @param allocator
 * @param headRoom
 */
public static void ensureHeadroom(BufferAllocator allocator, long headRoom) throws OutOfMemoryException {
  if (allocator.getHeadroom() >= headRoom) {
    // nothing to do in this case.
    return;
  }

  // do a dummy allocation so that we get the allocation states as part of the exception.
  try (ArrowBuf buffer = allocator.buffer(headRoom)) {}
}