Java SDK Documentation  12.0.0
com.vertica.sdk.PartitionWriter Class Referenceabstract
Inheritance diagram for com.vertica.sdk.PartitionWriter:
Inheritance graph
Collaboration diagram for com.vertica.sdk.PartitionWriter:
Collaboration graph

Public Member Functions

 PartitionWriter (int nargs)
 
void addCol (ByteBuffer arg, int colstride, VerticaType dt, String colName)
 
void addCol (ByteBuffer arg, int colstride, VerticaType dt)
 
void addCol (ByteBuffer arg, ByteBuffer da, int colstride, VerticaType dt)
 
void addCol (ByteBuffer arg, ByteBuffer da, int colstride, VerticaType dt, String colName)
 
boolean checkStringUserBlockInfo (int idx)
 
boolean checkTimeUserBlockInfo (int idx)
 
void copyFromInput (int dstIdx, PartitionReader input_reader, int srcIdx) throws UdfException
 
ByteBuffer getColDataAreaRef (int idx)
 
ByteBuffer getColRef (int idx)
 
TypeCoercion getDefaultTypeCoercion ()
 
int getNumCols ()
 
VNumeric getNumericWriter (int idx)
 
int getNumRows ()
 
BaseDataOID getProcessBlockUserInfoVectorAt (int i)
 
VString getStringWriter (int idx)
 
SizedColumnTypes getTypeMetaData ()
 
abstract boolean getWriteableBlock () throws UdfException, DestroyInvocation
 
boolean next () throws UdfException, DestroyInvocation
 
void resetBuffers ()
 
void setBoolean (int idx, boolean r)
 
void setBooleanNull (int idx)
 
void setBooleanValue (int idx, Boolean value)
 
void setDate (int idx, java.sql.Date r)
 
void setDateNull (int idx)
 
void setDateValue (int idx, java.sql.Date value)
 
TypeCoercion setDefaultTypeCoercion (TypeCoercion coerce)
 
void setDouble (int idx, double r)
 
void setDoubleNull (int idx)
 
void setDoubleValue (int idx, Double value)
 
void setLong (int idx, long r)
 
void setLongNull (int idx)
 
void setLongValue (int idx, Long value)
 
void setNumeric (int idx, BigDecimal bd)
 
void setNumericNull (int idx)
 
void setNumericValue (int idx, BigDecimal value)
 
void setRowFromMap (Map< String,?> rowData)
 
void setRowFromMap (Map< String,?> rowData, TypeCoercion coerce)
 
void setString (int idx, String r)
 
void setStringBytes (int idx, ByteBuffer bytes)
 
void setStringNull (int idx)
 
void setStringValue (int idx, String value)
 
void setTimestamp (int idx, java.sql.Timestamp r)
 
void setTimestampInfiniteNeg (int idx)
 
void setTimestampInfinitePos (int idx)
 
void setTimestampNull (int idx)
 
void setTimestampValue (int idx, java.sql.Timestamp value)
 
void setValue (int idx, Object value, TypeCoercion coerce)
 
void setVMap (int idx, Map< String,?> data)
 
void setVMap (int idx, Map< String,?> data, TypeCoercion coerce)
 
void throwInCorrectUsageError (int idx)
 : Throwing UdfException for incorrect setter usage
 

Public Attributes

int count
 
int index
 
int ncols
 
int nrows
 
SizedColumnTypes typeMetaData
 

Protected Member Functions

void clear ()
 
ByteBuffer getInlineColBuffer (int idx)
 
long getRowSize (SizedColumnTypes types)
 
void setRowCount (SizedColumnTypes types)
 

Static Protected Member Functions

static long blockSizeGivenRowSize (long row_size)
 

Protected Attributes

ArrayList< ByteBuffer > coldataareas
 
ArrayList< ByteBuffer > cols
 
ArrayList< Integer > colstrides
 
ArrayList< Integer > currentPos
 

Detailed Description

PartitionWriter provides an iterator-based write interface over output data for a single partition. Automatically makes space a block-at-a-time, as needed.

Member Function Documentation

void com.vertica.sdk.VerticaBlock.addCol ( ByteBuffer  arg,
int  colstride,
VerticaType  dt,
String  colName 
)
inherited

Add the location for reading a particular argument.

Parameters
argThe base location to find data.
colstrideThe stride between data instances.
dtThe type of input.
colNameName of the column

Referenced by com.vertica.sdk.VerticaBlock.addCol().

void com.vertica.sdk.VerticaBlock.addCol ( ByteBuffer  arg,
int  colstride,
VerticaType  dt 
)
inherited

Add the location for reading a particular argument.

Parameters
argThe base location to find data.
colstrideThe stride between data instances.
dtThe type of input.
void com.vertica.sdk.VerticaBlock.addCol ( ByteBuffer  arg,
ByteBuffer  da,
int  colstride,
VerticaType  dt 
)
inherited

Add the location for reading a particular argument.

Parameters
argThe base location to find data.
daThe location to find out of band string data.
colstrideThe stride between data instances.
dtThe type of input.
void com.vertica.sdk.VerticaBlock.addCol ( ByteBuffer  arg,
ByteBuffer  da,
int  colstride,
VerticaType  dt,
String  colName 
)
inherited

Add the location for reading a particular argument.

Parameters
argThe base location to find data.
daThe location to find out of band string data.
colstrideThe stride between data instances.
dtThe type of input.
colNameName of the column
void com.vertica.sdk.PartitionWriter.copyFromInput ( int  dstIdx,
PartitionReader  input_reader,
int  srcIdx 
) throws UdfException

Copies a column from the input reader to the output writer. The data types and sizes of the source and destination columns must match exactly.

Parameters
dstIdxThe destination column index (in the output writer)
input_readerThe input reader from which to copy a column
srcIdxThe source column index (in the input reader)
ByteBuffer com.vertica.sdk.VerticaBlock.getColDataAreaRef ( int  idx)
inherited

Get the ByteBuffer that stores out of line string data (Data Area) for the idx'th argument

Parameters
idxThe column number to retrieve from the input row.
Returns
the ByteBuffer

Referenced by com.vertica.sdk.BlockReader.getVString().

ByteBuffer com.vertica.sdk.VerticaBlock.getColRef ( int  idx)
inherited

Example: ByteBuffer a = arg_reader.getColPtr(0);

Parameters
idxThe column number to retrieve from the input row.
Returns
a ByteBuffer to the idx'th argument, containing data for the column

Referenced by com.vertica.sdk.PartitionWriter.copyFromInput(), com.vertica.sdk.BlockReader.getBoolean(), com.vertica.sdk.BlockReader.getDouble(), com.vertica.sdk.VerticaBlock.getInlineColBuffer(), com.vertica.sdk.BlockReader.getLong(), com.vertica.sdk.BlockReader.getStringLength(), com.vertica.sdk.BlockReader.getStringLoc(), com.vertica.sdk.BlockReader.getVNumeric(), com.vertica.sdk.BlockReader.getVString(), com.vertica.sdk.BlockWriter.getVStringWriter(), com.vertica.sdk.BlockReader.isBooleanNull(), com.vertica.sdk.ParamWriter.setBool(), com.vertica.sdk.BlockWriter.setBoolean(), com.vertica.sdk.BlockWriter.setBooleanNull(), com.vertica.sdk.PartitionWriter.setBooleanValue(), com.vertica.sdk.BlockWriter.setDate(), com.vertica.sdk.BlockWriter.setDateNull(), com.vertica.sdk.PartitionWriter.setDateValue(), com.vertica.sdk.BlockWriter.setDouble(), com.vertica.sdk.ParamWriter.setDouble(), com.vertica.sdk.BlockWriter.setDoubleNull(), com.vertica.sdk.PartitionWriter.setDoubleValue(), com.vertica.sdk.BlockWriter.setLong(), com.vertica.sdk.ParamWriter.setLong(), com.vertica.sdk.BlockWriter.setLongNull(), com.vertica.sdk.ParamWriter.setLongString(), com.vertica.sdk.PartitionWriter.setLongValue(), com.vertica.sdk.ParamWriter.setNumeric(), com.vertica.sdk.BlockWriter.setNumeric(), com.vertica.sdk.ParamWriter.setString(), com.vertica.sdk.BlockWriter.setString(), com.vertica.sdk.BlockWriter.setStringNull(), com.vertica.sdk.BlockWriter.setTimestamp(), com.vertica.sdk.BlockWriter.setTimestampInfiniteNeg(), com.vertica.sdk.BlockWriter.setTimestampInfinitePos(), com.vertica.sdk.BlockWriter.setTimestampNull(), and com.vertica.sdk.PartitionWriter.setTimestampValue().

TypeCoercion com.vertica.sdk.PartitionWriter.getDefaultTypeCoercion ( )

Give the default TypeCoercion instance, creating one if necessary. This may be useful in cases where the calling code would like to change the TypeCoercionPolicy or do TypeCoercion in the same manner as this PartitionWriter.

If a TypeCoercion is created, it is an instance of StandardTypeCoercion.

See Also
#setRowFromMap(Map)
Returns
the current default TypeCoercion, creating one if necessary.

Referenced by com.vertica.sdk.PartitionWriter.setRowFromMap(), and com.vertica.sdk.PartitionWriter.setVMap().

ByteBuffer com.vertica.sdk.VerticaBlock.getInlineColBuffer ( int  idx)
protectedinherited

Give a ByteBuffer for the given column (inline storage only). Returns a buffer with position and limit bounding the data area for a single element of that column, given the current position in the column.

Parameters
idxThe column number to retrieve from the input row.
Returns
the ByteBuffer for the column

Referenced by com.vertica.sdk.PartitionWriter.setStringBytes(), and com.vertica.sdk.PartitionWriter.setStringValue().

int com.vertica.sdk.VerticaBlock.getNumCols ( )
inherited
Returns
the number of arguments held by this reader.
int com.vertica.sdk.VerticaBlock.getNumRows ( )
inherited
Returns
the number of rows held by this block.
SizedColumnTypes com.vertica.sdk.VerticaBlock.getTypeMetaData ( )
inherited
Returns
information about the types and numbers of arguments

Referenced by com.vertica.sdk.ParamReader.getType(), com.vertica.sdk.PartitionWriter.setRowFromMap(), and com.vertica.sdk.PartitionWriter.setValue().

abstract boolean com.vertica.sdk.PartitionWriter.getWriteableBlock ( ) throws UdfException, DestroyInvocation
pure virtual

Gets a writeable block of data and positions cursor at the beginning.

Returns
true on success; use other methods to manipulate the block
Exceptions
UdfExceptionUDF problem
DestroyInvocationInvocation needed to be destroyed

Implemented in com.vertica.sdk.StreamWriter, and com.vertica.sdk.AnalyticPartitionWriter.

void com.vertica.sdk.PartitionWriter.setBooleanValue ( int  idx,
Boolean  value 
)

Set a Boolean value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setDateValue ( int  idx,
java.sql.Date  value 
)

Set a Date value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
TypeCoercion com.vertica.sdk.PartitionWriter.setDefaultTypeCoercion ( TypeCoercion  coerce)

Set the default type coercion instance.

See Also
#setRowFromMap(Map)
Parameters
coerceA TypeCoercion instance.
Returns
the former default, which may be null.
void com.vertica.sdk.PartitionWriter.setDoubleValue ( int  idx,
Double  value 
)

Set a Double value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setLongValue ( int  idx,
Long  value 
)

Set a Long value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setNumericValue ( int  idx,
BigDecimal  value 
)

Set a Numeric value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setRowFromMap ( Map< String,?>  rowData)

Sets all columns on the current row according to the data provided, using the column names to match the data keys. See setRowFromMap(Map, TypeCoercion) for more details. This is a shortcut for using the default type coercion.

Parameters
rowDataThe data. Null data is treated as empty.
See Also
#setRowFromMap(Map, TypeCoercion)
getDefaultTypeCoercion()
void com.vertica.sdk.PartitionWriter.setRowFromMap ( Map< String,?>  rowData,
TypeCoercion  coerce 
)

Sets all columns on the current row according to the data provided, using the column names to match the data keys.

For each column, TypeCoercion will be used to convert a value in rowData to the appropriate type for that column. This is done via setValue and may cause a TypeCoercion exception.

To find the corresponding value, the 'first' matching key (according to case-insensitive SQL identifier matching) in the map will be used. 'first' is not well defined, but is consistent.

If no corresponding value is found, the column will be set to null. This never raises an exception, regardless of the target column type. That is, FAIL_SDK_UNSUPPORTED_TYPE is ignored in that case.

In addition, if the target row structure appears to be a flex table, the necessary internal structures will be populated with an encoded vmap via setVMap(int, Map, TypeCoercion).

Parameters
rowDataThe data. Null data is treated as empty.
coerceThe implementation of coercion
See Also
#setVMap(int, Map, TypeCoercion)
setValue(int, Object, TypeCoercion)
void com.vertica.sdk.PartitionWriter.setStringBytes ( int  idx,
ByteBuffer  bytes 
)

Set a String value for column at index idx. Accepts null values.

Parameters
idxThe column index
bytesA ByteBuffer with bytes between position and limit that are a string encoded according to Vertica's requirements. This buffer must fit within the column's length requirements.
Exceptions
IllegalArgumentExceptionif bytes is too long
void com.vertica.sdk.PartitionWriter.setStringValue ( int  idx,
String  value 
)

Set a String value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setTimestampValue ( int  idx,
java.sql.Timestamp  value 
)

Set a Timestamp value for column at index idx. Accepts null values.

Parameters
idxcolumn number
valuevalue to set it to
void com.vertica.sdk.PartitionWriter.setValue ( int  idx,
Object  value,
TypeCoercion  coerce 
)

Set a value for a column using type coercion. Type coercion attempts to generate an appropriate value for the target column type based on the input type.

The following target column types are supported by the SDK for this method. All others will generate a TypeCoercionException due to FAIL_SDK_UNSUPPORTED_TYPE if appropriate.

  • Bools
  • Integers (excluding Numeric)
  • Floats
  • String-like types (char and binary, along with var- and long variants)
  • Timestamp and timestamptz
  • Dates
Parameters
idxThe column index
valueThe value to store in the column. May be null.
coerceThe type coercion policy.

Referenced by com.vertica.sdk.PartitionWriter.setRowFromMap().

void com.vertica.sdk.PartitionWriter.setVMap ( int  idx,
Map< String,?>  data 
)

Encodes a VMap into the given column, which must be of binary type.

Parameters
idxThe index of the binary or varbinary column.
dataThe data. Null data is treated as empty.
See Also
#setVMap(int, Map, TypeCoercion)
getDefaultTypeCoercion()
void com.vertica.sdk.PartitionWriter.setVMap ( int  idx,
Map< String,?>  data,
TypeCoercion  coerce 
)

Encodes a VMap into the given column, which must be of binary type. Uses standard type coercion to identify aggregate values and to serialize all values.

Parameters
idxThe index of the binary or varbinary column.
dataThe data. Null data is treated as empty.
coerceIgnored but still here for backwards compatibility.
See Also
#setVMap(int, Map)
getDefaultTypeCoercion()