diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/Operator.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/Operator.kt index f241ea25..bb35c35b 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/Operator.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/Operator.kt @@ -7,9 +7,13 @@ import kotlinx.coroutines.flow.Flow * A basic implementation of a pipeline-able operator. * * @author Ralph Gasser - * @version 1.0.0 + * @version 1.1.0 */ sealed interface Operator { + /** + * Returns root of this [Unary]. + */ + fun root(): Operator<*> /** * Converts this [Operator] to a [Flow] of type [O]. @@ -22,7 +26,12 @@ sealed interface Operator { /** * A nullary operator (usually a source). */ - interface Nullary: Operator + interface Nullary: Operator { + /** + * Returns root of this [Nullary] (which is this). + */ + override fun root(): Operator<*> = this + } /** * A unary [Operator] with one input [Operator] and one output [Operator]. @@ -30,6 +39,11 @@ sealed interface Operator { interface Unary: Operator { /** The input [Operator]. */ val input: Operator + + /** + * Returns root of this [Unary]. + */ + override fun root(): Operator<*> = this.input.root() } /** @@ -41,6 +55,11 @@ sealed interface Operator { /** The input [Operator]. */ val input2: Operator + + /** + * Returns root of this [Unary], which is the left-hand operator (by definition). + */ + override fun root(): Operator<*> = this.input1.root() } /** @@ -49,6 +68,11 @@ sealed interface Operator { interface NAry: Operator { /** The input [Operator]s. */ val inputs: List> + + /** + * Returns root of this [Unary], which is the left-hand operator (by definition). + */ + override fun root(): Operator<*> = this.inputs.first().root() } /** @@ -57,5 +81,10 @@ sealed interface Operator { interface Sink: Operator { /** The input [Operator]. */ val input: Operator + + /** + * Returns root of this [Unary], which is the left-hand operator (by definition). + */ + override fun root(): Operator<*> = this.input.root() } } \ No newline at end of file