Interface AccumuloRowSerializer
- All Known Implementing Classes:
LexicoderRowSerializer,StringRowSerializer
public interface AccumuloRowSerializer
Interface for deserializing the data in Accumulo into a Trino row.
Provides a means for end-users of the connector to customize how the data in an Accumulo row gets serialized and deserialized from/to a Trino row.
The workflow of how this class is called by the Accumulo connector for reading data is as follows:
- setRowIdName - Sets the Trino name which is the Accumulo row ID
- setRowOnly - True if only the row ID is going to be retrieved, false if more data is necessary.
- setMapping - Multiple calls for each Trino column, setting the mapping of Trino column name to Accumulo column family and qualifier
- deserialize - Called for each Accumulo entry in the same row. Implements should retrieve the Trino column value from the given key/value pair
- get* - Called to retrieve the data type for the given Trino column name
- reset - Begins a new Row, serializer is expected to clear any state
- If there are more entries left, go back to deserialize, else end!
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> TGeneric function to decode the given byte array to a Java object based on the given type.voiddeserialize(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[]Encodes a Trino Java object to a byte array based on the given type.Gets the array Block of the given Trino column.getArrayFromBlock(Type elementType, Block block) Given the array element type and Trino Block, decodes the Block into a list of values.static BlockgetBlockFromArray(Type elementType, List<?> array) Encodes the given list into a Block.static BlockgetBlockFromMap(Type type, Map<?, ?> map) Encodes the given map into a Block.booleangetBoolean(String name) Gets the Boolean value of the given Trino column.byteGets the Byte value of the given Trino column.longGets the Date value of the given Trino column.static AccumuloRowSerializerGets the default AccumuloRowSerializer,LexicoderRowSerializer.doubleGets the Double value of the given Trino column.floatGets the Float value of the given Trino column.intGets the Integer value of the given Trino column.longGets the Long value of the given Trino column.Gets the Map value of the given Trino column and Map type.getMapFromBlock(Type type, Block block) Given the map type and Trino Block, decodes the Block into a map of values.shortGets the Short value of the given Trino column.Gets the Time value of the given Trino column.getTimestamp(String name) Gets the Timestamp value of the given Trino column.byte[]getVarbinary(String name) Gets the Varbinary value of the given Trino column.getVarchar(String name) Gets the String value of the given Trino column.booleanGets a Boolean value indicating whether or not the Trino column is a null value.static ObjectreadObject(Type type, Block block, int position) Recursive helper function used bygetArrayFromBlock(io.trino.spi.type.Type, io.trino.spi.block.Block)andgetMapFromBlock(io.trino.spi.type.Type, io.trino.spi.block.Block)to decode the Block into a Java type.voidreset()Reset the state of the serializer to prepare for a new set of entries with the same row ID.voidEncode the given array Block into the given Text object.voidsetBoolean(org.apache.hadoop.io.Text text, Boolean value) Encode the given Boolean value into the given Text object.voidEncode the given Byte value into the given Text object.voidsetDate(org.apache.hadoop.io.Text text, long value) Encode the given Date value into the given Text object.voidEncode the given Double value into the given Text object.voidEncode the given Float value into the given Text object.voidEncode the given Integer value into the given Text object.voidEncode the given Long value into the given Text object.voidEncode the given map Block into the given Text object.voidsetMapping(String name, String family, String qualifier) Sets the mapping for the Trino column name to Accumulo family and qualifier.voidsetRowIdName(String name) Sets the Trino name which maps to the Accumulo row ID.voidsetRowOnly(boolean rowOnly) Sets a Boolean value indicating whether or not only the row ID is going to be retrieved from the serializer.voidEncode the given Short value into the given Text object.voidEncode the given Time value into the given Text object.voidsetTimestamp(org.apache.hadoop.io.Text text, Timestamp value) Encode the given Timestamp value into the given Text object.voidsetVarbinary(org.apache.hadoop.io.Text text, byte[] value) Encode the given byte[] value into the given Text object.voidsetVarchar(org.apache.hadoop.io.Text text, String value) Encode the given String value into the given Text object.static voidwriteObject(BlockBuilder builder, Type type, Object obj) Recursive helper function used bygetBlockFromArray(io.trino.spi.type.Type, java.util.List<?>)andgetBlockFromMap(io.trino.spi.type.Type, java.util.Map<?, ?>)to add the given object to the given block builder.
-
Method Details
-
getDefault
Gets the default AccumuloRowSerializer,LexicoderRowSerializer.- Returns:
- Default serializer
-
setRowIdName
Sets the Trino name which maps to the Accumulo row ID.- Parameters:
name- Trino column name
-
setMapping
Sets the mapping for the Trino column name to Accumulo family and qualifier.- Parameters:
name- Trino namefamily- Accumulo familyqualifier- Accumulo qualifier
-
setRowOnly
void setRowOnly(boolean rowOnly) Sets a Boolean value indicating whether or not only the row ID is going to be retrieved from the serializer.- Parameters:
rowOnly- True if only the row ID is set, false otherwise
-
reset
void reset()Reset the state of the serializer to prepare for a new set of entries with the same row ID. -
deserialize
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.- Parameters:
entry- Entry to deserialize
-
isNull
Gets a Boolean value indicating whether or not the Trino column is a null value.- Parameters:
name- Column name- Returns:
- True if null, false otherwise.
-
getArray
Gets the array Block of the given Trino column.- Parameters:
name- Column nametype- Array type- Returns:
- True if null, false otherwise.
-
setArray
Encode the given array Block into the given Text object.- Parameters:
text- Text object to settype- Array typeblock- Array block
-
getBoolean
Gets the Boolean value of the given Trino column.- Parameters:
name- Column name- Returns:
- Boolean value
-
setBoolean
Encode the given Boolean value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getByte
Gets the Byte value of the given Trino column.- Parameters:
name- Column name- Returns:
- Byte value
-
setByte
Encode the given Byte value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getDate
Gets the Date value of the given Trino column.- Parameters:
name- Column name- Returns:
- Date value
-
setDate
void setDate(org.apache.hadoop.io.Text text, long value) Encode the given Date value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getDouble
Gets the Double value of the given Trino column.- Parameters:
name- Column name- Returns:
- Double value
-
setDouble
Encode the given Double value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getFloat
Gets the Float value of the given Trino column.- Parameters:
name- Column name- Returns:
- Float value
-
setFloat
Encode the given Float value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getInt
Gets the Integer value of the given Trino column.- Parameters:
name- Column name- Returns:
- Integer value
-
setInt
Encode the given Integer value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getLong
Gets the Long value of the given Trino column.- Parameters:
name- Column name- Returns:
- Long value
-
setLong
Encode the given Long value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getMap
Gets the Map value of the given Trino column and Map type.- Parameters:
name- Column nametype- Map type- Returns:
- Map value
-
setMap
Encode the given map Block into the given Text object.- Parameters:
text- Text object to settype- Map typeblock- Map block
-
getShort
Gets the Short value of the given Trino column.- Parameters:
name- Column name- Returns:
- Short value
-
setShort
Encode the given Short value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getTime
Gets the Time value of the given Trino column.- Parameters:
name- Column name- Returns:
- Time value
-
setTime
Encode the given Time value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getTimestamp
Gets the Timestamp value of the given Trino column.- Parameters:
name- Column name- Returns:
- Timestamp value
-
setTimestamp
Encode the given Timestamp value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getVarbinary
Gets the Varbinary value of the given Trino column.- Parameters:
name- Column name- Returns:
- Varbinary value
-
setVarbinary
void setVarbinary(org.apache.hadoop.io.Text text, byte[] value) Encode the given byte[] value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
getVarchar
Gets the String value of the given Trino column.- Parameters:
name- Column name- Returns:
- String value
-
setVarchar
Encode the given String value into the given Text object.- Parameters:
text- Text object to setvalue- Value to encode
-
encode
Encodes a Trino Java object to a byte array based on the given type.Java Lists and Maps can be converted to Blocks using
getBlockFromArray(Type, java.util.List)andgetBlockFromMap(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 - Parameters:
type- The TrinoTypevalue- The Java object per the table in the method description- Returns:
- Encoded bytes
-
decode
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
getArrayFromBlock(Type, Block)andgetMapFromBlock(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 - Type Parameters:
T- The Java type of the object that has been encoded to the given byte array- Parameters:
type- The TrinoTypevalue- Encoded bytes to decode- Returns:
- The Java object per the table in the method description
-
getArrayFromBlock
Given the array element type and Trino Block, decodes the Block into a list of values.- Parameters:
elementType- Array element typeblock- Array block- Returns:
- List of values
-
getMapFromBlock
Given the map type and Trino Block, decodes the Block into a map of values.- Parameters:
type- Map typeblock- Map block- Returns:
- List of values
-
getBlockFromArray
Encodes the given list into a Block.- Parameters:
elementType- Element type of the arrayarray- Array of elements to encode- Returns:
- Trino Block
-
getBlockFromMap
Encodes the given map into a Block.- Parameters:
type- Trino type of the mapmap- Map of key/value pairs to encode- Returns:
- Trino Block
-
writeObject
Recursive helper function used bygetBlockFromArray(io.trino.spi.type.Type, java.util.List<?>)andgetBlockFromMap(io.trino.spi.type.Type, java.util.Map<?, ?>)to add the given object to the given block builder. Supports nested complex types!- Parameters:
builder- Block buildertype- Trino typeobj- Object to write to the block builder
-
readObject
Recursive helper function used bygetArrayFromBlock(io.trino.spi.type.Type, io.trino.spi.block.Block)andgetMapFromBlock(io.trino.spi.type.Type, io.trino.spi.block.Block)to decode the Block into a Java type.- Parameters:
type- Trino typeblock- Block to decodeposition- Position in the block to get- Returns:
- Java object from the Block
-