Package org.agrona

Class AbstractMutableDirectBuffer

java.lang.Object
org.agrona.AbstractMutableDirectBuffer
All Implemented Interfaces:
Comparable<DirectBuffer>, DirectBuffer, MutableDirectBuffer
Direct Known Subclasses:
ExpandableArrayBuffer, ExpandableDirectByteBuffer, UnsafeBuffer

public abstract class AbstractMutableDirectBuffer extends Object implements MutableDirectBuffer
Common super class for implementing MutableDirectBuffer interface.
  • Field Details

    • byteArray

      protected byte[] byteArray
    • addressOffset

      protected long addressOffset
    • capacity

      protected int capacity
  • Constructor Details

    • AbstractMutableDirectBuffer

      public AbstractMutableDirectBuffer()
  • Method Details

    • byteArray

      public byte[] byteArray()
      Get the underlying byte[] if one exists.

      NB: there may not be a one-to-one mapping between indices on this buffer and the underlying byte[], see DirectBuffer.wrapAdjustment().

      Specified by:
      byteArray in interface DirectBuffer
      Returns:
      the underlying byte[] if one exists.
      See Also:
    • addressOffset

      public long addressOffset()
      Reads the underlying offset to the memory address.
      Specified by:
      addressOffset in interface DirectBuffer
      Returns:
      the underlying offset to the memory address.
    • capacity

      public int capacity()
      Get the capacity of the underlying buffer.
      Specified by:
      capacity in interface DirectBuffer
      Returns:
      the capacity of the underlying buffer in bytes.
    • checkLimit

      public void checkLimit(int limit)
      Check that a given limit is not greater than the capacity of a buffer from a given offset.

      Can be overridden in a DirectBuffer subclass to enable an extensible buffer or handle retry after a flush.

      Specified by:
      checkLimit in interface DirectBuffer
      Parameters:
      limit - up to which access is required.
    • setMemory

      public void setMemory(int index, int length, byte value)
      Set a region of memory to a given byte value.
      Specified by:
      setMemory in interface MutableDirectBuffer
      Parameters:
      index - at which to start.
      length - of the run of bytes to set.
      value - the memory will be set to.
    • getLong

      public long getLong(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getLong in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value for at a given index.
    • putLong

      public void putLong(int index, long value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putLong in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - for at a given index.
      byteOrder - of the value when written.
    • getLong

      public long getLong(int index)
      Get the value at a given index.
      Specified by:
      getLong in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value for at a given index.
    • putLong

      public void putLong(int index, long value)
      Put a value to a given index.
      Specified by:
      putLong in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - for at a given index.
    • getInt

      public int getInt(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getInt in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value at a given index.
    • putInt

      public void putInt(int index, int value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putInt in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
      byteOrder - of the value when written.
    • getInt

      public int getInt(int index)
      Get the value at a given index.
      Specified by:
      getInt in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value for a given index.
    • putInt

      public void putInt(int index, int value)
      Put a value to a given index.
      Specified by:
      putInt in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - for at a given index.
    • getDouble

      public double getDouble(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getDouble in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value at a given index.
    • putDouble

      public void putDouble(int index, double value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putDouble in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
      byteOrder - of the value when written.
    • getDouble

      public double getDouble(int index)
      Get the value at a given index.
      Specified by:
      getDouble in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value at a given index.
    • putDouble

      public void putDouble(int index, double value)
      Put a value to a given index.
      Specified by:
      putDouble in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
    • getFloat

      public float getFloat(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getFloat in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value at a given index.
    • putFloat

      public void putFloat(int index, float value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putFloat in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
      byteOrder - of the value when written.
    • getFloat

      public float getFloat(int index)
      Get the value at a given index.
      Specified by:
      getFloat in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value at a given index.
    • putFloat

      public void putFloat(int index, float value)
      Put a value to a given index.
      Specified by:
      putFloat in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
    • getShort

      public short getShort(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getShort in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value at a given index.
    • putShort

      public void putShort(int index, short value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putShort in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
      byteOrder - of the value when written.
    • getShort

      public short getShort(int index)
      Get the value at a given index.
      Specified by:
      getShort in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value at a given index.
    • putShort

      public void putShort(int index, short value)
      Put a value to a given index.
      Specified by:
      putShort in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
    • getByte

      public byte getByte(int index)
      Get the value at a given index.
      Specified by:
      getByte in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value at a given index.
    • putByte

      public void putByte(int index, byte value)
      Put a value to a given index.
      Specified by:
      putByte in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
    • getBytes

      public void getBytes(int index, byte[] dst)
      Get from the underlying buffer into a supplied byte array. This method will try to fill the supplied byte array.
      Specified by:
      getBytes in interface DirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      dst - into which the dst will be copied.
    • getBytes

      public void getBytes(int index, byte[] dst, int offset, int length)
      Get bytes from the underlying buffer into a supplied byte array.
      Specified by:
      getBytes in interface DirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      dst - into which the bytes will be copied.
      offset - in the supplied buffer to start the copy.
      length - of the supplied buffer to use.
    • getBytes

      public void getBytes(int index, MutableDirectBuffer dstBuffer, int dstIndex, int length)
      Get bytes from this DirectBuffer into the provided MutableDirectBuffer at given indices.
      Specified by:
      getBytes in interface DirectBuffer
      Parameters:
      index - in this buffer to begin getting the bytes.
      dstBuffer - to which the bytes will be copied.
      dstIndex - in the channel buffer to which the byte copy will begin.
      length - of the bytes to be copied.
    • getBytes

      public void getBytes(int index, ByteBuffer dstBuffer, int length)
      Get from the underlying buffer into a supplied ByteBuffer current Buffer.position().

      The destination buffer will have its Buffer.position() advanced as a result.

      Specified by:
      getBytes in interface DirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      dstBuffer - into which the bytes will be copied.
      length - of the supplied buffer to use.
    • getBytes

      public void getBytes(int index, ByteBuffer dstBuffer, int dstOffset, int length)
      Get from the underlying buffer into a supplied ByteBuffer at an offset.

      The destination buffer will not have its Buffer.position() advanced as a result.

      Specified by:
      getBytes in interface DirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      dstBuffer - into which the bytes will be copied.
      dstOffset - in the target buffer.
      length - of the supplied buffer to use.
    • putBytes

      public void putBytes(int index, byte[] src)
      Put an array of src into the underlying buffer.
      Specified by:
      putBytes in interface MutableDirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      src - to be copied into the underlying buffer.
    • putBytes

      public void putBytes(int index, byte[] src, int offset, int length)
      Put an array into the underlying buffer.
      Specified by:
      putBytes in interface MutableDirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      src - to be copied to the underlying buffer.
      offset - in the supplied buffer to begin the copy.
      length - of the supplied buffer to copy.
    • putBytes

      public void putBytes(int index, ByteBuffer srcBuffer, int length)
      Put bytes into the underlying buffer for the view. Bytes will be copied from current Buffer.position() for a given length.

      The source buffer will have its Buffer.position() advanced as a result.

      Specified by:
      putBytes in interface MutableDirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      srcBuffer - to copy the bytes from.
      length - of the supplied buffer to copy.
    • putBytes

      public void putBytes(int index, ByteBuffer srcBuffer, int srcIndex, int length)
      Put bytes into the underlying buffer for the view. Bytes will be copied from the buffer index to the buffer index + length.

      The source buffer will not have its Buffer.position() advanced as a result.

      Specified by:
      putBytes in interface MutableDirectBuffer
      Parameters:
      index - in the underlying buffer to start from.
      srcBuffer - to copy the bytes from (does not change position).
      srcIndex - in the source buffer from which the copy will begin.
      length - of the bytes to be copied.
    • putBytes

      public void putBytes(int index, DirectBuffer srcBuffer, int srcIndex, int length)
      Put bytes from a source DirectBuffer into this MutableDirectBuffer at given indices.
      Specified by:
      putBytes in interface MutableDirectBuffer
      Parameters:
      index - in this buffer to begin putting the bytes.
      srcBuffer - from which the bytes will be copied.
      srcIndex - in the source buffer from which the byte copy will begin.
      length - of the bytes to be copied.
    • getChar

      public char getChar(int index, ByteOrder byteOrder)
      Get the value at a given index.
      Specified by:
      getChar in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      byteOrder - of the value to be read.
      Returns:
      the value at a given index.
    • putChar

      public void putChar(int index, char value, ByteOrder byteOrder)
      Put a value to a given index.
      Specified by:
      putChar in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
      byteOrder - of the value when written.
    • getChar

      public char getChar(int index)
      Get the value at a given index.
      Specified by:
      getChar in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      Returns:
      the value at a given index.
    • putChar

      public void putChar(int index, char value)
      Put a value to a given index.
      Specified by:
      putChar in interface MutableDirectBuffer
      Parameters:
      index - in bytes for where to put.
      value - to be written.
    • getStringAscii

      public String getStringAscii(int index)
      Get a String from bytes encoded in ASCII format that is length prefixed.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      Returns:
      the String as represented by the ASCII encoded bytes.
    • getStringAscii

      public int getStringAscii(int index, Appendable appendable)
      Get a String from bytes encoded in ASCII format that is length prefixed and append to an Appendable.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      appendable - to append the chars to.
      Returns:
      the number of bytes copied.
    • getStringAscii

      public String getStringAscii(int index, ByteOrder byteOrder)
      Get a String from bytes encoded in ASCII format that is length prefixed.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      byteOrder - for the length at the beginning of the String.
      Returns:
      the String as represented by the ASCII encoded bytes.
    • getStringAscii

      public int getStringAscii(int index, Appendable appendable, ByteOrder byteOrder)
      Get a String from bytes encoded in ASCII format that is length prefixed and append to an Appendable.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      appendable - to append the chars to.
      byteOrder - for the length at the beginning of the String.
      Returns:
      the number of bytes copied.
    • getStringAscii

      public String getStringAscii(int index, int length)
      Get part of a String from bytes encoded in ASCII format that is length prefixed.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      Returns:
      the String as represented by the ASCII encoded bytes.
    • getStringAscii

      public int getStringAscii(int index, int length, Appendable appendable)
      Get part of a String from bytes encoded in ASCII format that is length prefixed and append to an Appendable.
      Specified by:
      getStringAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      appendable - to append the chars to.
      Returns:
      the number of bytes copied.
    • putStringAscii

      public int putStringAscii(int index, String value)
      Encode a String as ASCII bytes to the buffer with a length prefix.
      Specified by:
      putStringAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      Returns:
      the number of bytes put into the buffer.
    • putStringAscii

      public int putStringAscii(int index, CharSequence value)
      Encode a CharSequence as ASCII bytes to the buffer with a length prefix.
      Specified by:
      putStringAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the CharSequence should be encoded.
      value - of the CharSequence to be encoded.
      Returns:
      the number of bytes put into the buffer.
    • putStringAscii

      public int putStringAscii(int index, String value, ByteOrder byteOrder)
      Encode a String as ASCII bytes to the buffer with a length prefix.
      Specified by:
      putStringAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      byteOrder - for the length prefix.
      Returns:
      the number of bytes put into the buffer.
    • putStringAscii

      public int putStringAscii(int index, CharSequence value, ByteOrder byteOrder)
      Encode a CharSequence as ASCII bytes to the buffer with a length prefix.
      Specified by:
      putStringAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the CharSequence should be encoded.
      value - of the CharSequence to be encoded.
      byteOrder - for the length prefix.
      Returns:
      the number of bytes put into the buffer.
    • getStringWithoutLengthAscii

      public String getStringWithoutLengthAscii(int index, int length)
      Get an encoded ASCII String from the buffer that does not have a length prefix.
      Specified by:
      getStringWithoutLengthAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      Returns:
      the String as represented by the Ascii encoded bytes.
    • getStringWithoutLengthAscii

      public int getStringWithoutLengthAscii(int index, int length, Appendable appendable)
      Get an encoded ASCII String from the buffer that does not have a length prefix and append to an Appendable.
      Specified by:
      getStringWithoutLengthAscii in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      appendable - to append the chars to.
      Returns:
      the number of bytes copied.
    • putStringWithoutLengthAscii

      public int putStringWithoutLengthAscii(int index, String value)
      Encode a String as ASCII bytes in the buffer without a length prefix.
      Specified by:
      putStringWithoutLengthAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the String begins.
      value - of the String to be encoded.
      Returns:
      the number of bytes encoded.
    • putStringWithoutLengthAscii

      public int putStringWithoutLengthAscii(int index, CharSequence value)
      Encode a CharSequence as ASCII bytes in the buffer without a length prefix.
      Specified by:
      putStringWithoutLengthAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the CharSequence begins.
      value - of the CharSequence to be encoded.
      Returns:
      the number of bytes encoded.
    • putStringWithoutLengthAscii

      public int putStringWithoutLengthAscii(int index, String value, int valueOffset, int length)
      Encode a String as ASCII bytes in the buffer without a length prefix taking a range of the value.
      Specified by:
      putStringWithoutLengthAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the String begins.
      value - of the String to be encoded.
      valueOffset - in the value String to begin.
      length - of the value String to encode. If this is greater than valueOffset - value length then the lesser will be used.
      Returns:
      the number of bytes encoded.
    • putStringWithoutLengthAscii

      public int putStringWithoutLengthAscii(int index, CharSequence value, int valueOffset, int length)
      Encode a CharSequence as ASCII bytes in the buffer without a length prefix taking a range of the value.
      Specified by:
      putStringWithoutLengthAscii in interface MutableDirectBuffer
      Parameters:
      index - at which the CharSequence begins.
      value - of the CharSequence to be encoded.
      valueOffset - in the value CharSequence to begin.
      length - of the value CharSequence to encode. If this is greater than valueOffset - value length then the lesser will be used.
      Returns:
      the number of bytes encoded.
    • getStringUtf8

      public String getStringUtf8(int index)
      Get a String from bytes encoded in UTF-8 format that is length prefixed.
      Specified by:
      getStringUtf8 in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      Returns:
      the String as represented by the UTF-8 encoded bytes.
    • getStringUtf8

      public String getStringUtf8(int index, ByteOrder byteOrder)
      Get a String from bytes encoded in UTF-8 format that is length prefixed.
      Specified by:
      getStringUtf8 in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      byteOrder - for the length at the beginning of the String.
      Returns:
      the String as represented by the UTF-8 encoded bytes.
    • getStringUtf8

      public String getStringUtf8(int index, int length)
      Get part of String from bytes encoded in UTF-8 format that is length prefixed.
      Specified by:
      getStringUtf8 in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      Returns:
      the String as represented by the UTF-8 encoded bytes.
    • putStringUtf8

      public int putStringUtf8(int index, String value)
      Encode a String as UTF-8 bytes to the buffer with a length prefix.
      Specified by:
      putStringUtf8 in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      Returns:
      the number of bytes put into the buffer.
    • putStringUtf8

      public int putStringUtf8(int index, String value, ByteOrder byteOrder)
      Encode a String as UTF-8 bytes to the buffer with a length prefix.
      Specified by:
      putStringUtf8 in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      byteOrder - for the length prefix.
      Returns:
      the number of bytes put into the buffer.
    • putStringUtf8

      public int putStringUtf8(int index, String value, int maxEncodedLength)
      Encode a String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.
      Specified by:
      putStringUtf8 in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      maxEncodedLength - to be checked before writing to the buffer.
      Returns:
      the number of bytes put into the buffer.
    • putStringUtf8

      public int putStringUtf8(int index, String value, ByteOrder byteOrder, int maxEncodedLength)
      Encode a String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.
      Specified by:
      putStringUtf8 in interface MutableDirectBuffer
      Parameters:
      index - at which the String should be encoded.
      value - of the String to be encoded.
      byteOrder - for the length prefix.
      maxEncodedLength - to be checked before writing to the buffer.
      Returns:
      the number of bytes put into the buffer.
    • getStringWithoutLengthUtf8

      public String getStringWithoutLengthUtf8(int index, int length)
      Get an encoded UTF-8 String from the buffer that does not have a length prefix.
      Specified by:
      getStringWithoutLengthUtf8 in interface DirectBuffer
      Parameters:
      index - at which the String begins.
      length - of the String in bytes to decode.
      Returns:
      the String as represented by the UTF-8 encoded bytes.
    • putStringWithoutLengthUtf8

      public int putStringWithoutLengthUtf8(int index, String value)
      Encode a String as UTF-8 bytes in the buffer without a length prefix.
      Specified by:
      putStringWithoutLengthUtf8 in interface MutableDirectBuffer
      Parameters:
      index - at which the String begins.
      value - of the String to be encoded.
      Returns:
      the number of bytes encoded.
    • parseNaturalIntAscii

      public int parseNaturalIntAscii(int index, int length)
      Parse the ASCII encoded int sized natural value at a given index.
      Specified by:
      parseNaturalIntAscii in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      length - the length in bytes to parse.
      Returns:
      the value at a given index.
    • parseNaturalLongAscii

      public long parseNaturalLongAscii(int index, int length)
      Parse the ASCII encoded long sized natural value at a given index.
      Specified by:
      parseNaturalLongAscii in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      length - the length in bytes to parse.
      Returns:
      the value at a given index.
    • parseIntAscii

      public int parseIntAscii(int index, int length)
      Parse the ASCII encoded integer value at a given index.
      Specified by:
      parseIntAscii in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      length - the length in bytes to parse.
      Returns:
      the value at a given index.
    • parseLongAscii

      public long parseLongAscii(int index, int length)
      Parse the ASCII encoded long integer value at a given index.
      Specified by:
      parseLongAscii in interface DirectBuffer
      Parameters:
      index - in bytes from which to get.
      length - the length in bytes to parse.
      Returns:
      the value at a given index.
    • putIntAscii

      public int putIntAscii(int index, int value)
      Puts an ASCII encoded int into the buffer.
      Specified by:
      putIntAscii in interface MutableDirectBuffer
      Parameters:
      index - the offset at which to put the int.
      value - the int to write.
      Returns:
      the number of bytes that the int took up encoded.
    • putNaturalIntAscii

      public int putNaturalIntAscii(int index, int value)
      Puts an ASCII encoded int sized natural number into the buffer.
      Specified by:
      putNaturalIntAscii in interface MutableDirectBuffer
      Parameters:
      index - the offset at which to put the int.
      value - the int to write.
      Returns:
      the number of bytes that the int took up encoded.
    • putNaturalPaddedIntAscii

      public void putNaturalPaddedIntAscii(int offset, int length, int value)
      Encode a natural number with a specified maximum length.

      If ascii encoding of the number is less than the specified length then the start will be pre-padded with zeros, if the value takes up more space than the allowed length then a NumberFormatException will be thrown.

      Specified by:
      putNaturalPaddedIntAscii in interface MutableDirectBuffer
      Parameters:
      offset - the offset to start encoding at.
      length - the maximum length to encode.
      value - the value to encode.
    • putNaturalIntAsciiFromEnd

      public int putNaturalIntAsciiFromEnd(int value, int endExclusive)
      Encode a natural number starting at its end position.
      Specified by:
      putNaturalIntAsciiFromEnd in interface MutableDirectBuffer
      Parameters:
      value - the natural number to encode.
      endExclusive - index after the last character encoded.
      Returns:
      startInclusive index of first character encoded.
    • putNaturalLongAscii

      public int putNaturalLongAscii(int index, long value)
      Puts an ASCII encoded long sized natural number into the buffer.
      Specified by:
      putNaturalLongAscii in interface MutableDirectBuffer
      Parameters:
      index - the offset at which to put the int.
      value - the int to write.
      Returns:
      the number of bytes that the int took up encoded.
    • putLongAscii

      public int putLongAscii(int index, long value)
      Puts an ASCII encoded long integer into the buffer.
      Specified by:
      putLongAscii in interface MutableDirectBuffer
      Parameters:
      index - the offset at which to put the int.
      value - the int to write.
      Returns:
      the number of bytes that the int took up encoded.
    • boundsCheck

      public void boundsCheck(int index, int length)
      Check that a given length of bytes is within the bounds from a given index.
      Specified by:
      boundsCheck in interface DirectBuffer
      Parameters:
      index - from which to check.
      length - in bytes of the range to check.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(DirectBuffer that)
      Specified by:
      compareTo in interface Comparable<DirectBuffer>
    • boundsCheck0

      protected final void boundsCheck0(int index, int length)
    • ensureCapacity

      protected abstract void ensureCapacity(int index, int length)
    • parsePositiveIntAscii

      private int parsePositiveIntAscii(int index, int length, int startIndex, int end)
    • parsePositiveIntAsciiOverflowCheck

      private long parsePositiveIntAsciiOverflowCheck(int index, int length, int startIndex, int end)
    • throwParseIntError

      private void throwParseIntError(int index, int length)
    • throwParseIntOverflowError

      private void throwParseIntOverflowError(int index, int length)
    • parsePositiveLongAscii

      private long parsePositiveLongAscii(int index, int length, int startIndex, int end)
    • parseLongAsciiOverflowCheck

      private long parseLongAsciiOverflowCheck(int index, int length, int[] maxValue, int startIndex, int end)
    • throwParseLongError

      private void throwParseLongError(int index, int length)
    • throwParseLongOverflowError

      private void throwParseLongOverflowError(int index, int length)
    • putPositiveIntAscii

      private static void putPositiveIntAscii(byte[] dest, long offset, int value, int digitCount)
    • putPositiveLongAscii

      private static void putPositiveLongAscii(byte[] dest, long offset, long value, int digitCount)