Class StringDataType

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

public class StringDataType extends BasicDataType<String>
A string type.
  • Field Details

    • INSTANCE

      public static final StringDataType INSTANCE
    • EMPTY_STRING_ARR

      private static final String[] EMPTY_STRING_ARR
  • Constructor Details

    • StringDataType

      public StringDataType()
  • Method Details

    • createStorage

      public String[] 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(String a, String b)
      Description copied from interface: DataType
      Compare two keys.
      Specified by:
      compare in interface Comparator<String>
      Specified by:
      compare in interface DataType<String>
      Overrides:
      compare in class BasicDataType<String>
      Parameters:
      a - the first key
      b - the second key
      Returns:
      -1 if the first key is smaller, 1 if larger, and 0 if equal
    • binarySearch

      public int binarySearch(String key, 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<String>
      Overrides:
      binarySearch in class BasicDataType<String>
      Parameters:
      key - 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
    • getMemory

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

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

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