C++ SDK Documentation  24.2.0
Vertica::BlockWriter Class Reference

Iterator interface for writing rows to a Vertica block. More...

Inheritance diagram for Vertica::BlockWriter:
Inheritance graph
Collaboration diagram for Vertica::BlockWriter:
Collaboration graph

Public Member Functions

 BlockWriter (int rowcount)
 
 BlockWriter (char *outArr, int stride, int rowcount, const int *indices, const VerticaType &dt)
 
int capacity () const
 
void copy (const VerticaBlock &other)
 
void copyFromInput (size_t dstIdx, const BlockReader &vblock, size_t srcIdx)
 
void copyFromInput (const BlockReader &vblock)
 
Array::ArrayWriter getArrayRef (size_t idx=0)
 Get a handle for writing an output array value. More...
 
template<class T >
const T * getColPtr (size_t idx) const
 
template<>
const VStringgetColPtr (size_t idx) const
 
template<>
const VNumericgetColPtr (size_t idx) const
 
template<>
const VUuidgetColPtr (size_t idx) const
 
template<>
const BlockReadergetColPtr (size_t idx) const
 
template<class T >
T * getColPtrForWrite (size_t idx)
 
template<>
VStringgetColPtrForWrite (size_t idx)
 
template<>
VNumericgetColPtrForWrite (size_t idx)
 
template<>
VUuidgetColPtrForWrite (size_t idx)
 
template<>
BlockWritergetColPtrForWrite (size_t idx)
 
template<class T >
const T & getColRef (size_t idx) const
 
template<class T >
T & getColRefForWrite (size_t idx)
 
int getColStride (size_t idx) const
 
const EE::DataAreagetDataArea (size_t idx) const
 
size_t getNumCols () const
 
VNumericgetNumericRef (size_t idx=0)
 Allocates a new VNumeric object to use as output. More...
 
int getNumRows () const
 
BlockWritergetRowPtr (size_t idx=0)
 Get a pointer for writing an output Row value. More...
 
BlockWritergetRowRef (size_t idx=0)
 Get a reference for writing an output Row value. More...
 
int getRowsWritten () const
 
VStringgetStringPtr (size_t idx=0)
 Get a pointer for writing output. More...
 
VStringgetStringRef (size_t idx=0)
 Allocates a new VString object to use as output. More...
 
const SizedColumnTypesgetTypeMetaData () const
 
SizedColumnTypesgetTypeMetaData ()
 
VUuidgetUuidRef (size_t idx=0)
 Allocates a new VUuid object to use as output. More...
 
void * getVoidPtr (size_t idx=0)
 
const void * getVoidPtr (size_t idx=0) const
 
bool hasMoreSpace () const
 
bool next ()
 Complete writing this row of output and move to the next row. More...
 
bool remaining () const
 
virtual void resetForDataAreaFlush ()
 
void setBool (vbool r)
 Adds a BOOLEAN value to the output row. More...
 
void setBool (size_t idx, vbool r)
 Adds a BOOLEAN value to the indicated column of the output row. More...
 
void setDataArea (size_t idx, void *dataarea)
 
void setDate (DateADT r)
 Adds a DATE value to the output row. More...
 
void setDate (size_t idx, DateADT r)
 Adds a DATE value to the indicated column of the output row. More...
 
void setFloat (vfloat r)
 Adds a FLOAT value to the output row. More...
 
void setFloat (size_t idx, vfloat r)
 Adds a FLOAT value to the indicated column of the output row. More...
 
void setInt (vint r)
 Adds an INTEGER value to the output row. More...
 
void setInt (size_t idx, vint r)
 Adds an INTEGER value to the indicated column of the output row. More...
 
void setInterval (Interval r)
 Adds an INTERVAL value to the output row. More...
 
void setInterval (size_t idx, Interval r)
 Adds an INTERVAL value to the indicated column of the output row. More...
 
void setIntervalYM (IntervalYM r)
 Adds an INTERVAL YEAR TO MONTH value to the output row. More...
 
void setIntervalYM (size_t idx, IntervalYM r)
 Adds an INTERVAL YEAR TO MONTH value to the indicated column of the output row. More...
 
void setNull (size_t idx=0, bool enforceNotNullProperty=true)
 Set the column to null. More...
 
void setTime (TimeADT r)
 Adds a TIME value to the output row. More...
 
void setTime (size_t idx, TimeADT r)
 Adds an TIME value to the indicated column of the output row. More...
 
void setTimestamp (Timestamp r)
 Adds a TIMESTAMP value to the output row. More...
 
void setTimestamp (size_t idx, Timestamp r)
 Adds an TIMESTAMP value to the indicated column of the output row. More...
 
void setTimestampTz (TimestampTz r)
 Adds a TIMESTAMP WITH TIMEZONE value to the output row. More...
 
void setTimestampTz (size_t idx, TimestampTz r)
 Adds an TIMESTAMP WITH TIMEZONE value to the indicated column of the output row. More...
 
void setTimeTz (TimeTzADT r)
 Adds a TIME WITH TIMEZONE value to the output row. More...
 
void setTimeTz (size_t idx, TimeTzADT r)
 Adds an TIME WITH TIMEZONE value to the indicated column of the output row. More...
 
void throwIncorrectUsageError ()
 

Protected Member Functions

void addCol (char *arg, int colstride, const Field &field)
 
void addCol (const char *arg, int colstride, const Field &field)
 
bool checkStringUserBlockInfo (size_t idx) const
 
bool checkTimeUserBlockInfo (size_t idx) const
 
EE::DataArea ** getArrayIntermediateDataArea (size_t c)
 
void reset ()
 
void resetIndex ()
 
void setRowCount (int rowCount)
 
void validateStringColumn (size_t idx, const VString &s, size_t colLength) const
 

Protected Attributes

std::vector< char * > cols
 
std::vector< int > colstrides
 
int count
 
std::vector< NestedBlockPtrctWrappers
 
int index
 
const int * indices
 
size_t ncols
 
int nrows
 
std::vector< BaseDataOID > processBlockUserInfoVector
 
std::vector< VStringsvWrappers
 
SizedColumnTypes typeMetaData
 
std::vector< VUuiduuWrappers
 
std::vector< VNumericvnWrappers
 

Friends

class Array::ArrayWriter
 
class EE::VEval
 
class PartitionWriter
 

Detailed Description

Iterator interface for writing rows to a Vertica block.

This class provides the output rows that ScalarFunction.processBlock() writes to.

Member Function Documentation

◆ addCol()

void Vertica::VerticaBlock::addCol ( char *  arg,
int  colstride,
const Field field 
)
protectedinherited

Add the location for reading a particular argument.

Parameters
argThe base location to find data.
colstrideThe stride between data instances.
fieldmetadata for the added column
dtThe type of input.
fieldnamethe name of the field

Referenced by Vertica::ParamReader::addParameter().

◆ copyFromInput() [1/2]

void Vertica::BlockWriter::copyFromInput ( size_t  dstIdx,
const BlockReader vblock,
size_t  srcIdx 
)

Copies a column from the input reader to the output writer. Raises an error if the input and output data types are not compatible.

Parameters
dstIdxThe destination column index in the output writer (this)
vblockThe source data block
srcIdxThe source column index in the input reader

Referenced by Vertica::copyBlockColumn(), and copyFromInput().

◆ copyFromInput() [2/2]

void Vertica::BlockWriter::copyFromInput ( const BlockReader vblock)
inline

Copy all columns from the source block to this block

◆ getArrayIntermediateDataArea()

EE::DataArea** Vertica::VerticaBlock::getArrayIntermediateDataArea ( size_t  c)
inlineprotectedinherited
Returns
a pointer to a DataArea for accumulating an intermediate result

◆ getArrayRef()

Array::ArrayWriter Vertica::BlockWriter::getArrayRef ( size_t  idx = 0)

Get a handle for writing an output array value.

Parameters
idxthe output column
Returns
a handle for writing array elements

◆ getColPtr()

template<class T >
const T* Vertica::VerticaBlock::getColPtr ( size_t  idx) const
inlineinherited
Returns
a pointer to the idx'th argument, cast appropriately.

Example:

const vint *a = arg_reader->getColPtr<vint>(0);

◆ getColRef()

template<class T >
const T& Vertica::VerticaBlock::getColRef ( size_t  idx) const
inlineinherited
Returns
a pointer to the idx'th argument, cast appropriately.

Example: const vint a = arg_reader->getColRef<vint>(0);

◆ getNumCols()

size_t Vertica::VerticaBlock::getNumCols ( ) const
inlineinherited
Returns
the number of columns held by this block.

Referenced by copyFromInput(), Vertica::BlockReader::isNull(), and setNull().

◆ getNumericRef()

VNumeric& Vertica::BlockWriter::getNumericRef ( size_t  idx = 0)
inline

Allocates a new VNumeric object to use as output.

Parameters
idxthe column to reference (default 0)
Returns
A new VNumeric object to hold output. This object automatically added to the output row in the indicated column

Referenced by setNull().

◆ getNumRows()

int Vertica::VerticaBlock::getNumRows ( ) const
inlineinherited
Returns
the number of rows held by this block.

◆ getRowPtr()

BlockWriter* Vertica::BlockWriter::getRowPtr ( size_t  idx = 0)
inline

Get a pointer for writing an output Row value.

Parameters
idxthe output column
Returns
a pointer to a BlockWriter which holds output data for the Row value's fields

◆ getRowRef()

BlockWriter& Vertica::BlockWriter::getRowRef ( size_t  idx = 0)
inline

Get a reference for writing an output Row value.

Parameters
idxthe output column
Returns
a reference to a BlockWriter which holds output data for the Row value's fields

Referenced by getRowPtr(), and Vertica::PartitionWriter::getRowRef().

◆ getStringPtr()

VString* Vertica::BlockWriter::getStringPtr ( size_t  idx = 0)
inline

Get a pointer for writing output.

Parameters
idxthe output column
Returns
A new VString object to hold output. This object automatically added to the output row in the indicated column

◆ getStringRef()

VString& Vertica::BlockWriter::getStringRef ( size_t  idx = 0)
inline

Allocates a new VString object to use as output.

Parameters
idxthe column to reference (default 0)
Returns
A new VString object to hold output. This object is automatically added to the output row in the indicated column

Referenced by getStringPtr(), and setNull().

◆ getTypeMetaData() [1/2]

const SizedColumnTypes& Vertica::VerticaBlock::getTypeMetaData ( ) const
inlineinherited
Returns
information about the types and numbers of arguments

Referenced by Vertica::ParamReader::getType(), Vertica::BlockReader::isNull(), and setNull().

◆ getTypeMetaData() [2/2]

SizedColumnTypes& Vertica::VerticaBlock::getTypeMetaData ( )
inlineinherited
Returns
information about the types and numbers of arguments

◆ getUuidRef()

VUuid& Vertica::BlockWriter::getUuidRef ( size_t  idx = 0)
inline

Allocates a new VUuid object to use as output.

Parameters
idxthe column to reference (default 0)
Returns
A new VUuid object to hold output. This object automatically added to the output row in the indicated column

Referenced by setNull().

◆ next()

bool Vertica::BlockWriter::next ( )
inline

Complete writing this row of output and move to the next row.

Referenced by Vertica::copyBlockColumn().

◆ remaining()

bool Vertica::VerticaBlock::remaining ( ) const
inlineinherited
Returns
the number of entries remaining in the block

◆ resetForDataAreaFlush()

virtual void Vertica::VerticaBlock::resetForDataAreaFlush ( )
inlinevirtualinherited

Virtual method to be called when the Data Area fills up in a load. Should be called from the StreamWriter class.

Reimplemented in Vertica::StreamWriter.

◆ setBool() [1/2]

void Vertica::BlockWriter::setBool ( vbool  r)
inline

Adds a BOOLEAN value to the output row.

Parameters
rThe BOOLEAN value to insert into the output row.

Referenced by setNull().

◆ setBool() [2/2]

void Vertica::BlockWriter::setBool ( size_t  idx,
vbool  r 
)
inline

Adds a BOOLEAN value to the indicated column of the output row.

Parameters
idxthe column index
rthe BOOLEAN value to insert

◆ setDate() [1/2]

void Vertica::BlockWriter::setDate ( DateADT  r)
inline

Adds a DATE value to the output row.

Parameters
rThe DATE value to insert into the output row.

Referenced by setNull().

◆ setDate() [2/2]

void Vertica::BlockWriter::setDate ( size_t  idx,
DateADT  r 
)
inline

Adds a DATE value to the indicated column of the output row.

Parameters
idxthe column index
rthe DATE value to insert

◆ setFloat() [1/2]

void Vertica::BlockWriter::setFloat ( vfloat  r)
inline

Adds a FLOAT value to the output row.

Parameters
rThe FLOAT value to insert into the output row.

Referenced by setNull().

◆ setFloat() [2/2]

void Vertica::BlockWriter::setFloat ( size_t  idx,
vfloat  r 
)
inline

Adds a FLOAT value to the indicated column of the output row.

Parameters
idxthe column index
rthe FLOAT value to insert

◆ setInt() [1/2]

void Vertica::BlockWriter::setInt ( vint  r)
inline

Adds an INTEGER value to the output row.

Setter methods

Parameters
rThe INTEGER value to insert into the output row.

Referenced by setNull().

◆ setInt() [2/2]

void Vertica::BlockWriter::setInt ( size_t  idx,
vint  r 
)
inline

Adds an INTEGER value to the indicated column of the output row.

Parameters
idxthe column index
rthe INTEGER value to insert

◆ setInterval() [1/2]

void Vertica::BlockWriter::setInterval ( Interval  r)
inline

Adds an INTERVAL value to the output row.

Parameters
rThe INTERVAL value to insert into the output row.

Referenced by setNull().

◆ setInterval() [2/2]

void Vertica::BlockWriter::setInterval ( size_t  idx,
Interval  r 
)
inline

Adds an INTERVAL value to the indicated column of the output row.

Parameters
idxthe column index
rthe INTERVAL value to insert

◆ setIntervalYM() [1/2]

void Vertica::BlockWriter::setIntervalYM ( IntervalYM  r)
inline

Adds an INTERVAL YEAR TO MONTH value to the output row.

Parameters
rThe INTERVAL YEAR TO MONTH value to insert into the output row.

Referenced by setNull().

◆ setIntervalYM() [2/2]

void Vertica::BlockWriter::setIntervalYM ( size_t  idx,
IntervalYM  r 
)
inline

Adds an INTERVAL YEAR TO MONTH value to the indicated column of the output row.

Parameters
idxthe column index
rthe INTERVAL YEAR TO MONTH value to insert

◆ setNull()

void Vertica::BlockWriter::setNull ( size_t  idx = 0,
bool  enforceNotNullProperty = true 
)
inline

Set the column to null.

Parameters
idxThe column number in the row to set to null
enforceNotNullPropertyif true, raise an error if the target field has the canBeNull property set to false.

Referenced by Vertica::PartitionWriter::setNull().

◆ setTime() [1/2]

void Vertica::BlockWriter::setTime ( TimeADT  r)
inline

Adds a TIME value to the output row.

Parameters
rThe TIME value to insert into the output row.

Referenced by setNull().

◆ setTime() [2/2]

void Vertica::BlockWriter::setTime ( size_t  idx,
TimeADT  r 
)
inline

Adds an TIME value to the indicated column of the output row.

Parameters
idxthe column index
rthe TIME value to insert

◆ setTimestamp() [1/2]

void Vertica::BlockWriter::setTimestamp ( Timestamp  r)
inline

Adds a TIMESTAMP value to the output row.

Parameters
rThe TIMESTAMP value to insert into the output row.

Referenced by setNull().

◆ setTimestamp() [2/2]

void Vertica::BlockWriter::setTimestamp ( size_t  idx,
Timestamp  r 
)
inline

Adds an TIMESTAMP value to the indicated column of the output row.

Parameters
idxthe column index
rthe TIMESTAMP value to insert

◆ setTimestampTz() [1/2]

void Vertica::BlockWriter::setTimestampTz ( TimestampTz  r)
inline

Adds a TIMESTAMP WITH TIMEZONE value to the output row.

Parameters
rThe TIMESTAMP WITH TIMEZONE value to insert into the output row.

Referenced by setNull().

◆ setTimestampTz() [2/2]

void Vertica::BlockWriter::setTimestampTz ( size_t  idx,
TimestampTz  r 
)
inline

Adds an TIMESTAMP WITH TIMEZONE value to the indicated column of the output row.

Parameters
idxthe column index
rthe TIMESTAMP WITH TIMEZONE value to insert

◆ setTimeTz() [1/2]

void Vertica::BlockWriter::setTimeTz ( TimeTzADT  r)
inline

Adds a TIME WITH TIMEZONE value to the output row.

Parameters
rThe TIME WITH TIMEZONE value to insert into the output row.

Referenced by setNull().

◆ setTimeTz() [2/2]

void Vertica::BlockWriter::setTimeTz ( size_t  idx,
TimeTzADT  r 
)
inline

Adds an TIME WITH TIMEZONE value to the indicated column of the output row.

Parameters
idxthe column index
rthe TIME WITH TIMEZONE value to insert