-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Java operator descriptors to Scala (#3179)
There are a few operator descriptors written in Java, which makes them difficult to use and maintain. This PR converts all such descriptors to Scala to streamline the migration process to new APIs and facilitate future work, such as operator offloading. Changed Operators: - PythonUDFSourceOpDescV2 - RUDFSourceOpDesc - SentimentAnalysisOpDesc - SpecializedFilterOpDesc - TypeCastingOpDesc
- Loading branch information
1 parent
5b622e3
commit 0414544
Showing
17 changed files
with
312 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
...ow-operator/src/main/scala/edu/uci/ics/amber/operator/filter/SpecializedFilterOpDesc.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
...w-operator/src/main/scala/edu/uci/ics/amber/operator/filter/SpecializedFilterOpDesc.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package edu.uci.ics.amber.operator.filter | ||
|
||
import com.fasterxml.jackson.annotation.{JsonProperty, JsonPropertyDescription} | ||
import edu.uci.ics.amber.core.executor.OpExecInitInfo | ||
import edu.uci.ics.amber.core.workflow.PhysicalOp | ||
import edu.uci.ics.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} | ||
import edu.uci.ics.amber.virtualidentity.{ExecutionIdentity, WorkflowIdentity} | ||
import edu.uci.ics.amber.workflow.{InputPort, OutputPort} | ||
|
||
class SpecializedFilterOpDesc extends FilterOpDesc { | ||
|
||
@JsonProperty(value = "predicates", required = true) | ||
@JsonPropertyDescription("multiple predicates in OR") | ||
var predicates: List[FilterPredicate] = List.empty | ||
|
||
override def getPhysicalOp( | ||
workflowId: WorkflowIdentity, | ||
executionId: ExecutionIdentity | ||
): PhysicalOp = { | ||
PhysicalOp | ||
.oneToOnePhysicalOp( | ||
workflowId, | ||
executionId, | ||
operatorIdentifier, | ||
OpExecInitInfo((_, _) => new SpecializedFilterOpExec(predicates)) | ||
) | ||
.withInputPorts(operatorInfo.inputPorts) | ||
.withOutputPorts(operatorInfo.outputPorts) | ||
} | ||
|
||
override def operatorInfo: OperatorInfo = { | ||
OperatorInfo( | ||
"Filter", | ||
"Performs a filter operation", | ||
OperatorGroupConstants.CLEANING_GROUP, | ||
List(InputPort()), | ||
List(OutputPort()), | ||
supportReconfiguration = true | ||
) | ||
} | ||
} |
21 changes: 0 additions & 21 deletions
21
...ow-operator/src/main/scala/edu/uci/ics/amber/operator/filter/SpecializedFilterOpExec.java
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...w-operator/src/main/scala/edu/uci/ics/amber/operator/filter/SpecializedFilterOpExec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package edu.uci.ics.amber.operator.filter | ||
|
||
import edu.uci.ics.amber.core.tuple.Tuple | ||
|
||
class SpecializedFilterOpExec(predicates: List[FilterPredicate]) extends FilterOpExec { | ||
|
||
setFilterFunc((tuple: Tuple) => predicates.exists(_.evaluate(tuple))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
...low-operator/src/main/scala/edu/uci/ics/amber/operator/typecasting/TypeCastingOpDesc.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
...ow-operator/src/main/scala/edu/uci/ics/amber/operator/typecasting/TypeCastingOpDesc.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package edu.uci.ics.amber.operator.typecasting | ||
|
||
import com.fasterxml.jackson.annotation.{JsonProperty, JsonPropertyDescription} | ||
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaTitle | ||
import edu.uci.ics.amber.core.executor.OpExecInitInfo | ||
import edu.uci.ics.amber.core.tuple.{AttributeTypeUtils, Schema} | ||
import edu.uci.ics.amber.core.workflow.{PhysicalOp, SchemaPropagationFunc} | ||
import edu.uci.ics.amber.operator.map.MapOpDesc | ||
import edu.uci.ics.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} | ||
import edu.uci.ics.amber.virtualidentity.{ExecutionIdentity, WorkflowIdentity} | ||
import edu.uci.ics.amber.workflow.{InputPort, OutputPort, PortIdentity} | ||
|
||
class TypeCastingOpDesc extends MapOpDesc { | ||
|
||
@JsonProperty(required = true) | ||
@JsonSchemaTitle("TypeCasting Units") | ||
@JsonPropertyDescription("Multiple type castings") | ||
var typeCastingUnits: List[TypeCastingUnit] = List.empty | ||
|
||
override def getPhysicalOp( | ||
workflowId: WorkflowIdentity, | ||
executionId: ExecutionIdentity | ||
): PhysicalOp = { | ||
if (typeCastingUnits == null) typeCastingUnits = List.empty | ||
PhysicalOp | ||
.oneToOnePhysicalOp( | ||
workflowId, | ||
executionId, | ||
operatorIdentifier, | ||
OpExecInitInfo((_, _) => new TypeCastingOpExec(typeCastingUnits)) | ||
) | ||
.withInputPorts(operatorInfo.inputPorts) | ||
.withOutputPorts(operatorInfo.outputPorts) | ||
.withPropagateSchema( | ||
SchemaPropagationFunc { inputSchemas: Map[PortIdentity, Schema] => | ||
val outputSchema = typeCastingUnits.foldLeft(inputSchemas.values.head) { (schema, unit) => | ||
AttributeTypeUtils.SchemaCasting(schema, unit.attribute, unit.resultType) | ||
} | ||
Map(operatorInfo.outputPorts.head.id -> outputSchema) | ||
} | ||
) | ||
} | ||
|
||
override def operatorInfo: OperatorInfo = { | ||
OperatorInfo( | ||
"Type Casting", | ||
"Cast between types", | ||
OperatorGroupConstants.CLEANING_GROUP, | ||
List(InputPort()), | ||
List(OutputPort()) | ||
) | ||
} | ||
|
||
override def getOutputSchema(schemas: Array[Schema]): Schema = { | ||
typeCastingUnits.foldLeft(schemas.head) { (schema, unit) => | ||
AttributeTypeUtils.SchemaCasting(schema, unit.attribute, unit.resultType) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.