diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-03-05 13:23:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 13:23:57 +0100 |
| commit | 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (patch) | |
| tree | 5b2773b8dc21c2e1b526fb70f829c376dd80532a /opendc-trace/opendc-trace-calcite/src/main | |
| parent | d28002a3c151d198298574312f32f1cb43f3a660 (diff) | |
Updated package versions, updated web server tests. (#207)
* Updated all package versions including kotlin. Updated all web-server tests to run.
* Changed the java version of the tests. OpenDC now only supports java 19.
* small update
* test update
* new update
* updated docker version to 19
* updated docker version to 19
Diffstat (limited to 'opendc-trace/opendc-trace-calcite/src/main')
5 files changed, 77 insertions, 41 deletions
diff --git a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceReaderEnumerator.kt b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceReaderEnumerator.kt index 74bd188b..eed52ab3 100644 --- a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceReaderEnumerator.kt +++ b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceReaderEnumerator.kt @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean internal class TraceReaderEnumerator<E>( private val reader: TableReader, private val columns: List<TableColumn>, - private val cancelFlag: AtomicBoolean + private val cancelFlag: AtomicBoolean, ) : Enumerator<E> { private val columnIndices = columns.map { reader.resolve(it.name) }.toIntArray() private var current: E? = null @@ -80,7 +80,11 @@ internal class TraceReaderEnumerator<E>( return res } - private fun convertColumn(reader: TableReader, column: TableColumn, columnIndex: Int): Any? { + private fun convertColumn( + reader: TableReader, + column: TableColumn, + columnIndex: Int, + ): Any? { return when (column.type) { is TableColumnType.Boolean -> reader.getBoolean(columnIndex) is TableColumnType.Int -> reader.getInt(columnIndex) diff --git a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceSchemaFactory.kt b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceSchemaFactory.kt index 3c6badc8..cbf7ec43 100644 --- a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceSchemaFactory.kt +++ b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceSchemaFactory.kt @@ -36,7 +36,11 @@ import java.nio.file.Paths * This factory allows users to include a schema that references a trace in a `model.json` file. */ public class TraceSchemaFactory : SchemaFactory { - override fun create(parentSchema: SchemaPlus, name: String, operand: Map<String, Any>): Schema { + override fun create( + parentSchema: SchemaPlus, + name: String, + operand: Map<String, Any>, + ): Schema { val base = operand[ModelHandler.ExtraOperand.BASE_DIRECTORY.camelName] as File? val pathParam = requireNotNull(operand["path"]) { "Trace path not specified" } as String val path = if (base != null) File(base, pathParam).toPath() else Paths.get(pathParam) diff --git a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTable.kt b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTable.kt index 2dd02710..e74d2ee8 100644 --- a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTable.kt +++ b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTable.kt @@ -71,7 +71,11 @@ internal class TraceTable(private val table: org.opendc.trace.Table) : return rowType } - override fun scan(root: DataContext, filters: MutableList<RexNode>, projects: IntArray?): Enumerable<Array<Any?>> { + override fun scan( + root: DataContext, + filters: MutableList<RexNode>, + projects: IntArray?, + ): Enumerable<Array<Any?>> { // Filters are currently not supported by the OpenDC trace API. By keeping the filters in the list, Calcite // assumes that they are declined and will perform the filters itself. @@ -130,14 +134,18 @@ internal class TraceTable(private val table: org.opendc.trace.Table) : return rowCount } - override fun <T> asQueryable(queryProvider: QueryProvider, schema: SchemaPlus, tableName: String): Queryable<T> { + override fun <T> asQueryable( + queryProvider: QueryProvider, + schema: SchemaPlus, + tableName: String, + ): Queryable<T> { return object : AbstractTableQueryable<T>(queryProvider, schema, this@TraceTable, tableName) { override fun enumerator(): Enumerator<T> { val cancelFlag = AtomicBoolean(false) return TraceReaderEnumerator( this@TraceTable.table.newReader(), this@TraceTable.table.columns, - cancelFlag + cancelFlag, ) } @@ -155,7 +163,7 @@ internal class TraceTable(private val table: org.opendc.trace.Table) : operation: TableModify.Operation, updateColumnList: MutableList<String>?, sourceExpressionList: MutableList<RexNode>?, - flattened: Boolean + flattened: Boolean, ): TableModify { cluster.planner.addRule(TraceTableModifyRule.DEFAULT.toRule()) @@ -166,7 +174,7 @@ internal class TraceTable(private val table: org.opendc.trace.Table) : operation, updateColumnList, sourceExpressionList, - flattened + flattened, ) } @@ -184,7 +192,10 @@ internal class TraceTable(private val table: org.opendc.trace.Table) : return typeFactory.createStructType(types, names) } - private fun mapType(typeFactory: JavaTypeFactory, type: TableColumnType): RelDataType { + private fun mapType( + typeFactory: JavaTypeFactory, + type: TableColumnType, + ): RelDataType { return when (type) { is TableColumnType.Boolean -> typeFactory.createSqlType(SqlTypeName.BOOLEAN) is TableColumnType.Int -> typeFactory.createSqlType(SqlTypeName.INTEGER) diff --git a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModify.kt b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModify.kt index cc23854f..eedff00d 100644 --- a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModify.kt +++ b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModify.kt @@ -59,7 +59,7 @@ internal class TraceTableModify( operation: Operation, updateColumnList: List<String>?, sourceExpressionList: List<RexNode>?, - flattened: Boolean + flattened: Boolean, ) : TableModify(cluster, traitSet, table, schema, input, operation, updateColumnList, sourceExpressionList, flattened), EnumerableRel { init { @@ -67,7 +67,10 @@ internal class TraceTableModify( table.unwrap(ModifiableTable::class.java) ?: throw AssertionError() // TODO: user error in validator } - override fun copy(traitSet: RelTraitSet, inputs: List<RelNode>?): RelNode { + override fun copy( + traitSet: RelTraitSet, + inputs: List<RelNode>?, + ): RelNode { return TraceTableModify( cluster, traitSet, @@ -77,40 +80,48 @@ internal class TraceTableModify( operation, updateColumnList, sourceExpressionList, - isFlattened + isFlattened, ) } - override fun computeSelfCost(planner: RelOptPlanner, mq: RelMetadataQuery?): RelOptCost { + override fun computeSelfCost( + planner: RelOptPlanner, + mq: RelMetadataQuery?, + ): RelOptCost { // Prefer this plan compared to the standard EnumerableTableModify. return super.computeSelfCost(planner, mq)!!.multiplyBy(.1) } - override fun implement(implementor: EnumerableRelImplementor, pref: Prefer): EnumerableRel.Result { + override fun implement( + implementor: EnumerableRelImplementor, + pref: Prefer, + ): EnumerableRel.Result { val builder = BlockBuilder() val result = implementor.visitChild(this, 0, getInput() as EnumerableRel, pref) val childExp = builder.append("child", result.block) - val convertedChildExpr = if (getInput().rowType != rowType) { - val typeFactory = cluster.typeFactory as JavaTypeFactory - val format = EnumerableTableScan.deduceFormat(table) - val physType = PhysTypeImpl.of(typeFactory, table.rowType, format) - val childPhysType = result.physType - val o = Expressions.parameter(childPhysType.javaRowType, "o") - val expressionList = List(childPhysType.rowType.fieldCount) { i -> - childPhysType.fieldReference(o, i, physType.getJavaFieldType(i)) - } + val convertedChildExpr = + if (getInput().rowType != rowType) { + val typeFactory = cluster.typeFactory as JavaTypeFactory + val format = EnumerableTableScan.deduceFormat(table) + val physType = PhysTypeImpl.of(typeFactory, table.rowType, format) + val childPhysType = result.physType + val o = Expressions.parameter(childPhysType.javaRowType, "o") + val expressionList = + List(childPhysType.rowType.fieldCount) { i -> + childPhysType.fieldReference(o, i, physType.getJavaFieldType(i)) + } - builder.append( - "convertedChild", - Expressions.call( - childExp, - BuiltInMethod.SELECT.method, - Expressions.lambda<org.apache.calcite.linq4j.function.Function<*>>(physType.record(expressionList), o) + builder.append( + "convertedChild", + Expressions.call( + childExp, + BuiltInMethod.SELECT.method, + Expressions.lambda<org.apache.calcite.linq4j.function.Function<*>>(physType.record(expressionList), o), + ), ) - ) - } else { - childExp - } + } else { + childExp + } if (!isInsert) { throw UnsupportedOperationException("Deletion and update not supported") @@ -126,10 +137,10 @@ internal class TraceTableModify( Long::class.java, expression, INSERT_METHOD, - convertedChildExpr - ) - ) - ) + convertedChildExpr, + ), + ), + ), ) val rowFormat = if (pref === Prefer.ARRAY) JavaRowFormat.ARRAY else JavaRowFormat.SCALAR diff --git a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModifyRule.kt b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModifyRule.kt index 7572e381..9c560984 100644 --- a/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModifyRule.kt +++ b/opendc-trace/opendc-trace-calcite/src/main/kotlin/org/opendc/trace/calcite/TraceTableModifyRule.kt @@ -52,14 +52,20 @@ internal class TraceTableModifyRule(config: Config) : ConverterRule(config) { modify.operation, modify.updateColumnList, modify.sourceExpressionList, - modify.isFlattened + modify.isFlattened, ) } companion object { /** Default configuration. */ - val DEFAULT: Config = Config.INSTANCE - .withConversion(LogicalTableModify::class.java, Convention.NONE, EnumerableConvention.INSTANCE, "TraceTableModificationRule") - .withRuleFactory { config: Config -> TraceTableModifyRule(config) } + val DEFAULT: Config = + Config.INSTANCE + .withConversion( + LogicalTableModify::class.java, + Convention.NONE, + EnumerableConvention.INSTANCE, + "TraceTableModificationRule", + ) + .withRuleFactory { config: Config -> TraceTableModifyRule(config) } } } |
