-
Notifications
You must be signed in to change notification settings - Fork 75
How to integrate a new operator into Texera
Oliver Chen edited this page Jul 5, 2018
·
3 revisions
Here we only talk about operator that does operation on retrieved data from source operator(e.g. sentiment analytics). This tutorial will not be suitable for source operator and result operator.
- This class will be used to generate your operator object. It should extend from predicateBase. You need to add your predicate class to predicateBase file first.
- The constructor of this predicate class should take all attributes you want your operator to take from the webpage(e.g. inputAttributeName/resultAttributeName), and store them.
- For each parameter of constructor, you'll want a method to return this argument for your operator class to use.
- The predicate class should have a newOperator method, which constructs and returns a new operator object using this predicate object. E.g.
public dummyOperator newOperator() { return new dummyOperator(this); }
- Write a getOperatorMetadata method to specify group and description of your operator. Use
ImmutableMap.<~>builder
to do it.
- This class should extend from one of the classes from
api/src/main/java/edu/uci/ics/texera/api/dataflow
- This class should have a constructor which takes a predicate object and stores it.
- This class should have a
setInputOperator
method, which specifies the previous operator(inputOperator). - This class should have a
open
method, which sets our inputSchema to be the inputOperator's ourputSchema and transforms our inputSchema into appropriate outputSchema. Then methodopen
sets the cursor toOPENED
. - This class should have a
getNextTuple
method, which callsgetNextTuple
of the inputOperator to get data from previous step; does operation on this data; adds generated field to the end if necessary; and returns the tuple. - This class should have a
close
method to set the cursor toCLOSED
. - This class should have a
transformToOutputSchema
method, which takes inputSchema, modifies it, and returns the outputSchema.
- Open
dataflow/src/main/java/edu/uci/ics/texera/api/dataflow/common/JsonSchemaHelper.java
- Comment the first line in
main
function - Uncomment the second line in
main
function - Change the parameter to your predicate class
- Run it, a schema should appear in the directory of your predicate class
It is a good idea to write a test function for your operator in dataflow/src/main/java/edu/uci/ics/texera/api/dataflow/common/PredicateBaseTest.java
- Add html element to
core/gui/app/operatorbar/operator-bar.component.html
, and set an unique id to it - Add relevant code to
core/gui/app/services/mock-data.ts
, remember to specify your operator's id at the bottom of the file - Add relevant code to
dataflow/src/main/java/edu/uci/ics/texera/dataflow/plangen/OperatorArityConstants.java
Use Running Texera GUI to compile and run backend/frontend