Overriding the Cancel Method
Your User-Defined Transform Function (UDTF) can override the TransformFunction.cancel
method that Vertica calls if the query that called the function has been canceled. You should override this method to perform an orderly shutdown of any additional processing that your UDx spawned. For example, you can have your cancel
method shut down threads that your UDTF has spawned or signal a third-party library that it needs to stop processing and exit. Your cancel
method must leave your UDTF's function class ready to be destroyed, since Vertica calls the UDx's destroy
method after the cancel
method has exited.
Notes
- If your UDTF does not override
cancel
, Vertica assumes your UDTF does not need to perform any special cancel processing and calls the function class'sdestroy
method to have it free any resources. - Your
cancel
method is called from a different thread than the thread running your UDx'sprocessPartition
function. - The call to the
cancel
method is not synchronized in any way with your UDTF'sprocessPartition
method. If you need yourprocessPartition
function to exit before yourcancel
method performs some action (killing threads, for example) you need to have the two methods synchronize their actions. - If your
cancel
method runs for too long, Vertica kills the JVM side process your UDx.