summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-21 11:34:34 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-21 11:34:34 +0200
commit68ef3700ed2f69bcf0118bb69eda71e6b1f4d54f (patch)
tree73201888564accde4cfa107f4ffdb15e9f93d45c /opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi
parentc7fff03408ee3109d0a39a96c043584a2d8f67ca (diff)
feat(trace): Add support for writing traces
This change adds a new API for writing traces in a trace format. Currently, writing is only supported by the OpenDC VM format, but over time the other formats will also have support for writing added.
Diffstat (limited to 'opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi')
-rw-r--r--opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt21
1 files changed, 21 insertions, 0 deletions
diff --git a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt
index e04dd948..f2e610db 100644
--- a/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt
+++ b/opendc-trace/opendc-trace-api/src/main/kotlin/org/opendc/trace/spi/TraceFormat.kt
@@ -23,6 +23,7 @@
package org.opendc.trace.spi
import org.opendc.trace.TableReader
+import org.opendc.trace.TableWriter
import java.nio.file.Path
import java.util.*
@@ -36,6 +37,15 @@ public interface TraceFormat {
public val name: String
/**
+ * Construct an empty trace at [path].
+ *
+ * @param path The path where to create the empty trace.
+ * @throws IllegalArgumentException If [path] is invalid.
+ * @throws UnsupportedOperationException If the table does not support trace creation.
+ */
+ public fun create(path: Path)
+
+ /**
* Return the name of the tables available in the trace at the specified [path].
*
* @param path The path to the trace.
@@ -64,6 +74,17 @@ public interface TraceFormat {
public fun newReader(path: Path, table: String): TableReader
/**
+ * Open a [TableWriter] for the specified [table].
+ *
+ * @param path The path to the trace to open.
+ * @param table The name of the table to open a [TableWriter] for.
+ * @throws IllegalArgumentException If [table] does not exist.
+ * @throws UnsupportedOperationException If the format does not support writing.
+ * @return A [TableWriter] instance for the table.
+ */
+ public fun newWriter(path: Path, table: String): TableWriter
+
+ /**
* A helper object for resolving providers.
*/
public companion object {