Documentation ¶
Overview ¶
Package datarecording offers functionality in writing data from each simulation experiment into a databse
Example ¶
package main import ( "fmt" "os" "github.com/sarchlab/akita/v4/datarecording" ) type Task struct { id int name string } func main() { dbPath := "test" writer := datarecording.NewSQLiteWriter(dbPath) writer.Init() reader := datarecording.NewSQLiteReader(dbPath) reader.Init() cleanup := func() { writer.DB.Close() reader.DB.Close() os.Remove(dbPath + ".sqlite3") } defer cleanup() task1 := Task{1, "task1"} writer.CreateTable("test_table", task1) task2 := Task{2, "task2"} writer.InsertData("test_table", task2) tables := reader.ListTables() fmt.Printf("The stored table: %s", tables) }
Output: Table test_table created successfully Data is successfully inserted The stored table: [test_table]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataRecorder ¶
type DataRecorder interface { // Init establishes a connection to the database Init() // CreateTable creates a new table with given filename CreateTable(table string, sampleEntry any) // DataInsert writes a same-type task into table that already exists InsertData(table string, entry any) // ListTable returns a slice containing names of all tables ListTables() []string // Flush flushes all the baffered task into database Flush() }
DataRecorder is a backend that can record and store data
type SQLiteReader ¶
SQLiteReader is a reader that reads trace data from a SQLite database.
func NewSQLiteReader ¶
func NewSQLiteReader(filename string) *SQLiteReader
NewSQLiteReader creates a new SQLiteTraceReader.
func (*SQLiteReader) Init ¶
func (r *SQLiteReader) Init()
Init establishes a connection to the database.
func (*SQLiteReader) ListTables ¶
func (r *SQLiteReader) ListTables() []string
ListTables returns a slice containing names of all tables
type SQLiteWriter ¶
SQLiteWriter is the writer that writes data into SQLite database
func NewSQLiteWriter ¶
func NewSQLiteWriter(path string) *SQLiteWriter
NewSQLiteWriter creates a new SQLiteWriter.
func (*SQLiteWriter) CreateTable ¶
func (t *SQLiteWriter) CreateTable(table string, sampleEntry any)
func (*SQLiteWriter) Flush ¶
func (t *SQLiteWriter) Flush()
func (*SQLiteWriter) Init ¶
func (t *SQLiteWriter) Init()
Init establishes a connection to the databse
func (*SQLiteWriter) InsertData ¶
func (t *SQLiteWriter) InsertData(table string, entry any)
Click to show internal directories.
Click to hide internal directories.