Class StringRowSerializer
- java.lang.Object
-
- io.trino.plugin.accumulo.serializers.StringRowSerializer
-
- All Implemented Interfaces:
AccumuloRowSerializer
public class StringRowSerializer extends Object implements AccumuloRowSerializer
Implementation ofStringRowSerializerthat encodes and decodes Trino column values as human-readable String objects.
-
-
Constructor Summary
Constructors Constructor Description StringRowSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdecode(Type type, byte[] value)Generic 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[]encode(Type type, Object value)Encodes a Trino Java object to a byte array based on the given type.BlockgetArray(String name, Type type)Gets the array Block of the given Trino column.booleangetBoolean(String name)Gets the Boolean value of the given Trino column.bytegetByte(String name)Gets the Byte value of the given Trino column.DategetDate(String name)Gets the Date value of the given Trino column.doublegetDouble(String name)Gets the Double value of the given Trino column.floatgetFloat(String name)Gets the Float value of the given Trino column.intgetInt(String name)Gets the Integer value of the given Trino column.longgetLong(String name)Gets the Long value of the given Trino column.BlockgetMap(String name, Type type)Gets the Map value of the given Trino column and Map type.shortgetShort(String name)Gets the Short value of the given Trino column.TimegetTime(String name)Gets the Time value of the given Trino column.TimestampgetTimestamp(String name)Gets the Timestamp value of the given Trino column.byte[]getVarbinary(String name)Gets the Varbinary value of the given Trino column.StringgetVarchar(String name)Gets the String value of the given Trino column.booleanisNull(String name)Gets a Boolean value indicating whether or not the Trino column is a null value.voidreset()Reset the state of the serializer to prepare for a new set of entries with the same row ID.voidsetArray(org.apache.hadoop.io.Text text, Type type, Block block)Encode 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.voidsetByte(org.apache.hadoop.io.Text text, Byte value)Encode the given Byte value into the given Text object.voidsetDate(org.apache.hadoop.io.Text text, Date value)Encode the given Date value into the given Text object.voidsetDouble(org.apache.hadoop.io.Text text, Double value)Encode the given Double value into the given Text object.voidsetFloat(org.apache.hadoop.io.Text text, Float value)Encode the given Float value into the given Text object.voidsetInt(org.apache.hadoop.io.Text text, Integer value)Encode the given Integer value into the given Text object.voidsetLong(org.apache.hadoop.io.Text text, Long value)Encode the given Long value into the given Text object.voidsetMap(org.apache.hadoop.io.Text text, Type type, Block block)Encode 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.voidsetShort(org.apache.hadoop.io.Text text, Short value)Encode the given Short value into the given Text object.voidsetTime(org.apache.hadoop.io.Text text, Time value)Encode 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.
-
-
-
Method Detail
-
setRowIdName
public void setRowIdName(String name)
Description copied from interface:AccumuloRowSerializerSets the Trino name which maps to the Accumulo row ID.- Specified by:
setRowIdNamein interfaceAccumuloRowSerializer- Parameters:
name- Trino column name
-
setRowOnly
public void setRowOnly(boolean rowOnly)
Description copied from interface:AccumuloRowSerializerSets a Boolean value indicating whether or not only the row ID is going to be retrieved from the serializer.- Specified by:
setRowOnlyin interfaceAccumuloRowSerializer- 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:AccumuloRowSerializerSets the mapping for the Trino column name to Accumulo family and qualifier.- Specified by:
setMappingin interfaceAccumuloRowSerializer- Parameters:
name- Trino namefamily- Accumulo familyqualifier- Accumulo qualifier
-
reset
public void reset()
Description copied from interface:AccumuloRowSerializerReset the state of the serializer to prepare for a new set of entries with the same row ID.- Specified by:
resetin interfaceAccumuloRowSerializer
-
deserialize
public void deserialize(Map.Entry<org.apache.accumulo.core.data.Key,org.apache.accumulo.core.data.Value> entry)
Description copied from interface:AccumuloRowSerializerDeserialize the given Accumulo entry, retrieving data for the Trino column.- Specified by:
deserializein interfaceAccumuloRowSerializer- Parameters:
entry- Entry to deserialize
-
isNull
public boolean isNull(String name)
Description copied from interface:AccumuloRowSerializerGets a Boolean value indicating whether or not the Trino column is a null value.- Specified by:
isNullin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- True if null, false otherwise.
-
getArray
public Block getArray(String name, Type type)
Description copied from interface:AccumuloRowSerializerGets the array Block of the given Trino column.- Specified by:
getArrayin interfaceAccumuloRowSerializer- Parameters:
name- Column nametype- 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:AccumuloRowSerializerEncode the given array Block into the given Text object.- Specified by:
setArrayin interfaceAccumuloRowSerializer- Parameters:
text- Text object to settype- Array typeblock- Array block
-
getBoolean
public boolean getBoolean(String name)
Description copied from interface:AccumuloRowSerializerGets the Boolean value of the given Trino column.- Specified by:
getBooleanin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Boolean value
-
setBoolean
public void setBoolean(org.apache.hadoop.io.Text text, Boolean value)Description copied from interface:AccumuloRowSerializerEncode the given Boolean value into the given Text object.- Specified by:
setBooleanin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getByte
public byte getByte(String name)
Description copied from interface:AccumuloRowSerializerGets the Byte value of the given Trino column.- Specified by:
getBytein interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Byte value
-
setByte
public void setByte(org.apache.hadoop.io.Text text, Byte value)Description copied from interface:AccumuloRowSerializerEncode the given Byte value into the given Text object.- Specified by:
setBytein interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getDate
public Date getDate(String name)
Description copied from interface:AccumuloRowSerializerGets the Date value of the given Trino column.- Specified by:
getDatein interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Date value
-
setDate
public void setDate(org.apache.hadoop.io.Text text, Date value)Description copied from interface:AccumuloRowSerializerEncode the given Date value into the given Text object.- Specified by:
setDatein interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getDouble
public double getDouble(String name)
Description copied from interface:AccumuloRowSerializerGets the Double value of the given Trino column.- Specified by:
getDoublein interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Double value
-
setDouble
public void setDouble(org.apache.hadoop.io.Text text, Double value)Description copied from interface:AccumuloRowSerializerEncode the given Double value into the given Text object.- Specified by:
setDoublein interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getFloat
public float getFloat(String name)
Description copied from interface:AccumuloRowSerializerGets the Float value of the given Trino column.- Specified by:
getFloatin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Float value
-
setFloat
public void setFloat(org.apache.hadoop.io.Text text, Float value)Description copied from interface:AccumuloRowSerializerEncode the given Float value into the given Text object.- Specified by:
setFloatin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getInt
public int getInt(String name)
Description copied from interface:AccumuloRowSerializerGets the Integer value of the given Trino column.- Specified by:
getIntin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Integer value
-
setInt
public void setInt(org.apache.hadoop.io.Text text, Integer value)Description copied from interface:AccumuloRowSerializerEncode the given Integer value into the given Text object.- Specified by:
setIntin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getLong
public long getLong(String name)
Description copied from interface:AccumuloRowSerializerGets the Long value of the given Trino column.- Specified by:
getLongin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Long value
-
setLong
public void setLong(org.apache.hadoop.io.Text text, Long value)Description copied from interface:AccumuloRowSerializerEncode the given Long value into the given Text object.- Specified by:
setLongin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getMap
public Block getMap(String name, Type type)
Description copied from interface:AccumuloRowSerializerGets the Map value of the given Trino column and Map type.- Specified by:
getMapin interfaceAccumuloRowSerializer- Parameters:
name- Column nametype- Map type- Returns:
- Map value
-
setMap
public void setMap(org.apache.hadoop.io.Text text, Type type, Block block)Description copied from interface:AccumuloRowSerializerEncode the given map Block into the given Text object.- Specified by:
setMapin interfaceAccumuloRowSerializer- Parameters:
text- Text object to settype- Map typeblock- Map block
-
getShort
public short getShort(String name)
Description copied from interface:AccumuloRowSerializerGets the Short value of the given Trino column.- Specified by:
getShortin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Short value
-
setShort
public void setShort(org.apache.hadoop.io.Text text, Short value)Description copied from interface:AccumuloRowSerializerEncode the given Short value into the given Text object.- Specified by:
setShortin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getTime
public Time getTime(String name)
Description copied from interface:AccumuloRowSerializerGets the Time value of the given Trino column.- Specified by:
getTimein interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Time value
-
setTime
public void setTime(org.apache.hadoop.io.Text text, Time value)Description copied from interface:AccumuloRowSerializerEncode the given Time value into the given Text object.- Specified by:
setTimein interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getTimestamp
public Timestamp getTimestamp(String name)
Description copied from interface:AccumuloRowSerializerGets the Timestamp value of the given Trino column.- Specified by:
getTimestampin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Timestamp value
-
setTimestamp
public void setTimestamp(org.apache.hadoop.io.Text text, Timestamp value)Description copied from interface:AccumuloRowSerializerEncode the given Timestamp value into the given Text object.- Specified by:
setTimestampin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getVarbinary
public byte[] getVarbinary(String name)
Description copied from interface:AccumuloRowSerializerGets the Varbinary value of the given Trino column.- Specified by:
getVarbinaryin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- Varbinary value
-
setVarbinary
public void setVarbinary(org.apache.hadoop.io.Text text, byte[] value)Description copied from interface:AccumuloRowSerializerEncode the given byte[] value into the given Text object.- Specified by:
setVarbinaryin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
getVarchar
public String getVarchar(String name)
Description copied from interface:AccumuloRowSerializerGets the String value of the given Trino column.- Specified by:
getVarcharin interfaceAccumuloRowSerializer- Parameters:
name- Column name- Returns:
- String value
-
setVarchar
public void setVarchar(org.apache.hadoop.io.Text text, String value)Description copied from interface:AccumuloRowSerializerEncode the given String value into the given Text object.- Specified by:
setVarcharin interfaceAccumuloRowSerializer- Parameters:
text- Text object to setvalue- Value to encode
-
encode
public byte[] encode(Type type, Object value)
Description copied from interface:AccumuloRowSerializerEncodes 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)andAccumuloRowSerializer.getBlockFromMap(Type, Map)Type to Encode Expected Java Object ARRAY io.trino.spi.block.Block BIGINT Integer or Long BOOLEAN Boolean DATE java.sql.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:
encodein interfaceAccumuloRowSerializer- Parameters:
type- The TrinoTypevalue- 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:AccumuloRowSerializerGeneric 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)andAccumuloRowSerializer.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:
decodein interfaceAccumuloRowSerializer- 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
-
-