Memory (apache-cassandra API)
Date: 2018-02-12

org.apache.cassandra.io.util

## Class Memory

- java.lang.Object
- - org.apache.cassandra.io.util.Memory

- All Implemented Interfaces:
    java.lang.AutoCloseable
  Direct Known Subclasses:
    RefCountedMemory, SafeMemory

      public class Memory
      extends java.lang.Object
      implements java.lang.AutoCloseable

  An off-heap region of memory that must be manually free'd when no longer needed.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.nio.ByteBuffer[]` | `NO_BYTE_BUFFERS`
    `protected long` | `peer`
    `protected long` | `size`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Memory(long bytes)`
    `protected` | `Memory(Memory copyOf)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Memory` | `allocate(long bytes)`
    `java.nio.ByteBuffer` | `asByteBuffer(long offset, int length)`
    `java.nio.ByteBuffer[]` | `asByteBuffers(long offset, long length)`
    `protected void` | `checkBounds(long start, long end)`
    `void` | `close()`
    `Memory` | `copy(long newSize)`
    `boolean` | `equals(java.lang.Object o)`
    `void` | `free()`
    `byte` | `getByte(long offset)`
    `void` | `getBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)` Transfers count bytes from Memory starting at memoryOffset to buffer starting at bufferOffset
    `int` | `getInt(long offset)`
    `long` | `getLong(long offset)`
    `void` | `put(long trgOffset, Memory memory, long srcOffset, long size)`
    `void` | `setByte(long offset, byte b)`
    `void` | `setByteBuffer(java.nio.ByteBuffer buffer, long offset, int length)`
    `void` | `setBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)` Transfers count bytes from buffer to Memory
    `void` | `setBytes(long memoryOffset, java.nio.ByteBuffer buffer)`
    `void` | `setInt(long offset, int l)`
    `void` | `setLong(long offset, long l)`
    `void` | `setMemory(long offset, long bytes, byte b)`
    `void` | `setShort(long offset, short l)`
    `long` | `size()`
    `java.lang.String` | `toString()`
    `protected static java.lang.String` | `toString(long peer, long size)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### NO_BYTE_BUFFERS

          public static final java.nio.ByteBuffer[] NO_BYTE_BUFFERS

    - #### peer

          protected long peer

    - #### size

          protected final long size

  - ### Constructor Detail

    - #### Memory

          protected Memory(long bytes)

    - #### Memory

          protected Memory(Memory copyOf)

  - ### Method Detail

    - #### allocate

          public static Memory allocate(long bytes)

    - #### setByte

          public void setByte(long offset,
                              byte b)

    - #### setMemory

          public void setMemory(long offset,
                                long bytes,
                                byte b)

    - #### setLong

          public void setLong(long offset,
                              long l)

    - #### setInt

          public void setInt(long offset,
                             int l)

    - #### setShort

          public void setShort(long offset,
                               short l)

    - #### setBytes

          public void setBytes(long memoryOffset,
                               java.nio.ByteBuffer buffer)

    - #### setBytes

          public void setBytes(long memoryOffset,
                               byte[] buffer,
                               int bufferOffset,
                               int count)

      Transfers count bytes from buffer to Memory
      Parameters:
        `memoryOffset` - start offset in the memory
        `buffer` - the data buffer
        `bufferOffset` - start offset of the buffer
        `count` - number of bytes to transfer

    - #### getByte

          public byte getByte(long offset)

    - #### getLong

          public long getLong(long offset)

    - #### getInt

          public int getInt(long offset)

    - #### getBytes

          public void getBytes(long memoryOffset,
                               byte[] buffer,
                               int bufferOffset,
                               int count)

      Transfers count bytes from Memory starting at memoryOffset to buffer starting at bufferOffset
      Parameters:
        `memoryOffset` - start offset in the memory
        `buffer` - the data buffer
        `bufferOffset` - start offset of the buffer
        `count` - number of bytes to transfer

    - #### checkBounds

          @Inline
          protected void checkBounds(long start,
                                             long end)

    - #### put

          public void put(long trgOffset,
                          Memory memory,
                          long srcOffset,
                          long size)

    - #### copy

          public Memory copy(long newSize)

    - #### free

          public void free()

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### size

          public long size()

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### asByteBuffers

          public java.nio.ByteBuffer[] asByteBuffers(long offset,
                                                     long length)

    - #### asByteBuffer

          public java.nio.ByteBuffer asByteBuffer(long offset,
                                                  int length)

    - #### setByteBuffer

          public void setByteBuffer(java.nio.ByteBuffer buffer,
                                    long offset,
                                    int length)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toString

          protected static java.lang.String toString(long peer,
                                                     long size)

Copyright © 2018 The Apache Software Foundation