Package com.gpudb
Class RecordBase
- java.lang.Object
-
- com.gpudb.RecordBase
-
- All Implemented Interfaces:
Record,org.apache.avro.generic.GenericContainer,org.apache.avro.generic.IndexedRecord
- Direct Known Subclasses:
GenericRecord,RecordObject
public abstract class RecordBase extends Object implements Record
Abstract class that provides default implementations of most methods ofRecord. Derived classes must at a minimum implement theRecord.getType(),Record.get(int), andRecord.put(int, Object)methods.
-
-
Constructor Summary
Constructors Constructor Description RecordBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Objectget(String name)Returns the value of the specified field.ObjectgetArray(int index)For string columns with array property, return a native Java array of the appropriate type: Boolean[], Integer[], Long[], Float[], Double[], BigInteger[], or String[].ObjectgetArray(String name)For string columns with array property, return a native Java array of the appropriate type: Boolean[], Integer[], Long[], Float[], Double[], BigInteger[], or String[].ByteBuffergetBytes(int index)Returns the value of the specified field cast to aByteBuffer.ByteBuffergetBytes(String name)Returns the value of the specified field cast to aByteBuffer.Map<String,Object>getDataMap()Returns aMapof field names to values that is bound to the record (updates made to the map are reflected in the record and vice versa).DoublegetDouble(int index)Returns the value of the specified field cast to aDouble.DoublegetDouble(String name)Returns the value of the specified field cast to aDouble.FloatgetFloat(int index)Returns the value of the specified field cast to aFloat.FloatgetFloat(String name)Returns the value of the specified field cast to aFloat.IntegergetInt(int index)Returns the value of the specified field cast to aInteger.IntegergetInt(String name)Returns the value of the specified field cast to aInteger.Map<String,Object>getJson(int index)For string columns with JSON property, return a Java Map representing the JSON object.Map<String,Object>getJson(String name)For string columns with JSON property, return a Java Map representing the JSON object.LonggetLong(int index)Returns the value of the specified field cast to aLong.LonggetLong(String name)Returns the value of the specified field cast to aLong.org.apache.avro.SchemagetSchema()Returns the Avro record schema of the record.StringgetString(int index)Returns the value of the specified field cast to aString.StringgetString(String name)Returns the value of the specified field cast to aString.float[]getVector(int index)For byte columns with a vector property, return a native Java array of float.float[]getVector(String name)For byte columns with a vector property, return a native Java array of float.inthashCode()voidput(String name, Object value)Sets the value of the specified field.voidputArray(int index, Object value)For string columns with array property, parse the value parameter which may be a String, List<?>, int[], Integer[], long[], Long[], float[], Float[], double[], Double[].voidputArray(String name, Object value)For string columns with array property, parse the value parameter which may be a String, List<?>, int[], Integer[], long[], Long[], float[], Float[], double[], Double[].voidputBytes(int index, Object value)For Byte columns, parse the value parameter which may be a ByteBuffer or byte[].voidputBytes(String name, Object value)For Byte columns, parse the value parameter which may be a ByteBuffer or byte[].voidputDateTime(int index, Object value)For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the system timezone.voidputDateTime(int index, Object value, TimeZone timezone)For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the given timezone (system timezone if none given).voidputDateTime(String name, Object value)For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the system timezone.voidputDateTime(String name, Object value, TimeZone timezone)For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the given timezone (system timezone if none given).voidputDecimal(String name, Object value)voidputJson(int index, Object value)For String columns with json property, parse the value parameter which may be a String, or Map<String, String>.voidputJson(String name, Object value)For String columns with json property, parse the value parameter which may be a String, or Map<String, String>.voidputVector(int index, Object value)For bytes columns with vector property, parse the value parameter which may be a string, float[], Float[] or List<Float>.voidputVector(String name, Object value)For bytes columns with vector property, parse the value property which may be a string, float[], Float[] or List<Float>.StringtoString()
-
-
-
Method Detail
-
getSchema
public org.apache.avro.Schema getSchema()
Description copied from interface:RecordReturns the Avro record schema of the record.
-
get
public Object get(String name)
Description copied from interface:RecordReturns the value of the specified field.
-
getArray
public Object getArray(String name) throws Exception
For string columns with array property, return a native Java array of the appropriate type: Boolean[], Integer[], Long[], Float[], Double[], BigInteger[], or String[]. For binary columns with vector property, return float[].- Parameters:
name- The name of the column.- Returns:
- a native Java array of the appropriate type for the given column name
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
getArray
public Object getArray(int index) throws Exception
For string columns with array property, return a native Java array of the appropriate type: Boolean[], Integer[], Long[], Float[], Double[], BigInteger[], or String[]. For binary columns with vector property, return float[].- Parameters:
index- The index of the column.- Returns:
- a native Java array of the appropriate type for the given column index
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
getBytes
public ByteBuffer getBytes(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aByteBuffer. If the field is not of the correct type an exception will be thrown.
-
getBytes
public ByteBuffer getBytes(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aByteBuffer. If the field is not of the correct type an exception will be thrown.
-
getDouble
public Double getDouble(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aDouble. If the field is not of the correct type an exception will be thrown.
-
getDouble
public Double getDouble(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aDouble. If the field is not of the correct type an exception will be thrown.
-
getFloat
public Float getFloat(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aFloat. If the field is not of the correct type an exception will be thrown.
-
getFloat
public Float getFloat(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aFloat. If the field is not of the correct type an exception will be thrown.
-
getInt
public Integer getInt(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aInteger. If the field is not of the correct type an exception will be thrown.
-
getInt
public Integer getInt(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aInteger. If the field is not of the correct type an exception will be thrown.
-
getJson
public Map<String,Object> getJson(String name) throws Exception
For string columns with JSON property, return a Java Map representing the JSON object.- Parameters:
name- The name of the column.- Returns:
- a native Java map of the appropriate type for the given column name
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
getJson
public Map<String,Object> getJson(int index) throws Exception
For string columns with JSON property, return a Java Map representing the JSON object.- Parameters:
index- The index of the column.- Returns:
- a native Java map of the appropriate type for the given column index
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
getLong
public Long getLong(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aLong. If the field is not of the correct type an exception will be thrown.
-
getLong
public Long getLong(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aLong. If the field is not of the correct type an exception will be thrown.
-
getString
public String getString(int index)
Description copied from interface:RecordReturns the value of the specified field cast to aString. If the field is not of the correct type an exception will be thrown.
-
getString
public String getString(String name)
Description copied from interface:RecordReturns the value of the specified field cast to aString. If the field is not of the correct type an exception will be thrown.
-
getVector
public float[] getVector(String name) throws Exception
For byte columns with a vector property, return a native Java array of float.- Parameters:
name- The name of the column.- Returns:
- an array of floats for the given vector column name
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
getVector
public float[] getVector(int index) throws ExceptionFor byte columns with a vector property, return a native Java array of float.- Parameters:
index- The index of the column.- Returns:
- an array of floats for the given vector column index
- Throws:
GPUdbException- If an error occurs during the operation.com.fasterxml.jackson.core.JsonProcessingExceptioncom.fasterxml.jackson.databind.JsonMappingExceptionException
-
put
public void put(String name, Object value)
Description copied from interface:RecordSets the value of the specified field.
-
putArray
public void putArray(String name, Object value) throws GPUdbException
For string columns with array property, parse the value parameter which may be a String, List<?>, int[], Integer[], long[], Long[], float[], Float[], double[], Double[]. If the value is not of a relevant type, throw an error.- Parameters:
name- The name of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putArray
public void putArray(int index, Object value) throws GPUdbExceptionFor string columns with array property, parse the value parameter which may be a String, List<?>, int[], Integer[], long[], Long[], float[], Float[], double[], Double[]. If the value is not of a relevant type, throw an error.- Parameters:
index- The index of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putBytes
public void putBytes(String name, Object value) throws GPUdbException
For Byte columns, parse the value parameter which may be a ByteBuffer or byte[]. If the value is not of a relevant type, throw an error.- Parameters:
name- The name of the column.value- The value to be set.- Throws:
GPUdbException- if an error occurs during the operation.
-
putBytes
public void putBytes(int index, Object value) throws GPUdbExceptionFor Byte columns, parse the value parameter which may be a ByteBuffer or byte[]. If the value is not of a relevant type, throw an error.- Parameters:
index- The index of the column.value- The value to be set.- Throws:
GPUdbException- if an error occurs during the operation.
-
putDateTime
public void putDateTime(String name, Object value) throws GPUdbException
For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the system timezone. If the column is not of a relevant type, set the value without any parsing (so that any string or other typed values can be set using this method without resorting to first check the column's type before calling it). Caveat is that due to string manipulation, this is considerably slower thanput(java.lang.String, java.lang.Object). So, use this method only if you know that a non-Kinetica date/time/datetime format is being used.- Parameters:
name- The name of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putDateTime
public void putDateTime(String name, Object value, TimeZone timezone) throws GPUdbException
For string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the given timezone (system timezone if none given). If the column is not of a relevant type, set the value without any parsing (so that any string or other typed values can be set using this method without resorting to first check the column's type before calling it). Caveat is that due to string manipulation, this is considerably slower thanput(java.lang.String, java.lang.Object). So, use this method only if you know that a non-Kinetica date/time/datetime format is being used.- Parameters:
name- The name of the column.value- The value to be parsed (based on the given column's type).timezone- Optional parameter specifying the timezone to use for parsing the given value. If null, the system timezone is used.- Throws:
GPUdbException- if an error occurs during the operation.
-
putDateTime
public void putDateTime(int index, Object value) throws GPUdbExceptionFor string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the system timezone. If the column is not of a relevant type, throw an error. Caveat is that due to string manipulation, this is considerably slower thanput(java.lang.String, java.lang.Object). So, use this method only if you know that a non-Kinetica date/time/datetime format is being used.- Parameters:
index- The index of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putDateTime
public void putDateTime(int index, Object value, TimeZone timezone) throws GPUdbExceptionFor string columns with date, time, or datetime property, parse the string and convert to the appropriate Kinetica format using the given timezone (system timezone if none given). If the column is not of a relevant type, set the value without any parsing (so that any string or other typed values can be set using this method without resorting to first check the column's type before calling it). Caveat is that due to string manipulation, this is considerably slower thanput(java.lang.String, java.lang.Object). So, use this method only if you know that a non-Kinetica date/time/datetime format is being used. The following patterns are accepted for date and datetime columns: 1) yyyy[-][/][.]MM[-][/][.]dd[ ]['T'][HH:mm[:ss][.S[S][S][S][S][S]][ ][XXX][Z][z][VV][x]] 2) MM[-][/][.]dd[-][/][.]yyyy[ ]['T'][HH:mm[:ss][.S[S][S][S][S][S]][ ][XXX][Z][z][VV][x]] 3) dd[-][/][.]MM[-][/][.]yyyy[ ]['T'][HH:mm[:ss][.S[S][S][S][S][S]][ ][XXX][Z][z][VV][x]] The following pattern is accepted by time-type columns: HH:mm[:ss][.S[S][S][S][S][S]][ ][XXX][Z][z][VV][x] In other words, the date component can be any of YMD, MDY, or DMY pattern withh '-', '.', or '/' as the separator. And, the time component must have hours and minutes, but can optionally have seconds, fraction of a second (up to six digits) and some form of a timezone identifier.- Parameters:
index- The index of the column.value- The value to be parsed (based on the given column's type).timezone- Optional parameter specifying the timezone to use for parsing the given value. If null, the system timezone is used.- Throws:
GPUdbException- if an error occurs during the operation.
-
putJson
public void putJson(String name, Object value) throws GPUdbException
For String columns with json property, parse the value parameter which may be a String, or Map<String, String>. If the column is not of a relevant type, throw an error.- Parameters:
name- The name of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putJson
public void putJson(int index, Object value) throws GPUdbExceptionFor String columns with json property, parse the value parameter which may be a String, or Map<String, String>. If the column is not of a relevant type, throw an error.- Parameters:
index- The index of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putVector
public void putVector(String name, Object value) throws GPUdbException
For bytes columns with vector property, parse the value property which may be a string, float[], Float[] or List<Float>. If the column is not of a relevant type, throw an error.- Parameters:
name- The name of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
putVector
public void putVector(int index, Object value) throws GPUdbExceptionFor bytes columns with vector property, parse the value parameter which may be a string, float[], Float[] or List<Float>. If the column is not of a relevant type, throw an error.- Parameters:
index- The index of the column.value- The value to be parsed (based on the given column's type).- Throws:
GPUdbException- if an error occurs during the operation.
-
getDataMap
public Map<String,Object> getDataMap()
Description copied from interface:RecordReturns aMapof field names to values that is bound to the record (updates made to the map are reflected in the record and vice versa).- Specified by:
getDataMapin interfaceRecord- Returns:
- the map
-
-