Combining Cooperative Parse and Apportioned Load
You can enable both Cooperative Parse and Apportioned Load in the same parser, allowing Vertica to decide how to load data.
Deciding How to Divide a Load
Vertica uses apportioned load, where possible, at query-planning time. It decides whether to also use cooperative parse at execution time.
Apportioned load requires SourceFactory
support. Given a suitable UDSource
, at planning time Vertica calls the isParserApportionable()
method on the ParserFactory
. If this method returns true
, Vertica apportions the load.
If isParserApportionable()
returns false
but isChunkerApportionable()
returns true
, then a chunker is available for cooperative parse and that chunker supports apportioned load. Vertica apportions the load.
If neither of these methods returns true
, then Vertica does not apportion the load.
At execution time, Vertica first checks whether the load is running in unfenced mode and proceeds only if it is. Cooperative parse is not supported in fenced mode.
If the load is not apportioned, and more than one thread is available, Vertica uses cooperative parse.
If the load is apportioned, and exactly one thread is available, Vertica uses cooperative parse if and only if the parser is not apportionable. In this case, the chunker is apportionable but the parser is not.
If the load is apportioned, and more than one thread is available, and the chunker is apportionable, Vertica uses cooperative parse.
If Vertica uses cooperative parse but prepareChunker()
does not return a UDChunker
instance, Vertica reports an error.
Executing Apportioned, Cooperative Loads
If a load uses both apportioned load and cooperative parse, Vertica uses the SourceFactory
to break the input into portions. It then assigns the portions to execution nodes. See How Vertica Apportions a Load.
On the execution node, Vertica calls the chunker's alignPortion()
method to align the input with portion boundaries. (This step is skipped for the first portion, which by definition is already aligned at the beginning.) This step is necessary because a parser using apportioned load sometimes has to read beyond the end of the portion, so a chunker needs to find the end point.
After aligning the portion, Vertica calls the chunker's process()
method repeatedly. See How Vertica Divides a Load.
The chunks found by the chunker are then sent to the parser's process()
method for processing in the usual way.