Public Member Functions | |
| void | destroy (ServerInterface srvInterface) throws UdfException |
| abstract StreamState | process (ServerInterface srvInterface, DataBuffer input, InputState input_state, DataBuffer output) throws UdfException |
| void | setup (ServerInterface srvInterface) throws UdfException |
Responsible for reading raw input data from a file and preparing it to be processed by a parser. This preparation may involve decompression, re-encoding, or any other sort of binary manipulation.
| void com.vertica.sdk.UDFilter.destroy | ( | ServerInterface | srvInterface | ) | throws UdfException |
Will be invoked during query execution, after the last time that process() is called on this UDFilter instance for a particular input file.
May optionally be overridden to perform tear-down/destruction.
See UDFilter.setup() for a note about the restartability of UDFilters.
| UdfException |
| abstract StreamState com.vertica.sdk.UDFilter.process | ( | ServerInterface | srvInterface, | |
| DataBuffer | input, | |||
| InputState | input_state, | |||
| DataBuffer | output | |||
| ) | throws UdfException [pure virtual] |
Will be invoked repeatedly during query execution, until it returns DONE or until the query is canceled by the user.
On each invocation, process() is handed some input data and a buffer to write output data into. It is expected to read and process some amount of the input data, write some amount of output data, and return a value that informs Vertica what needs to happen next.
process() must set `input.offset` to the number of bytes that were successfully read from the `input` buffer, and that will not need to be re-consumed by a subsequent invocation of process(). This may not be larger than `input.size`. (`input.size` is the size of the buffer.) If it is set to 0, this indicates that process() cannot process any part of an input buffer of this size, and requires more data per invocation. (For example, a block-based decompression algorithm might return 0 if the input buffer does not contain a complete block.)
Note that `input` may contain null bytes, if the source file contains null bytes. Note also that `input` is NOT automatically null-terminated.
If `input_state` == END_OF_FILE, then the last byte in `input` is the last byte in the input stream. Returning INPUT_NEEDED will not result in any new input appearing. process() should return DONE in this case as soon as this operator has finished producing all output that it is going to produce.
process() must set `output.offset` to the number of bytes that were written to the `output` buffer. This may not be larger than `output.size`. If it is set to 0, this indicates that process() requires a larger output buffer.
Note that, unless OUTPUT_NEEDED is returned, `output` will be UNMODIFIED the next time process() is called. This means that pointers into the buffer will continue to be valid. It also means that `output.offset` may be set. So, in general, process() code should assume that buffers start at `output.buf[output.offset]`. The same goes for `input` and INPUT_NEEDED. Note also that, as a performance optimization, upstream operators may start processing emitted data (data between output.buf[0] and output.buf[output.offset]) before OUTPUT_NEEDED is returned. For this reason, `output.offset` must be strictly increasing.
process() must not block indefinitely. If it cannot proceed for an extended period of time, it should return KEEP_GOING. It will be called again shortly. Failure to do this will, among other things, prevent the query from being canceled by the user.
| UdfException |
| void com.vertica.sdk.UDFilter.setup | ( | ServerInterface | srvInterface | ) | throws UdfException |
Will be invoked during query execution, prior to the first time that process() is called on this UDFilter instance for a particular input file.
May optionally be overridden to perform setup/initialzation.
Note that UDFilters MUST BE RESTARTABLE! If loading large numbers of files, a given UDFilter may be re-used for multiple files. Vertica follows the worker-pool design pattern: At the start of COPY execution, several Parsers and several Filters are instantiated per node, by calling the corresponding prepare() method multiple times. Each Filter/Parser pair is then internally assigned to an initial Source (UDSource or internal). At that point, setup() is called; then process() is called until it is finished; then destroy() is called. If there are still sources in the pool waiting to be processed, then the UDFilter/UDSource pair will be given a second Source; setup() will be called a second time, then process() until it is finished, then destroy(). This repeats until all sources have been read.
| UdfException |