C++ SDK Documentation  11.0.0
Vertica::ScalarFunction Class Referenceabstract

Interface for User-Defined Scalar Function (UDSF). A UDSF produces a single value from a row of data. More...

Inheritance diagram for Vertica::ScalarFunction:
Inheritance graph
Collaboration diagram for Vertica::ScalarFunction:
Collaboration graph

Public Member Functions

void cancelUDX (ServerInterface &srvInterface)
 
virtual void destroy (ServerInterface &srvInterface, const SizedColumnTypes &argTypes)
 
virtual void destroy (ServerInterface &srvInterface, const SizedColumnTypes &argTypes, SessionParamWriterMap &udSessionParams)
 
virtual void getOutputRange (ServerInterface &srvInterface, ValueRangeReader &inRange, ValueRangeWriter &outRange)
 
bool isCanceled () const
 
virtual void processBlock (ServerInterface &srvInterface, BlockReader &arg_reader, BlockWriter &res_writer)=0
 
virtual void setup (ServerInterface &srvInterface, const SizedColumnTypes &argTypes)
 

Protected Member Functions

virtual void cancel (ServerInterface &srvInterface)
 

Friends

struct ::CPPExecContext
 
class ::EE::VEval
 
class ::UdfSupport
 

Detailed Description

Interface for User-Defined Scalar Function (UDSF). A UDSF produces a single value from a row of data.

A UDSF can be used anywhere a native function can be used, except CREATE TABLE BY PARTITION and SEGMENTED BY expressions.

A ScalarFunction must have an associated ScalarFunctionFactory.

Member Function Documentation

virtual void Vertica::UDXObject::cancel ( ServerInterface &  srvInterface)
inlineprotectedvirtualinherited

Cancel callback to be overridden by the UDX. Called when the query running the UDX has been canceled.

Note
  • This method will be invoked at most once per UDX object. Once a UDX object has been canceled, it will never be un-canceled.
  • This method may be called from a separate thread, concurrently with other methods of this UDX object (but never the constructor or destructor). Implementations must be thread-safe with all methods of this UDX.
  • This method will be invoked for either an explicit user cancel, or in the event of an error during query execution.
void Vertica::UDXObject::cancelUDX ( ServerInterface &  srvInterface)
inlineinherited

Cancel callback invoked when the query running the UDX has been canceled. See cancel().

virtual void Vertica::UDXFunction::destroy ( ServerInterface &  srvInterface,
const SizedColumnTypes argTypes 
)
inlinevirtualinherited

Perform per instance destruction. This function may throw errors

virtual void Vertica::UDXFunction::destroy ( ServerInterface &  srvInterface,
const SizedColumnTypes argTypes,
SessionParamWriterMap udSessionParams 
)
inlinevirtualinherited

Perform per instance destruction and write session parameters to be used by UDxs that are invoked after this one returns. This function may throw errors

virtual void Vertica::ScalarFunction::getOutputRange ( ServerInterface &  srvInterface,
ValueRangeReader &  inRange,
ValueRangeWriter &  outRange 
)
inlinevirtual

Invoke a user defined function to determine the output value range of this function. Ranges are represented by a minimum/maximum pair of values (inclusive). The developer is responsible to provide an output value range on the basis of the input argument ranges. Minimum/maximum values of ranges are of the same type as defined in the metadata class getPrototype() function.

Parameters
srvInterfacea ServerInterface object used to communicate with Vertica
inRangeinput value range
outRangeoutput value range
Remarks
By default, the ValueRangeWriter object can have NULL values, values in the range are unsorted, and it is unbounded, i.e., the following functions return as follows:
  • outRange.canHaveNulls() == true
  • outRange.getSortedness() == EE::SORT_UNORDERED
  • outRange.isBounded() == false
Note
  • This methods may be invoked by different threads at different times, and by a different thread than the constructor.
  • C++ exceptions may NOT be thrown out of this method. Use the vertica specific vt_throw_exception() function or vt_report_error() macro instead
  • Invoking vt_throw_exception() or vt_report_error() from this method will not stop the function execution, which may still complete successfully. Instead, the output range will be discarded, and a WARNING message will be written to the Vertica log
bool Vertica::UDXObject::isCanceled ( ) const
inlineinherited
Returns
true iff this UDX has been canceled
virtual void Vertica::ScalarFunction::processBlock ( ServerInterface &  srvInterface,
BlockReader arg_reader,
BlockWriter res_writer 
)
pure virtual

Invoke a user defined function on a set of rows. As the name suggests, a batch of rows are passed in for every invocation to amortize performance.

Parameters
srvInterfacea ServerInterface object used to communicate with Vertica
arg_readerinput rows
res_writeroutput location
Note
  • This methods may be invoked by different threads at different times, and by a different thread than the constructor.
  • The order in which the function sees rows is not guaranteed.
  • C++ exceptions may NOT be thrown out of this method. Use the vertica specific vt_throw_exception() function or vt_report_error() macro instead
virtual void Vertica::UDXFunction::setup ( ServerInterface &  srvInterface,
const SizedColumnTypes argTypes 
)
inlinevirtualinherited

Perform per instance initialization. This function may throw errors.