Class ClickHouseByteBuffer

java.lang.Object
com.clickhouse.data.ClickHouseByteBuffer
All Implemented Interfaces:
Serializable

@Deprecated public final class ClickHouseByteBuffer extends Object implements Serializable
Deprecated.
This class represents a slice of a byte array. It holds a reference to a byte array, and it uses position() and length() to define the slice. You may think of it as a lite version of ByteBuffer.
See Also:
  • Field Details

    • EMPTY_BYTES

      public static final byte[] EMPTY_BYTES
      Deprecated.
      Empty byte array.
    • EMPTY_BUFFER

      public static final ByteBuffer EMPTY_BUFFER
      Deprecated.
      Empty and read-only byte buffer.
    • array

      protected byte[] array
      Deprecated.
    • position

      protected int position
      Deprecated.
    • length

      protected int length
      Deprecated.
  • Constructor Details

    • ClickHouseByteBuffer

      protected ClickHouseByteBuffer(byte[] bytes, int offset, int length)
      Deprecated.
      Default constructor.
      Parameters:
      bytes - non-null byte array
      offset - start position
      length - length of bytes
  • Method Details

    • newInstance

      public static ClickHouseByteBuffer newInstance()
      Deprecated.
      Creates an empty byte buffer.
      Returns:
      empty byte buffer
    • of

      public static ClickHouseByteBuffer of(ByteBuffer buffer)
      Deprecated.
      Wraps given byte buffer.
      Parameters:
      buffer - byte buffer
      Returns:
      non-null wrapped byte buffer
    • of

      public static ClickHouseByteBuffer of(byte[] bytes)
      Deprecated.
      Wraps given byte array as byte buffer.
      Parameters:
      bytes - byte array
      Returns:
      non-null byte buffer
    • of

      public static ClickHouseByteBuffer of(byte[] bytes, int offset, int length)
      Deprecated.
      Wraps given byte array as byte buffer.
      Parameters:
      bytes - byte array
      offset - start position
      length - length
      Returns:
      non-null byte buffer
    • of

      public static ClickHouseByteBuffer of(List<byte[]> list, int offset, int length)
      Deprecated.
      Wraps given byte arrays as byte buffer.
      Parameters:
      list - list of non-null byte arrays
      offset - offset
      length - length
      Returns:
      non-null byte buffer
    • asBigInteger

      public BigInteger asBigInteger()
      Deprecated.
      Converts all bytes(little-endian) to signed big integer. Same as getBigInteger(0, length(), false).
      Returns:
      non-null signed big integer
    • asBigDecimal

      public BigDecimal asBigDecimal()
      Deprecated.
    • asBigDecimal

      public BigDecimal asBigDecimal(int scale)
      Deprecated.
    • asBoolean

      public boolean asBoolean()
      Deprecated.
    • asBooleanArray

      public boolean[] asBooleanArray()
      Deprecated.
    • asDouble

      public double asDouble()
      Deprecated.
    • asDoubleArray

      public double[] asDoubleArray()
      Deprecated.
    • asDate

      public LocalDate asDate()
      Deprecated.
    • asDateTime

      public LocalDateTime asDateTime()
      Deprecated.
    • asDateTime

      public LocalDateTime asDateTime(int scale)
      Deprecated.
    • asFloat

      public float asFloat()
      Deprecated.
    • asFloatArray

      public float[] asFloatArray()
      Deprecated.
    • asUnsignedBigInteger

      public BigInteger asUnsignedBigInteger()
      Deprecated.
      Converts all bytes(little-endian) to unsigned big integer. Same as getBigInteger(0, length(), true).
      Returns:
      non-null unsigned big integer
    • getBigInteger

      public BigInteger getBigInteger(int offset, int byteLength, boolean unsigned)
      Deprecated.
      Converts byteLength bytes(little-endian) starting from position() + offset to big integer.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      byteLength - bytes to convert
      unsigned - true if it's unsigned big integer; false otherwise
      Returns:
      non-null big integer
    • getBoolean

      public boolean getBoolean(int offset)
      Deprecated.
      Converts the byte at position() + offset in array to boolean.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      boolean
    • getDouble

      public double getDouble(int offset)
      Deprecated.
      Converts 8 bytes(little-endian) starting from position() + offset to double.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      double
    • getFloat

      public float getFloat(int offset)
      Deprecated.
      Converts 4 bytes(little-endian) starting from position() + offset to float.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      float
    • getInteger

      public int getInteger(int offset)
      Deprecated.
      Converts 4 bytes(little-endian) starting from position() + offset to signed integer.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      signed integer
    • getLong

      public long getLong(int offset)
      Deprecated.
      Converts 8 bytes(little-endian) starting from position() + offset to signed long.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      signed long
    • getShort

      public short getShort(int offset)
      Deprecated.
      Converts 2 bytes(little-endian) starting from position() + offset to signed short.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      signed short
    • getUnsignedInteger

      public long getUnsignedInteger(int offset)
      Deprecated.
      Converts 4 bytes(little-endian) starting from position() + offset to unsigned integer.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      unsigned integer
    • getUnsignedLong

      public BigInteger getUnsignedLong(int offset)
      Deprecated.
      Converts 8 bytes(little-endian) starting from position() + offset to unsigned long.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      non-null unsigned long
    • getUnsignedShort

      public int getUnsignedShort(int offset)
      Deprecated.
      Converts 2 bytes(little-endian) starting from position() + offset to unsigned short.
      Parameters:
      offset - zero-based relative offset, 1 means the second byte starting from position()
      Returns:
      unsigned short
    • asBigIntegerArray

      public BigInteger[] asBigIntegerArray(int byteLength, boolean unsigned)
      Deprecated.
    • asInteger

      public int asInteger()
      Deprecated.
    • asLong

      public long asLong()
      Deprecated.
    • asShort

      public short asShort()
      Deprecated.
    • asIntegerArray

      public int[] asIntegerArray()
      Deprecated.
    • asLongArray

      public long[] asLongArray()
      Deprecated.
    • asShortArray

      public short[] asShortArray()
      Deprecated.
    • asUnsignedInteger

      public long asUnsignedInteger()
      Deprecated.
    • asUnsignedLong

      public BigInteger asUnsignedLong()
      Deprecated.
    • asUnsignedShort

      public int asUnsignedShort()
      Deprecated.
    • asUnsignedIntegerArray

      public long[] asUnsignedIntegerArray()
      Deprecated.
    • asUnsignedShortArray

      public int[] asUnsignedShortArray()
      Deprecated.
    • asUuid

      public UUID asUuid()
      Deprecated.
    • getUuid

      public UUID getUuid(int offset)
      Deprecated.
    • asAsciiString

      public String asAsciiString()
      Deprecated.
      Converts to ASCII string.
      Returns:
      non-null ASCII string
    • asString

      public String asString(Charset charset)
      Deprecated.
      Converts to string using given charset.
      Parameters:
      charset - optional charset, null is treated as StandardCharsets.UTF_8
      Returns:
      non-null string
    • asUnicodeString

      public String asUnicodeString()
      Deprecated.
      Converts to UTF-8 string.
      Returns:
      non-null UTF-8 string
    • compact

      public ClickHouseByteBuffer compact()
      Deprecated.
      Compacts byte array by creating a new copy with exact same length but position changed to zero. It does nothing when position is zero and length is same as bytes.length.
      Returns:
      this byte buffer
    • isCompact

      public boolean isCompact()
      Deprecated.
      Checks whether the buffer is compact or not. A buffer is compact when position points to zero and length equals to array().length.
      Returns:
      true if the buffer is compact; false otherwise
    • isEmpty

      public boolean isEmpty()
      Deprecated.
      Checks whether the buffer is empty or not. Please pay attention that this will return true when length() is zero, even array() may return an non-empty byte array.
      Returns:
      true if the buffer is empty; false otherwise
    • match

      public boolean match(byte[] bytes)
      Deprecated.
      Checks if the byte buffer is same as the given byte array.
      Parameters:
      bytes - bytes to check
      Returns:
      true if the byte buffer is same as the given byte array; false otherwise
    • reset

      public ClickHouseByteBuffer reset()
      Deprecated.
      Resets the buffer to empty.
      Returns:
      this byte buffer
    • reverse

      public ClickHouseByteBuffer reverse()
      Deprecated.
      Reverses the byte array.
      Returns:
      this byte buffer
    • reverse

      public ClickHouseByteBuffer reverse(int offset, int length)
      Deprecated.
      Reverses the byte array.
      Parameters:
      offset - start position
      length - bytes to reserve
      Returns:
      this byte buffer
    • slice

      public ClickHouseByteBuffer slice(int offset, int length)
      Deprecated.
      Gets slice of the byte buffer.
      Parameters:
      offset - offset zero-based relative offset, 1 means the second byte starting from position()
      length - length of the slice
      Returns:
      non-null slice of the byte buffer(backed by the same byte array but with different position and length)
    • update

      public ClickHouseByteBuffer update(ByteBuffer buffer)
      Deprecated.
      Updates buffer.
      Parameters:
      buffer - byte buffer
      Returns:
      this byte buffer
    • update

      public ClickHouseByteBuffer update(byte[] bytes)
      Deprecated.
      Updates buffer.
      Parameters:
      bytes - byte array, null is same as empty byte array
      Returns:
      this byte buffer
    • update

      public ClickHouseByteBuffer update(byte[] bytes, int offset, int length)
      Deprecated.
      Updates buffer.
      Parameters:
      bytes - byte array, null is same as empty byte array
      offset - start position
      length - length of bytes
      Returns:
      this byte buffer
    • update

      public ClickHouseByteBuffer update(List<byte[]> list, int offset, int length)
      Deprecated.
      Updates buffer.
      Parameters:
      list - list of byte arrays, null is same as empty byte array
      offset - start position
      length - length of bytes
      Returns:
      this byte buffer
    • array

      public byte[] array()
      Deprecated.
      Gets byte array.
      Returns:
      non-null byte array
    • copy

      public ClickHouseByteBuffer copy(boolean deep)
      Deprecated.
      Creates a copy of the current byte buffer.
      Parameters:
      deep - true to copy the underlying byte array; false to reuse
      Returns:
      non-null copy of the current byte buffer
    • firstByte

      public byte firstByte()
      Deprecated.
    • getByte

      public byte getByte(int offset)
      Deprecated.
    • lastByte

      public byte lastByte()
      Deprecated.
    • position

      public int position()
      Deprecated.
      Gets start position.
      Returns:
      start position
    • position

      public ClickHouseByteBuffer position(int newPosition)
      Deprecated.
      Sets new position.
      Parameters:
      newPosition - new position, which should be always less than limit()
      Returns:
      this byte buffer
    • length

      public int length()
      Deprecated.
      Gets length of bytes.
      Returns:
      length of bytes
    • limit

      public int limit()
      Deprecated.
      Gets end position.
      Returns:
      end position
    • setLength

      public ClickHouseByteBuffer setLength(int newLength)
      Deprecated.
      Sets new length.
      Parameters:
      newLength - new length, negative number is treated as zero
      Returns:
      this byte buffer
    • hashCode

      public int hashCode()
      Deprecated.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Deprecated.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object