|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
Function
interface provides a way to inject custom logic
into a connector, where it can be executed close to the actual data and where it can make decisions about
what changes should be made to the content.
See:
Description
Interface Summary | |
---|---|
FunctionContext | The context in which a Function is executed. |
Class Summary | |
---|---|
Function | A serializable function that is to be called within a connector during a single atomic operation. |
The Function
interface provides a way to inject custom logic
into a connector, where it can be executed close to the actual data and where it can make decisions about
what changes should be made to the content. The FunctionContext
interface encapsulates the context in which a function is run
, including
the input parameters, output parameters, location in the graph, and ways of building and executing other
requests.
To use a Function
, simply subclass it, implement the
Function.run(FunctionContext)
method, and then used it
via the Graph API
, either through direct (immediately) interaction:
Graph graph = ... Function myFunction = ... Mapor via batch invocation:output = graph.applyFunction(myFunction) .with("a","val1") .and("b",3) .to("/"); Object count = output.get("count");
Graph graph = ... Function myFunction = ... Graph.Batch batch = graph.batch(); batch.applyFunction(myFunction) .with("a","val1") .and("b",3) .to("/") .and() .read("/myNode"); Results results = batch.execute(); Listrequests = results.getRequests(); FunctionRequest functRequest = requests.get(0); ReadNodeRequest readRequest = requests.get(1); // use the results in the requests ... long count = functRequest.output("success",PropertyType.LONG,new Long(0)).longValue(); for ( Property prop : readRequest.getProperties() ) { // do something ... }
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |