// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT   = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT      = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT      = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT    = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT     = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT       = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT      = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT     = 1;


import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
    state.putCapacity(capacity);
    return AllocateDirectWritableMap.map(state);
  }

  //ALLOCATE DIRECT

  /**
   * Allocates and provides access to capacityBytes directly in native (off-heap) memory
   * leveraging the WritableMemory API.
   * The allocated memory will be 8-byte aligned, but may not be page aligned.
   * @param capacityBytes the size of the desired memory in bytes
   * @return WritableResourceHandler for managing this off-heap resource
   */
  public static WritableResourceHandler allocateDirect(final long capacityBytes) {
    return allocateDirect(capacityBytes, null);
  }

  /**
   * Allocates and provides access to capacityBytes directly in native (off-heap) memory
   * leveraging the WritableMemory API.
   * The allocated memory will be 8-byte aligned, but may not be page aligned.
   * @param capacityBytes the size of the desired memory in bytes
   * @param memReq optional callback
   * @return WritableResourceHandler for managing this off-heap resource
   */
  public static WritableResourceHandler allocateDirect(final long capacityBytes,
      final MemoryRequest memReq) {
    final MemoryState state = new MemoryState();
    state.putCapacity(capacityBytes);
    state.putMemoryRequest(memReq);
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT   = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT      = 0;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT      = 1;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT    = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT     = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT       = 2;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT      = 3;
// 
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT     = 1;


// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

    state.putCapacity(capacity);
    return AllocateDirectWritableMap.map(state);
  }

  //ALLOCATE DIRECT

  /**
   * Allocates and provides access to capacityBytes directly in native (off-heap) memory
   * leveraging the WritableMemory API.
   * The allocated memory will be 8-byte aligned, but may not be page aligned.
   * @param capacityBytes the size of the desired memory in bytes
   * @return WritableResourceHandler for managing this off-heap resource
   */
  public static WritableResourceHandler allocateDirect(final long capacityBytes) {
    return allocateDirect(capacityBytes, null);
  }

  /**
   * Allocates and provides access to capacityBytes directly in native (off-heap) memory
   * leveraging the WritableMemory API.
   * The allocated memory will be 8-byte aligned, but may not be page aligned.
   * @param capacityBytes the size of the desired memory in bytes
   * @param memReq optional callback
   * @return WritableResourceHandler for managing this off-heap resource
   */
  public static WritableResourceHandler allocateDirect(final long capacityBytes,
      final MemoryRequest memReq) {
    final MemoryState state = new MemoryState();
    state.putCapacity(capacityBytes);
    state.putMemoryRequest(memReq);
    return (WritableResourceHandler) AllocateDirect.allocDirect(state);