Class LexicoderRowSerializer

java.lang.Object
io.trino.plugin.accumulo.serializers.LexicoderRowSerializer
All Implemented Interfaces:
AccumuloRowSerializer

public class LexicoderRowSerializer extends Object implements AccumuloRowSerializer
Implementation of AccumuloRowSerializer that uses Accumulo lexicoders to serialize the values of the Trino columns.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    decode(Type type, byte[] value)
    Generic function to decode the given byte array to a Java object based on the given type.
    void
    deserialize(Map.Entry<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Value> entry)
    Deserialize the given Accumulo entry, retrieving data for the Trino column.
    byte[]
    encode(Type type, Object value)
    Encodes a Trino Java object to a byte array based on the given type.
    getArray(String name, Type type)
    Gets the array Block of the given Trino column.
    boolean
    Gets the Boolean value of the given Trino column.
    byte
    Gets the Byte value of the given Trino column.
    long
    Gets the Date value of the given Trino column.
    double
    Gets the Double value of the given Trino column.
    float
    Gets the Float value of the given Trino column.
    int
    getInt(String name)
    Gets the Integer value of the given Trino column.
    static org.apache.accumulo.core.client.lexicoder.Lexicoder
     
    long
    Gets the Long value of the given Trino column.
    getMap(String name, Type type)
    Gets the Map value of the given Trino column and Map type.
    short
    Gets the Short value of the given Trino column.
    Gets the Time value of the given Trino column.
    Gets the Timestamp value of the given Trino column.
    byte[]
    Gets the Varbinary value of the given Trino column.
    Gets the String value of the given Trino column.
    boolean
    isNull(String name)
    Gets a Boolean value indicating whether or not the Trino column is a null value.
    void
    Reset the state of the serializer to prepare for a new set of entries with the same row ID.
    void
    setArray(org.apache.hadoop.io.Text text, Type type, Block block)
    Encode the given array Block into the given Text object.
    void
    setBoolean(org.apache.hadoop.io.Text text, Boolean value)
    Encode the given Boolean value into the given Text object.
    void
    setByte(org.apache.hadoop.io.Text text, Byte value)
    Encode the given Byte value into the given Text object.
    void
    setDate(org.apache.hadoop.io.Text text, long value)
    Encode the given Date value into the given Text object.
    void
    setDouble(org.apache.hadoop.io.Text text, Double value)
    Encode the given Double value into the given Text object.
    void
    setFloat(org.apache.hadoop.io.Text text, Float value)
    Encode the given Float value into the given Text object.
    void
    setInt(org.apache.hadoop.io.Text text, Integer value)
    Encode the given Integer value into the given Text object.
    void
    setLong(org.apache.hadoop.io.Text text, Long value)
    Encode the given Long value into the given Text object.
    void
    setMap(org.apache.hadoop.io.Text text, Type type, Block block)
    Encode the given map Block into the given Text object.
    void
    setMapping(String name, String family, String qualifier)
    Sets the mapping for the Trino column name to Accumulo family and qualifier.
    void
    Sets the Trino name which maps to the Accumulo row ID.
    void
    setRowOnly(boolean rowOnly)
    Sets a Boolean value indicating whether or not only the row ID is going to be retrieved from the serializer.
    void
    setShort(org.apache.hadoop.io.Text text, Short value)
    Encode the given Short value into the given Text object.
    void
    setTime(org.apache.hadoop.io.Text text, Time value)
    Encode the given Time value into the given Text object.
    void
    setTimestamp(org.apache.hadoop.io.Text text, Timestamp value)
    Encode the given Timestamp value into the given Text object.
    void
    setVarbinary(org.apache.hadoop.io.Text text, byte[] value)
    Encode the given byte[] value into the given Text object.
    void
    setVarchar(org.apache.hadoop.io.Text text, String value)
    Encode the given String value into the given Text object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LexicoderRowSerializer

      public LexicoderRowSerializer()
  • Method Details

    • setRowIdName

      public void setRowIdName(String name)
      Description copied from interface: AccumuloRowSerializer
      Sets the Trino name which maps to the Accumulo row ID.
      Specified by:
      setRowIdName in interface AccumuloRowSerializer
      Parameters:
      name - Trino column name
    • setRowOnly

      public void setRowOnly(boolean rowOnly)
      Description copied from interface: AccumuloRowSerializer
      Sets a Boolean value indicating whether or not only the row ID is going to be retrieved from the serializer.
      Specified by:
      setRowOnly in interface AccumuloRowSerializer
      Parameters:
      rowOnly - True if only the row ID is set, false otherwise
    • setMapping

      public void setMapping(String name, String family, String qualifier)
      Description copied from interface: AccumuloRowSerializer
      Sets the mapping for the Trino column name to Accumulo family and qualifier.
      Specified by:
      setMapping in interface AccumuloRowSerializer
      Parameters:
      name - Trino name
      family - Accumulo family
      qualifier - Accumulo qualifier
    • reset

      public void reset()
      Description copied from interface: AccumuloRowSerializer
      Reset the state of the serializer to prepare for a new set of entries with the same row ID.
      Specified by:
      reset in interface AccumuloRowSerializer
    • deserialize

      public void deserialize(Map.Entry<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Value> entry)
      Description copied from interface: AccumuloRowSerializer
      Deserialize the given Accumulo entry, retrieving data for the Trino column.
      Specified by:
      deserialize in interface AccumuloRowSerializer
      Parameters:
      entry - Entry to deserialize
    • isNull

      public boolean isNull(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets a Boolean value indicating whether or not the Trino column is a null value.
      Specified by:
      isNull in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      True if null, false otherwise.
    • getArray

      public Block getArray(String name, Type type)
      Description copied from interface: AccumuloRowSerializer
      Gets the array Block of the given Trino column.
      Specified by:
      getArray in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      type - Array type
      Returns:
      True if null, false otherwise.
    • setArray

      public void setArray(org.apache.hadoop.io.Text text, Type type, Block block)
      Description copied from interface: AccumuloRowSerializer
      Encode the given array Block into the given Text object.
      Specified by:
      setArray in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      type - Array type
      block - Array block
    • getBoolean

      public boolean getBoolean(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Boolean value of the given Trino column.
      Specified by:
      getBoolean in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Boolean value
    • setBoolean

      public void setBoolean(org.apache.hadoop.io.Text text, Boolean value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Boolean value into the given Text object.
      Specified by:
      setBoolean in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getByte

      public byte getByte(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Byte value of the given Trino column.
      Specified by:
      getByte in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Byte value
    • setByte

      public void setByte(org.apache.hadoop.io.Text text, Byte value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Byte value into the given Text object.
      Specified by:
      setByte in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getDate

      public long getDate(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Date value of the given Trino column.
      Specified by:
      getDate in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Date value
    • setDate

      public void setDate(org.apache.hadoop.io.Text text, long value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Date value into the given Text object.
      Specified by:
      setDate in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getDouble

      public double getDouble(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Double value of the given Trino column.
      Specified by:
      getDouble in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Double value
    • setDouble

      public void setDouble(org.apache.hadoop.io.Text text, Double value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Double value into the given Text object.
      Specified by:
      setDouble in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getFloat

      public float getFloat(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Float value of the given Trino column.
      Specified by:
      getFloat in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Float value
    • setFloat

      public void setFloat(org.apache.hadoop.io.Text text, Float value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Float value into the given Text object.
      Specified by:
      setFloat in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getInt

      public int getInt(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Integer value of the given Trino column.
      Specified by:
      getInt in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Integer value
    • setInt

      public void setInt(org.apache.hadoop.io.Text text, Integer value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Integer value into the given Text object.
      Specified by:
      setInt in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getLong

      public long getLong(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Long value of the given Trino column.
      Specified by:
      getLong in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Long value
    • setLong

      public void setLong(org.apache.hadoop.io.Text text, Long value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Long value into the given Text object.
      Specified by:
      setLong in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getMap

      public Block getMap(String name, Type type)
      Description copied from interface: AccumuloRowSerializer
      Gets the Map value of the given Trino column and Map type.
      Specified by:
      getMap in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      type - Map type
      Returns:
      Map value
    • setMap

      public void setMap(org.apache.hadoop.io.Text text, Type type, Block block)
      Description copied from interface: AccumuloRowSerializer
      Encode the given map Block into the given Text object.
      Specified by:
      setMap in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      type - Map type
      block - Map block
    • getShort

      public short getShort(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Short value of the given Trino column.
      Specified by:
      getShort in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Short value
    • setShort

      public void setShort(org.apache.hadoop.io.Text text, Short value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Short value into the given Text object.
      Specified by:
      setShort in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getTime

      public Time getTime(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Time value of the given Trino column.
      Specified by:
      getTime in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Time value
    • setTime

      public void setTime(org.apache.hadoop.io.Text text, Time value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Time value into the given Text object.
      Specified by:
      setTime in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getTimestamp

      public Timestamp getTimestamp(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Timestamp value of the given Trino column.
      Specified by:
      getTimestamp in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Timestamp value
    • setTimestamp

      public void setTimestamp(org.apache.hadoop.io.Text text, Timestamp value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given Timestamp value into the given Text object.
      Specified by:
      setTimestamp in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getVarbinary

      public byte[] getVarbinary(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the Varbinary value of the given Trino column.
      Specified by:
      getVarbinary in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      Varbinary value
    • setVarbinary

      public void setVarbinary(org.apache.hadoop.io.Text text, byte[] value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given byte[] value into the given Text object.
      Specified by:
      setVarbinary in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • getVarchar

      public String getVarchar(String name)
      Description copied from interface: AccumuloRowSerializer
      Gets the String value of the given Trino column.
      Specified by:
      getVarchar in interface AccumuloRowSerializer
      Parameters:
      name - Column name
      Returns:
      String value
    • setVarchar

      public void setVarchar(org.apache.hadoop.io.Text text, String value)
      Description copied from interface: AccumuloRowSerializer
      Encode the given String value into the given Text object.
      Specified by:
      setVarchar in interface AccumuloRowSerializer
      Parameters:
      text - Text object to set
      value - Value to encode
    • encode

      public byte[] encode(Type type, Object value)
      Description copied from interface: AccumuloRowSerializer
      Encodes a Trino Java object to a byte array based on the given type.

      Java Lists and Maps can be converted to Blocks using AccumuloRowSerializer.getBlockFromArray(Type, java.util.List) and AccumuloRowSerializer.getBlockFromMap(Type, Map)

      Type to Encode Expected Java Object
      ARRAY io.trino.spi.block.Block
      BIGINT Integer or Long
      BOOLEAN Boolean
      DATE long
      DOUBLE Double
      INTEGER Integer
      Map io.trino.spi.block.Block
      REAL Float
      SMALLINT Short
      TIME java.sql.Time, Long
      TIMESTAMP java.sql.Timestamp, Long
      TINYINT Byte
      VARBINARY io.airlift.slice.Slice or byte[]
      VARCHAR io.airlift.slice.Slice or String
      Specified by:
      encode in interface AccumuloRowSerializer
      Parameters:
      type - The Trino Type
      value - The Java object per the table in the method description
      Returns:
      Encoded bytes
    • decode

      public <T> T decode(Type type, byte[] value)
      Description copied from interface: AccumuloRowSerializer
      Generic function to decode the given byte array to a Java object based on the given type.

      Blocks from ARRAY and MAP types can be converted to Java Lists and Maps using AccumuloRowSerializer.getArrayFromBlock(Type, Block) and AccumuloRowSerializer.getMapFromBlock(Type, Block)

      Encoded Type Returned Java Object
      ARRAY List<?>
      BIGINT Long
      BOOLEAN Boolean
      DATE Long
      DOUBLE Double
      Map Map<?,?>
      REAL Double
      SMALLINT Long
      TIME Long
      TIMESTAMP Long
      TINYINT Long
      VARBINARY byte[]
      VARCHAR String
      Specified by:
      decode in interface AccumuloRowSerializer
      Type Parameters:
      T - The Java type of the object that has been encoded to the given byte array
      Parameters:
      type - The Trino Type
      value - Encoded bytes to decode
      Returns:
      The Java object per the table in the method description
    • getLexicoder

      public static org.apache.accumulo.core.client.lexicoder.Lexicoder getLexicoder(Type type)