Moved TaskBuilder to common.

This commit is contained in:
Alexander Nozik 2019-09-12 11:10:15 +03:00
parent 61c2530c91
commit 530b1c1b76
3 changed files with 21 additions and 2 deletions

View File

@ -39,7 +39,7 @@ class AllDataDependency(val placement: Name = EmptyName) : Dependency() {
}
override fun toMeta() = buildMeta {
"data" to "*"
"data" to "@all"
"to" to placement
}
}

View File

@ -14,7 +14,7 @@ import kotlin.reflect.KClass
@TaskBuildScope
class TaskBuilder(val name: String) {
private var modelTransform: TaskModelBuilder.(Meta) -> Unit = { data("*") }
private var modelTransform: TaskModelBuilder.(Meta) -> Unit = { allData() }
var descriptor: NodeDescriptor? = null
private val dataTransforms: MutableList<DataTransformation> = ArrayList()
@ -40,6 +40,20 @@ class TaskBuilder(val name: String) {
this.modelTransform = modelTransform
}
/**
* Add a transformation on untyped data
*/
fun rawTransform(
from: String = "",
to: String = "",
block: TaskEnv.(DataNode<*>) -> DataNode<*>
) {
dataTransforms += DataTransformation(from, to){context, model, data->
val env = TaskEnv(EmptyName, model.meta, context)
env.block(data)
}
}
fun <T : Any> transform(
inputType: KClass<out T>,
from: String = "",

View File

@ -0,0 +1,5 @@
package hep.dataforge.workspace
//fun <T1: Any, T2: Any, R: Any> TaskBuilder.zip(
// val firstNo
//) = rawTransform { }