src/Contracts.scala
1// Private, minimal embedding contracts for the vendored EcoFlow algorithms.
2// This does not embed PiFlow's scheduler, server, checkpointing or configuration system.
3package cn.piflow {
4
5 import org.apache.spark.sql.{DataFrame,SparkSession}
6 trait ProcessContext
7 trait JobContext { def get[T]()(implicit m:Manifest[T]):T }
8 trait JobInputStream { def read():DataFrame; def read(port:String):DataFrame }
9 trait JobOutputStream { def write(data:DataFrame):Unit }
10}
11package cn.piflow.conf {
12 import cn.piflow._
13 import cn.piflow.conf.bean.PropertyDescriptor
14 abstract class ConfigurableStop extends Serializable {
15 val authorEmail:String
16 val description:String
17 val inportList:List[String]
18 val outportList:List[String]
19 def setProperties(p:Map[String,Any]):Unit
20 def perform(in:JobInputStream,out:JobOutputStream,ctx:JobContext):Unit
21 def initialize(ctx:ProcessContext):Unit
22 def getPropertyDescriptor():List[PropertyDescriptor]
23 def getIcon():Array[Byte]
24 def getGroup():List[String]
25 }
26 object Port { val DefaultPort="Default"; val LeftPort="Left"; val RightPort="Right" }
27 object StopGroup { val ExcelGroup="Excel"; val CleanGroup="Clean" }
28}
29package cn.piflow.conf.bean {
30 final class PropertyDescriptor {
31 def name(v:String):this.type=this
32 def displayName(v:String):this.type=this
33 def description(v:String):this.type=this
34 def defaultValue(v:String):this.type=this
35 def required(v:Boolean):this.type=this
36 def example(v:String):this.type=this
37 def allowableValues(v:Set[String]):this.type=this
38 }
39}
40package cn.piflow.conf.util {
41 object MapUtil { def get(map:Map[String,Any],key:String):Any=map.getOrElse(key,throw new IllegalArgumentException("missing parameter: "+key)) }
42 object ImageUtil { def getImage(path:String,cls:String=""):Array[Byte]=Array.emptyByteArray }
43}