Class UserDefinedFunctionHandler
- java.lang.Object
-
- com.amazonaws.athena.connector.lambda.handlers.UserDefinedFunctionHandler
-
- All Implemented Interfaces:
com.amazonaws.services.lambda.runtime.RequestStreamHandler
- Direct Known Subclasses:
AthenaUDFHandler
,ExampleUserDefinedFuncHandler
public abstract class UserDefinedFunctionHandler extends Object implements com.amazonaws.services.lambda.runtime.RequestStreamHandler
Athena UDF users are expected to extend this class to create UDFs.
-
-
Constructor Summary
Constructors Constructor Description UserDefinedFunctionHandler(String sourceType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doHandleRequest(BlockAllocator allocator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, UserDefinedFunctionRequest req, OutputStream outputStream)
void
handleRequest(InputStream inputStream, OutputStream outputStream, com.amazonaws.services.lambda.runtime.Context context)
protected void
onPing(PingRequest request)
protected Block
processRows(BlockAllocator allocator, Method udfMethod, Block inputRecords, org.apache.arrow.vector.types.pojo.Schema outputSchema)
Processes a group by rows.
-
-
-
Constructor Detail
-
UserDefinedFunctionHandler
public UserDefinedFunctionHandler(String sourceType)
-
-
Method Detail
-
handleRequest
public final void handleRequest(InputStream inputStream, OutputStream outputStream, com.amazonaws.services.lambda.runtime.Context context)
- Specified by:
handleRequest
in interfacecom.amazonaws.services.lambda.runtime.RequestStreamHandler
-
doHandleRequest
protected final void doHandleRequest(BlockAllocator allocator, com.fasterxml.jackson.databind.ObjectMapper objectMapper, UserDefinedFunctionRequest req, OutputStream outputStream) throws Exception
- Throws:
Exception
-
processRows
protected Block processRows(BlockAllocator allocator, Method udfMethod, Block inputRecords, org.apache.arrow.vector.types.pojo.Schema outputSchema) throws Exception
Processes a group by rows. This method takes in a block of data (containing multiple rows), process them and returns multiple rows of the output column in a block.UDF methods are invoked row-by-row in a for loop. Arrow values are converted to Java Objects and then passed into the UDF java method. This is not very efficient because we might potentially be doing a lot of data copying. Advanced users could choose to override this method and directly deal with Arrow data to achieve better performance.
- Parameters:
allocator
- arrow memory allocatorudfMethod
- the extracted java method matching the User-Defined-Function defined in Athena.inputRecords
- input data in Arrow formatoutputSchema
- output data schema in Arrow format- Returns:
- output data in Arrow format
- Throws:
Exception
-
onPing
protected void onPing(PingRequest request)
-
-