C++ SDK Documentation  12.0.0
Vertica::ParserFactory Class Referenceabstract

Produces and initializes UDParsers to parse input into tuples. More...

Inheritance diagram for Vertica::ParserFactory:
Inheritance graph
Collaboration diagram for Vertica::ParserFactory:
Collaboration graph

Public Types

enum  UDXType {
  SCALAR = 1, TRANSFORM = 2, ANALYTIC = 3, MULTI_TRANSFORM = 4,
  AGGREGATE = 5, LOAD_SOURCE = 6, LOAD_FILTER = 7, LOAD_PARSER = 8,
  FILESYSTEM = 9, TYPE = 10, CURSOR_TRANSFORM = 11, KEYMANAGER = 12
}
 

Public Member Functions

virtual void getParameterType (ServerInterface &srvInterface, SizedColumnTypes &parameterTypes) __override__
 
virtual void getParserReturnType (ServerInterface &srvInterface, PerColumnParamReader &perColumnParamReader, PlanContext &planCtxt, const SizedColumnTypes &argTypes, SizedColumnTypes &returnType)
 
virtual void getPerInstanceResources (ServerInterface &srvInterface, VResources &res) __override__
 
virtual void getPerInstanceResources (ServerInterface &srvInterface, VResources &res, const SizedColumnTypes &inputTypes) __override__
 
UDXFactory::UDXType getUDXFactoryType () __override__
 
virtual bool isChunkerApportionable (ServerInterface &srvInterface)
 
virtual bool isParserApportionable ()
 
virtual void plan (ServerInterface &srvInterface, PerColumnParamReader &perColumnParamReader, PlanContext &planCtxt)
 
virtual UDParserprepare (ServerInterface &srvInterface, PerColumnParamReader &perColumnParamReader, PlanContext &planCtxt, const SizedColumnTypes &returnType)=0
 
virtual UDChunkerprepareChunker (ServerInterface &srvInterface, PerColumnParamReader &perColumnParamReader, PlanContext &planCtxt, const SizedColumnTypes &returnType)
 

Protected Attributes

Oid libOid
 
std::string sqlName
 

Detailed Description

Produces and initializes UDParsers to parse input into tuples.

Note that ParserFactories are singletons. Subclasses should be stateless, with no fields containing data, just methods. plan() and prepare() methods must never modify any global variables or state; they may only modify the variables that they are given as arguments. (If global state must be modified, use SourceIterator.)

Factories should be registered using the RegisterFactory() macro, defined in Vertica.h.

Member Enumeration Documentation

The type of UDX instance this factory produces

Member Function Documentation

virtual void Vertica::ParserFactory::getParameterType ( ServerInterface srvInterface,
SizedColumnTypes parameterTypes 
)
inlinevirtual

Inherited from the parent "UDXFactory" class in VerticaUDx.h

Reimplemented from Vertica::UDXFactory.

virtual void Vertica::ParserFactory::getParserReturnType ( ServerInterface srvInterface,
PerColumnParamReader perColumnParamReader,
PlanContext planCtxt,
const SizedColumnTypes argTypes,
SizedColumnTypes returnType 
)
inlinevirtual

Function to tell Vertica what the return types (and length/precision if necessary) of this UDX are. Called, possibly multiple times, on each node executing the query.

The default provided implementation configures Vertica to use the same output column types as the destination table. This requires that the UDParser validate the expected output column types and emit appropriate tuples. Note that the default provided implementation of this function should be sufficient for most Parsers, so this method should not be overridden by most Parser implementations. If a COPY statement has a return type that doesn't match the destination table, Vertica will emit an appropriate error. Users can use COPY expressions to perform typecasting and conversion if necessary.

For CHAR/VARCHAR types, specify the max length,

For NUMERIC types, specify the precision and scale.

For Time/Timestamp types (with or without time zone), specify the precision, -1 means unspecified/don't care

For IntervalYM/IntervalDS types, specify the precision and range

For all other types, no length/precision specification needed

Parameters
srvInterfaceInterface to server operations and functionality, including (not-per-column) parameter lookup
perColumnParamReaderPer-column parameters passed into the query
planCtxtContext for storing and retrieving arbitrary data, for use just by this instance of this query. The same context is shared with plan().
argTypesProvides the data types of arguments that this UDT was called with. This may be used to modify the return types accordingly.
returnTypeUser code must fill in the names and data types returned by the UDT.
virtual void Vertica::UDLFactory::getPerInstanceResources ( ServerInterface srvInterface,
VResources res 
)
inlinevirtualinherited

Set the resource required for each instance of the UDX Object subclass. Users should override only one of the following methods.

Parameters
srvInterfacea ServerInterface object used to communicate with Vertica
resa VResources object used to tell Vertica what resources are needed by the UDX

Reimplemented from Vertica::UDXFactory.

Referenced by Vertica::UDLFactory::getPerInstanceResources().

virtual void Vertica::UDLFactory::getPerInstanceResources ( ServerInterface srvInterface,
VResources res,
const SizedColumnTypes inputTypes 
)
inlinevirtualinherited

Set the resource required for each instance of the UDX Object subclass. Users should override only one of the following methods.

Parameters
srvInterfacea ServerInterface object used to communicate with Vertica
resa VResources object used to tell Vertica what resources are needed by the UDX
argTypesProvides the data types of arguments that this UDT was called with

Reimplemented from Vertica::UDXFactory.

UDXFactory::UDXType Vertica::ParserFactory::getUDXFactoryType ( )
inlinevirtual
Returns
the type of UDX Object instance this factory returns.
Note
User subclasses should use the appropriate subclass of UDXFactory and not override this method on their own.

Implements Vertica::UDXFactory.

virtual bool Vertica::ParserFactory::isChunkerApportionable ( ServerInterface srvInterface)
inlinevirtual

Return true if this factory returns a UDChunker that implements alignPortion() and knows what to do with InputState END_OF_PORTION. Such a chunker can start at some offset into a source and chunk just a portion of it.

This does not have to be the same as isParserApportionable() - the two methods can return true/false independent of each other.

virtual bool Vertica::ParserFactory::isParserApportionable ( )
inlinevirtual

Return true if this factory returns an UDParser that knows what to do with InputState START_OF_PORTION and END_OF_PORTION. Such a parser can start at some offset into that source and parse just a portion of it

(this func only called by SDK parsers)

virtual void Vertica::ParserFactory::plan ( ServerInterface srvInterface,
PerColumnParamReader perColumnParamReader,
PlanContext planCtxt 
)
inlinevirtual

Execute any planning logic required at query plan time. This method is run once per query, during query initialization. Its job is to perform parameter validation, and to modify the set of nodes that the COPY statement will run on (through srvInterface).

plan() runs exactly once per query, on the initiator node. If it throws an exception, the query will not proceed; it will be aborted prior to distributing the query to the other nodes and running prepare().

Parameters
srvInterfaceInterface to server operations and functionality, including (not-per-column) parameter lookup
perColumnParamReaderPer-column parameters passed into the query
planCtxtContext for storing and retrieving arbitrary data, for use just by this instance of this query. The same context is shared with plan().
virtual UDParser* Vertica::ParserFactory::prepare ( ServerInterface srvInterface,
PerColumnParamReader perColumnParamReader,
PlanContext planCtxt,
const SizedColumnTypes returnType 
)
pure virtual

Instantiate a UDParser instance. This function will be called on each node, prior to the Load operator starting to execute.

'planData' contains the same data that was placed there by the plan() static method.

Parameters
srvInterfaceInterface to server operations and functionality, including (not-per-column) parameter lookup
perColumnParamReaderPer-column parameters passed into the query
planCtxtContext for storing and retrieving arbitrary data, for use just by this instance of this query. The same context is shared with plan().
returnTypeThe data types of the columns that this Parser must produce
Returns
The UDParser instance to be used by this query