All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickzetta.platform.operator.MemoryAllocator Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.platform.operator;

import io.netty.buffer.*;

public class MemoryAllocator implements ByteBufAllocator {

  private final ByteBufAllocator allocator;

  private boolean isPooled;

  public MemoryAllocator() {
    this(true);
  }

  public MemoryAllocator(boolean isPooled) {
    this.isPooled = isPooled;
    if (this.isPooled) {
      this.allocator = new PooledByteBufAllocator();
    } else {
      this.allocator = new UnpooledByteBufAllocator(false);
    }
  }

  @Override
  public ByteBuf buffer() {
    return allocator.buffer();
  }

  @Override
  public ByteBuf buffer(int initialCapacity) {
    return allocator.buffer(initialCapacity);
  }

  @Override
  public ByteBuf buffer(int initialCapacity, int maxCapacity) {
    return allocator.buffer(initialCapacity, maxCapacity);
  }

  @Override
  public ByteBuf ioBuffer() {
    return allocator.ioBuffer();
  }

  @Override
  public ByteBuf ioBuffer(int initialCapacity) {
    return allocator.ioBuffer(initialCapacity);
  }

  @Override
  public ByteBuf ioBuffer(int initialCapacity, int maxCapacity) {
    return allocator.ioBuffer(initialCapacity, maxCapacity);
  }

  @Override
  public ByteBuf heapBuffer() {
    return allocator.heapBuffer();
  }

  @Override
  public ByteBuf heapBuffer(int initialCapacity) {
    return allocator.heapBuffer(initialCapacity);
  }

  @Override
  public ByteBuf heapBuffer(int initialCapacity, int maxCapacity) {
    return allocator.heapBuffer(initialCapacity, maxCapacity);
  }

  @Override
  public ByteBuf directBuffer() {
    return allocator.directBuffer();
  }

  @Override
  public ByteBuf directBuffer(int initialCapacity) {
    return allocator.directBuffer(initialCapacity);
  }

  @Override
  public ByteBuf directBuffer(int initialCapacity, int maxCapacity) {
    return allocator.directBuffer(initialCapacity, maxCapacity);
  }

  @Override
  public CompositeByteBuf compositeBuffer() {
    return allocator.compositeBuffer();
  }

  @Override
  public CompositeByteBuf compositeBuffer(int maxNumComponents) {
    return allocator.compositeBuffer(maxNumComponents);
  }

  @Override
  public CompositeByteBuf compositeHeapBuffer() {
    return allocator.compositeHeapBuffer();
  }

  @Override
  public CompositeByteBuf compositeHeapBuffer(int maxNumComponents) {
    return allocator.compositeHeapBuffer(maxNumComponents);
  }

  @Override
  public CompositeByteBuf compositeDirectBuffer() {
    return allocator.compositeDirectBuffer();
  }

  @Override
  public CompositeByteBuf compositeDirectBuffer(int maxNumComponents) {
    return allocator.compositeDirectBuffer(maxNumComponents);
  }

  @Override
  public boolean isDirectBufferPooled() {
    return allocator.isDirectBufferPooled();
  }

  @Override
  public int calculateNewCapacity(int minNewCapacity, int maxCapacity) {
    return allocator.calculateNewCapacity(minNewCapacity, maxCapacity);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy