diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-10-11 11:47:39 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-10-25 16:42:27 +0200 |
| commit | c4ce5ebb7de6494cb8d90076cba8596aa0cbabeb (patch) | |
| tree | 13756bd08650c0e41e24132b8dab0fad327ddf31 /opendc-trace/opendc-trace-api/src/main/kotlin | |
| parent | ff94e63d5f80df317505c7ae0c6a5465f9a0c1f5 (diff) | |
feat(trace): Support conversion from Azure trace format
This change adds support for converting the Azure VM traces into the
OpenDC trace format.
Diffstat (limited to 'opendc-trace/opendc-trace-api/src/main/kotlin')
| -rw-r--r-- | opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/util/CompositeTableReader.kt | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/util/CompositeTableReader.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/util/CompositeTableReader.kt index dafc0798..11e032c7 100644 --- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/util/CompositeTableReader.kt +++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/util/CompositeTableReader.kt @@ -46,11 +46,7 @@ public abstract class CompositeTableReader : TableReader { protected abstract fun nextReader(): TableReader? override fun nextRow(): Boolean { - if (!hasStarted) { - assert(delegate == null) { "Duplicate initialization" } - delegate = nextReader() - hasStarted = true - } + tryStart() var delegate = delegate @@ -68,6 +64,8 @@ public abstract class CompositeTableReader : TableReader { } override fun resolve(column: TableColumn<*>): Int { + tryStart() + val delegate = delegate return delegate?.resolve(column) ?: -1 } @@ -107,4 +105,15 @@ public abstract class CompositeTableReader : TableReader { } override fun toString(): String = "CompositeTableReader" + + /** + * Try to obtain the initial delegate. + */ + private fun tryStart() { + if (!hasStarted) { + assert(delegate == null) { "Duplicate initialization" } + delegate = nextReader() + hasStarted = true + } + } } |
