DSIExtScalarFunction Class Reference

An abstract class that represents a custom scalar function from the DSII. More...

Inherits Simba::Support::UnsafeSharedObject.

List of all members.

Public Member Functions

virtual void Execute (Simba::SQLEngine::InputValues &in_inputValues)=0
 Execute the scalar function for the new set of inputs.
virtual void GetFunctionName (simba_wstring &out_scalarName) const =0
 Get the name of the scalar function.
virtual const std::vector
< SqlTypeMetadata * > & 
GetInputMetadata ()=0
 Retrieve the metadata representing the inputs to the scalar function.
virtual SqlTypeMetadataGetOutputMetadata ()=0
 Retrieve the metadata representing the output of the scalar function.
virtual bool RetrieveData (SqlData *io_data, simba_signed_native in_offset, simba_signed_native in_maxSize)=0
 Fills in in_data with a chunk of data for the scalar function.
virtual bool UpdateMetadata (const std::vector< SqlTypeMetadata * > &in_inputMetadata, bool in_isPrepare)=0
 Update the expected input and return metadata for the scalar function based on the input metadata.
virtual ~DSIExtScalarFunction ()
 Destructor.

Protected Member Functions

 DSIExtScalarFunction ()
 Constructor.

Detailed Description

An abstract class that represents a custom scalar function from the DSII.


Constructor & Destructor Documentation

virtual ~DSIExtScalarFunction (  )  [inline, virtual]

Destructor.

DSIExtScalarFunction (  )  [inline, protected]

Constructor.


Member Function Documentation

virtual void Execute ( Simba::SQLEngine::InputValues in_inputValues  )  [pure virtual]

Execute the scalar function for the new set of inputs.

After execution, the value will be retrieved via RetrieveData(). The parameters that are passed via Execute() will also be valid during later calls to RetrieveData().

Parameters:
in_inputValues The input values for the scalar function.
virtual void GetFunctionName ( simba_wstring out_scalarName  )  const [pure virtual]

Get the name of the scalar function.

Parameters:
out_scalarName The name of the scalar function.
virtual const std::vector<SqlTypeMetadata*>& GetInputMetadata (  )  [pure virtual]

Retrieve the metadata representing the inputs to the scalar function.

Note that the collection can be empty if there are no inputs to the scalar function.

Returns:
The set of metadata representing the inputs to the scalar function. (NOT OWN)
virtual SqlTypeMetadata* GetOutputMetadata (  )  [pure virtual]

Retrieve the metadata representing the output of the scalar function.

Returns:
The metadata for the output of the scalar function. (NOT OWN)
virtual bool RetrieveData ( SqlData io_data,
simba_signed_native  in_offset,
simba_signed_native  in_maxSize 
) [pure virtual]

Fills in in_data with a chunk of data for the scalar function.

The SqlTypeMetadata* used by in_data is the same SqlTypeMetadata* for the output metadata.

It implements the following procedure: (1) If the data is null, call in_data->SetNull(true). in_offset and in_maxSize can be ignored

(2) If the data is not of a character or binary type, then the value should be copied into the pointer returned by in_data->GetBuffer(). in_offset and in_maxSize can be ignored

(3) If the data is of a character or binary type: (a) in_offset specifies the starting point to copy data from, in # of bytes from the start of that piece of data (b) in_offset must be aligned properly to the start of a data element (c) in_maxSize indicates the maximum number of bytes to copy (d) if in_maxSize is RETRIEVE_ALL_DATA, it means that the whole piece of data should be copied (e) the size of the data chunk being copied should be set with in_data->SetLength() (f) this length is the number of full elements copied (g) if there's only room for a partial element at the end, it does not need to be copied, and should not be included in the SetLength() length (h) calling SetLength() must be done before copying data in, because it modifies the size of the data buffer (i) the chunk of data starting at in_offset which is at a maximum in_size bytes long should be copied into the pointer returned by in_data->GetBuffer(). (j) null termination is not necessary, though for character data the buffer has extra room available at the end for a null terminator

Parameters:
io_data Holds a buffer to store the requested data. (NOT OWN)
in_offset Number of bytes in the data to skip before copying into in_data.
in_maxSize Maximum number of bytes of data to returning in in_data.
Returns:
True if there is more data left, false otherwise.
virtual bool UpdateMetadata ( const std::vector< SqlTypeMetadata * > &  in_inputMetadata,
bool  in_isPrepare 
) [pure virtual]

Update the expected input and return metadata for the scalar function based on the input metadata.

This function will be called at least twice, once during the preparation phase when metadata may be inaccurate due to parameters, and one or more times during execution when metadata will be accurate as parameters will have been bound.

This function will allow the scalar function implementation to change the output metadata as well as the expected input metadata for the scalar function if needed, however if the expected input and output metadata doesn't change based on inputs, this function can do nothing.

This function will also allow the implementation to validate the types of the input metadata to reject types that are not expected to work. For instance, if the scalar function should only accept numeric types as input, this function could throw an exception to reject non-numeric inputs. Note that this should only happen on the second call at execution time, as at prepare time the metadata may be inaccurate. If the implementation does not do validation of types, then the SQLEngine will attempt to convert input data to match the type reported for the input argument.

Parameters:
in_inputMetadata The current metadata for each of the inputs to the scalar function. The index of the metadata corresponds directly to the input into the scalar function. (NOT OWN)
in_isPrepare Flag indicating if this is a prepare metadata call, in which case the input metadata may not be accurate, or an execute metadata call, when the input metadata will be accurate.
Returns:
True if the output metadata was updated; false otherwise.

The documentation for this class was generated from the following file:

Generated on Wed May 17 14:21:18 2017 for SimbaEngine 10.1.3.1011 by simba