Class LongDataType

java.lang.Object
org.h2.mvstore.type.BasicDataType<Long>
org.h2.mvstore.type.LongDataType
All Implemented Interfaces:
Comparator<Long>, DataType<Long>

public class LongDataType extends BasicDataType<Long>
Class LongDataType.
  • 8/21/17 6:52 PM initial creation
  • Field Details

    • INSTANCE

      public static final LongDataType INSTANCE
    • EMPTY_LONG_ARR

      private static final Long[] EMPTY_LONG_ARR
  • Constructor Details

    • LongDataType

      private LongDataType()
  • Method Details

    • getMemory

      public int getMemory(Long obj)
      Description copied from interface: DataType
      Calculates the amount of used memory in bytes.
      Specified by:
      getMemory in interface DataType<Long>
      Specified by:
      getMemory in class BasicDataType<Long>
      Parameters:
      obj - the object
      Returns:
      the used memory
    • write

      public void write(WriteBuffer buff, Long data)
      Description copied from interface: DataType
      Write an object.
      Specified by:
      write in interface DataType<Long>
      Specified by:
      write in class BasicDataType<Long>
      Parameters:
      buff - the target buffer
      data - the value
    • read

      public Long read(ByteBuffer buff)
      Description copied from interface: DataType
      Read an object.
      Specified by:
      read in interface DataType<Long>
      Specified by:
      read in class BasicDataType<Long>
      Parameters:
      buff - the source buffer
      Returns:
      the object
    • createStorage

      public Long[] createStorage(int size)
      Description copied from interface: DataType
      Create storage object of array type to hold values
      Parameters:
      size - number of values to hold
      Returns:
      storage object
    • compare

      public int compare(Long one, Long two)
      Description copied from interface: DataType
      Compare two keys.
      Specified by:
      compare in interface Comparator<Long>
      Specified by:
      compare in interface DataType<Long>
      Overrides:
      compare in class BasicDataType<Long>
      Parameters:
      one - the first key
      two - the second key
      Returns:
      -1 if the first key is smaller, 1 if larger, and 0 if equal
    • binarySearch

      public int binarySearch(Long keyObj, Object storageObj, int size, int initialGuess)
      Description copied from interface: DataType
      Perform binary search for the key within the storage
      Specified by:
      binarySearch in interface DataType<Long>
      Overrides:
      binarySearch in class BasicDataType<Long>
      Parameters:
      keyObj - to search for
      storageObj - to search within (an array of type T)
      size - number of data items in the storage
      initialGuess - for key position
      Returns:
      index of the key , if found, - index of the insertion point, if not
    • binarySearch

      private static int binarySearch(long key, Long[] storage, int low, int high, int x)