ddlog
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package ddlog contains Go bindings for the DDlog C API.
Index¶
- Variables
- func DefaultErrMsgPrinter(msg string)
- func SetErrMsgPrinter(errMsgPrinter ErrMsgPrinter)
- type CString
- type Command
- type ErrMsgPrinter
- type OutRecordDumper
- type OutRecordHandler
- type OutRecordSink
- type Program
- func (p *Program) ApplyUpdate(command Command) error
- func (p *Program) ApplyUpdates(commands ...Command) error
- func (p *Program) ApplyUpdatesAsTransaction(commands ...Command) error
- func (p *Program) ClearRelation(tableID TableID) error
- func (p *Program) CommitTransaction() error
- func (p *Program) CommitTransactionChangesAsArray() error
- func (p *Program) DumpInputSnapshot(name string) error
- func (p *Program) GetTableID(name string) TableID
- func (p *Program) GetTableName(tableID TableID) string
- func (p *Program) GetTableOriginalName(name string) string
- func (p *Program) RollbackTransaction() error
- func (p *Program) StartRecordingCommands(name string) error
- func (p *Program) StartTransaction() error
- func (p *Program) Stop() error
- func (p *Program) StopRecordingCommands() error
- type Record
- func NewRecordBool(v bool) Record
- func NewRecordI32(v int32) Record
- func NewRecordI64(v int64) Record
- func NewRecordLeft(r Record) Record
- func NewRecordNone() Record
- func NewRecordNull() Record
- func NewRecordRight(r Record) Record
- func NewRecordSome(r Record) Record
- func NewRecordString(v string) Record
- func NewRecordU128(v uint128.Uint128) Record
- func NewRecordU32(v uint32) Record
- func NewRecordU64(v uint64) Record
- type RecordMap
- type RecordSet
- type RecordStruct
- type RecordTuple
- type RecordVector
- type TableID
Constants¶
This section is empty.
Variables¶
var (// StdSomeConstructor is a static string for the "std.Some" DDlog constructor.StdSomeConstructor =NewCString("std.Some")// StdNoneConstructor is a static string for the "std.None" DDlog constructor.StdNoneConstructor =NewCString("std.None")// StdLeftConstructor is a static string for the "std.Left" DDlog constructor.StdLeftConstructor =NewCString("std.Left")// StdRightConstructor is a static string for the "std.Right" DDlog constructor.StdRightConstructor =NewCString("std.Right"))
Functions¶
funcDefaultErrMsgPrinter¶
func DefaultErrMsgPrinter(msgstring)
DefaultErrMsgPrinter is the default printer used to display DDlog error messages. It prints themessages to stderr. Override it by calling SetErrMsgPrinter.
funcSetErrMsgPrinter¶
func SetErrMsgPrinter(errMsgPrinterErrMsgPrinter)
SetErrMsgPrinter overrides the default error message printer used to display DDlog errormessages. An errMsgPrinter set to nil be cause all error messages to be dropped. Concurrent callsto the provided errMsgPrinter will be sequential.
Types¶
typeCString¶
type CString struct {// contains filtered or unexported fields}CString is a wrapper around a C string. This is useful when you want to pre-allocate a "static"string once and use it multiple times, as it avoids multiple calls to C.CString / copies.
funcNewCString¶
NewCString creates a new CString. It invokes C.CString which allocates a C string in the C heapusing malloc and copies the contents of the Go string to that location. Because this is a "Cpointer", it is not subject to the restrictions of Go pointers(https://golang.org/cmd/cgo/#hdr-Passing_pointers). It is the caller's responsibility to releasethe allocated memory by calling Free.
typeCommand¶
type Command struct {// contains filtered or unexported fields}Command is a wrapper around a DDlog command (ddlog_cmd *). Creating a Command with one of thefunctions below will never fail; however the command it creates may fail to execute.
funcNewDeleteKeyCommand¶
NewDeleteKeyCommand creates a delete-by-key command. tableID must have a primary key for thiscommand to work.
funcNewDeleteValCommand¶
NewDeleteValCommand creates a delete-by-value command.
funcNewInsertCommand¶
NewInsertCommand creates an insert command.
funcNewInsertOrUpdateCommand¶
NewInsertOrUpdateCommand creates an insert-or-update command.
typeErrMsgPrinter¶
type ErrMsgPrinter func(msgstring)
ErrMsgPrinter is the function type for the user-provided printer which will be invoked every timeDDlog generates an error.
typeOutRecordDumper¶
type OutRecordDumper struct {// contains filtered or unexported fields}OutRecordDumper implements the OutRecordHandler interface: use it to log all the changes receivedfrom DDlog to a file.
funcNewOutRecordDumper¶
func NewOutRecordDumper(changesFileNamestring) (*OutRecordDumper,error)
NewOutRecordDumper creates an OutRecordDumper instance.
funcNewOutRecordStdoutDumper¶
func NewOutRecordStdoutDumper() (*OutRecordDumper,error)
NewOutRecordStdoutDumper creates an OutRecordDumper instance which writes all the changesreceived from DDlog to stdout.
typeOutRecordHandler¶
type OutRecordHandler interface {// Handle is called for every change reported by DDlog. There will a call to Handle for each// new or deleted record (there is no notion of "modified" output record in DDlog). Handle// will be called exactly once for each new / deleted record.Handle(*Program,TableID,Record,int64)}OutRecordHandler defines an interface which lets the client register a "callback" (when creatinga Program) for DDlog changes.
typeOutRecordSink¶
type OutRecordSink struct{}OutRecordSink implements the OutRecordHandler interface: use it to discard all the changesreceived from DDlog.
funcNewOutRecordSink¶
func NewOutRecordSink() (*OutRecordSink,error)
NewOutRecordSink creates an OutRecordSink instance.
typeProgram¶
type Program struct {// contains filtered or unexported fields}Program is an instance of a DDlog program. It corresponds to ddlog_prog struct in the C API.
funcNewProgram¶
func NewProgram(workersuint, outRecordHandlerOutRecordHandler) (*Program,error)
NewProgram creates a new instance of a DDlog Program. workers is the number of worker threadsthat DDlog is allowed to use. outRecordHandler implements the Handle method, which will be calledevery time an output record is created / deleted. If workers is greater than 1, Handle can becalled concurrently from multiple worker threads.
func (*Program)ApplyUpdate¶
ApplyUpdate applies a single update to DDlog tables. Must be called as part of a transaction.
func (*Program)ApplyUpdates¶
ApplyUpdates applies updates to DDlog tables. Must be called as part of a transaction.
func (*Program)ApplyUpdatesAsTransaction¶
ApplyUpdatesAsTransaction starts a transaction, applies updates to DDlog tables and commits thetransaction.
func (*Program)ClearRelation¶
ClearRelation clears all input relations in the provided table.
func (*Program)CommitTransaction¶
CommitTransaction commits a transaction.
func (*Program)CommitTransactionChangesAsArray¶
CommitTransactionChangesAsArray commits a transaction. It uses a different implementation fromCommitTransaction, which may yield better performance when many output records aregenerated. Unlike with CommitTransaction, DDlog will not generate one callback for each outputrecord, but will return an array of output records (with weight). Note that we still generateone OutRecordHandler callback for each output record.
func (*Program)DumpInputSnapshot¶
DumpInputSnapshot dumps current snapshot of input tables to the provided file in a formatsuitable for replay debugging.
func (*Program)GetTableID¶
GetTableID gets the table id by name.
func (*Program)GetTableName¶
GetTableName gets the table name by id.
func (*Program)GetTableOriginalName¶
GetTableOriginalName gets the table's original name, if the relationhad an 'original=\"name\"' annotation. Otherwise it returnsthe table name itself (if it is a legal table name).
func (*Program)RollbackTransaction¶
RollbackTransaction rollbacks an ongoing transaction.
func (*Program)StartRecordingCommands¶
StartRecordingCommands creates a file with the provided name to record all the commands sent toDDlog. If the file already exists, it will be truncated.
func (*Program)StartTransaction¶
StartTransaction starts a transaction. Note that DDlog does not support nested or concurrenttransactions.
func (*Program)Stop¶
Stop stops the DDlog program and deallocates all the resources allocated by DDlog.
func (*Program)StopRecordingCommands¶
StopRecordingCommands stops recording the commands sent to DDlog to file and closes the file.
typeRecord¶
type Record interface {// Free releases the memory associated with a given record. Do not call this method if// ownership of the record has already been transferred to DDlog (e.g. by adding the record// to a command).Free()// Dump returns a string representation of a record.Dump()string// IsNull returns true iff the record is NULL.IsNull()bool// IsBool returns true iff the record is a boolean record.IsBool()bool// IsInt returns true iff the record is an integer record.IsInt()bool// IsString returns true iff the record is a string record.IsString()bool// IsTuple returns true iff the record is a tuple record.IsTuple()bool// IsVector returns true iff the record is a vector record.IsVector()bool// IsMap returns true iff the record is a map record.IsMap()bool// IsSet returns true iff the record is a set record.IsSet()bool// IsStruct returns true iff the record is a struct record.IsStruct()bool// IntBits returns the minimum number of bits required to represent the record if it is an// integer record. It returns 0 if the record is not an integer record.IntBits()int// ToBool returns the value of a boolean record. Behavior is undefined if the record is not// a boolean.ToBool()bool// ToBoolSafe returns the value of a boolean record. Returns an error if the record is not a// boolean.ToBoolSafe() (bool,error)// ToU128 returns the value of an integer record as a Uint128. Behavior is undefined if the// record is not an integer or if its value does not fit into 128 bits.ToU128()uint128.Uint128// ToU128Safe returns the value of an integer record as a Uint128. Returns an error if the// record is not an integer or if its value does not fit into 128 bits.ToU128Safe() (uint128.Uint128,error)// ToU64 returns the value of an integer record as a uint64. Behavior is undefined if the// record is not an integer or if its value does not fit into 64 bits.ToU64()uint64// ToU64Safe returns the value of an integer record as a uint64. Returns an error if the// record is not an integer or if its value does not fit into 64 bits.ToU64Safe() (uint64,error)// ToU32 returns the value of an integer record as a uint32. Behavior is undefined if the// record is not an integer or if its value does not fit into 32 bits.ToU32()uint32// ToU32Safe returns the value of an integer record as a uint32. Returns an error if the// record is not an integer or if its value does not fit into 32 bits.ToU32Safe() (uint32,error)// ToI64 returns the value of an integer record as an int64. Behavior is undefined if the// record is not an integer or if its value does not fit into 64 bits.ToI64()int64// ToI64Safe returns the value of an integer record as an int64. Returns an error if the// record is not an integer or if its value does not fit into 64 bits.ToI64Safe() (int64,error)// ToI32 returns the value of an integer record as an int32. Behavior is undefined if the// record is not an integer or if its value does not fit into 32 bits.ToI32()int32// ToI32Safe returns the value of an integer record as an int32. Returns an error if the// record is not an integer or if its value does not fit into 32 bits.ToI32Safe() (int32,error)// ToString returns the value of a string record. Behavior is undefined if the record is not// a string.ToString()string// ToStringSafe returns the value of a string record. Returns an error if the record is not// a string.ToStringSafe() (string,error)// AsTuple interprets the current record as a tuple, enabling the caller to use methods// which are specific to tuples on the returned object. Behavior is undefined if the record// is not a tuple.AsTuple()RecordTuple// AsTupleSafe interprets the current record as a tuple, enabling the caller to use methods// which are specific to tuples on the returned object. Returns an error if the record is// not a tuple.AsTupleSafe() (RecordTuple,error)// AsVector interprets the current record as a vector, enabling the caller to use methods// which are specific to vectors on the returned object. Behavior is undefined if the record// is not a vector.AsVector()RecordVector// AsVectorSafe interprets the current record as a vector, enabling the caller to use// methods which are specific to vectors on the returned object. Returns an error if the// record is not a vector.AsVectorSafe() (RecordVector,error)// AsMap interprets the current record as a map, enabling the caller to use methods which// are specific to maps on the returned object. Behavior is undefined if the record is not a// map.AsMap()RecordMap// AsMapSafe interprets the current record as a map, enabling the caller to use methods// which are specific to maps on the returned object. Returns an error if the record is not// a map.AsMapSafe() (RecordMap,error)// AsSet interprets the current record as a set, enabling the caller to use methods which// are specific to sets on the returned object. Behavior is undefined if the record is not a// set.AsSet()RecordSet// AsSetSafe interprets the current record as a set, enabling the caller to use methods// which are specific to sets on the returned object. Returns an error if the record is not// a set.AsSetSafe() (RecordSet,error)// AsStruct interprets the current record as a struct, enabling the caller to use methods// which are specific to structs on the returned object. Behavior is undefined if the record// is not a struct.AsStruct()RecordStruct// AsStructSafe interprets the current record as a struct, enabling the caller to use// methods which are specific to structs on the returned object. Returns an error if the// record is not a struct.AsStructSafe() (RecordStruct,error)// contains filtered or unexported methods}Record represents a DDlog record. It is an interface, rather than simply a wrapper around addlog_record pointer, to provide some type-safety. In particular, some methods are not includedin this interface because they are specific to a type of record (e.g. Push() for a RecordVector).
funcNewRecordI32¶
NewRecordI32 creates a record for a signed integer value. Can be used to populate any DDlog fieldof type `signed<N>`, `N<=32`.
funcNewRecordI64¶
NewRecordI64 creates a record for a signed integer value. Can be used to populate any DDlog fieldof type `signed<N>`, `N<=64`.
funcNewRecordLeft¶
NewRecordLeft is a convenience wrapper around NewRecordStructStatic for the std.Leftconstructor.
funcNewRecordNone¶
func NewRecordNone()Record
NewRecordNone is a convenience wrapper around NewRecordStructStatic for the std.Noneconstructor.
funcNewRecordNull¶
func NewRecordNull()Record
NewRecordNull returns a NULL record, which can be used as a placeholder for an invalid record.
funcNewRecordRight¶
NewRecordRight is a convenience wrapper around NewRecordStructStatic for the std.Rightconstructor.
funcNewRecordSome¶
NewRecordSome is a convenience wrapper around NewRecordStructStatic for the std.Someconstructor.
funcNewRecordString¶
NewRecordString creates a record for a string.
funcNewRecordU128¶
NewRecordU128 creates a record for an unsigned integer value. Can be used to populate any DDlogfield of type `bit<N>`, `N<=128`.
funcNewRecordU32¶
NewRecordU32 creates a record for an unsigned integer value. Can be used to populate any DDlogfield of type `bit<N>`, `N<=32`.
funcNewRecordU64¶
NewRecordU64 creates a record for an unsigned integer value. Can be used to populate any DDlogfield of type `bit<N>`, `N<=64`.
typeRecordMap¶
type RecordMap interface {Record// Push appends a key-value pair to the map.Push(rKey, rValueRecord)// KeyAt returns the i-th key of the map. Returns a NULL record if the map has fewer than i// key-value pairs.KeyAt(idxint)Record// ValueAt returns the i-th value of the map. Returns a NULL record if the map has fewer// than i key-value pairs.ValueAt(idxint)Record// At returns the i-th key-value pair of the map. Returns a NULL record if the map has fewer// than i key-value pairs.At(idxint) (Record,Record)// Size returns the number of key-value pairs in the map.Size()int}RecordMap extends the Record interface for DDlog records of type map.
funcNewRecordMap¶
NewRecordMap creates a map record with specified key-value pairs.
typeRecordSet¶
type RecordSet interface {Record// Push appends an element to the set.Push(rValueRecord)// At returns the i-th element of the set. Returns a NULL record if the set has fewer than i// elements.At(idxint)Record// Size returns the number of elements in the set.Size()int}RecordSet extends the Record interface for DDlog records of type set.
funcNewRecordSet¶
NewRecordSet creates a set record with specified elements.
typeRecordStruct¶
type RecordStruct interface {Record// Name returns the constructor name for the struct.Name()string// At returns the i-th field of the struct. Returns a NULL record if the struct has fewer// than i fields.At(idxint)Record}RecordStruct extends the Record interface for DDlog records of type struct.
funcNewRecordStruct¶
func NewRecordStruct(constructorstring, records ...Record)RecordStruct
NewRecordStruct creates a struct record with specified constructor name and arguments.
funcNewRecordStructStatic¶
func NewRecordStructStatic(constructorCString, records ...Record)RecordStruct
NewRecordStructStatic creates a struct record with specified constructor name andarguments. Unlike NewRecordStruct, this function takes a CString for the constructor to avoidmaking an extra copy of the constructor string when it is "static" (known ahead of time).
typeRecordTuple¶
type RecordTuple interface {Record// Push appends an element to the tuple.Push(rValueRecord)// At returns the i-th element of the tuple. Returns a NULL record if the tuple has fewer// than i elements.At(idxint)Record// Size returns the number of elements in the tuple.Size()int}RecordTuple extends the Record interface for DDlog records of type tuple.
funcNewRecordPair¶
func NewRecordPair(r1, r2Record)RecordTuple
NewRecordPair is a convenience way to create a 2-tuple. Such tuples are useful when constructingmaps out of key-value pairs.
funcNewRecordTuple¶
func NewRecordTuple(records ...Record)RecordTuple
NewRecordTuple creates a tuple record with specified fields.
typeRecordVector¶
type RecordVector interface {Record// Push appends an element to the vector.Push(rValueRecord)// At returns the i-th element of the vector. Returns a NULL record if the vector has fewer// than i elements.At(idxint)Record// Size returns the number of elements in the vector.Size()int}RecordVector extends the Record interface for DDlog records of type vector.
funcNewRecordVector¶
func NewRecordVector(records ...Record)RecordVector
NewRecordVector creates a vector record with specified elements.