dal

package
v0.0.0-...-f714a01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2016 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package dal is a generated protocol buffer package.

It is generated from these files:

dal/protobuf.proto

It has these top-level messages:

ProtoLog
ProtoSegment
ProtoFact

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteBlock

func DeleteBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) error

func DeleteLog

func DeleteLog(e storage.Tx, domain string, name string) error

func DeleteSegment

func DeleteSegment(e storage.Tx, domain string, id *uuid.UUID) error

func GetBlock

func GetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int) ([]byte, error)

GetBlock returns a block from storage. The lookup requires the domain, ID of the segment the block is contained in, the index of the block in the segment, and the transaction that processed the segment.

func SetBlock

func SetBlock(e storage.Tx, domain string, id *uuid.UUID, idx int, bytes []byte) (int, error)

func SetLog

func SetLog(e storage.Tx, domain string, log *Log) (int, error)

func SetSegment

func SetSegment(e storage.Tx, domain string, segment *Segment) (int, error)

Types

type BlockDecoder

type BlockDecoder struct {
	Domain      string
	Transaction uint64
	Count       int
	// contains filtered or unexported fields
}

BlockDecoder decodes bytes into facts.

func NewBlockDecoder

func NewBlockDecoder(block []byte, domain string, tx uint64) *BlockDecoder

func (*BlockDecoder) Empty

func (d *BlockDecoder) Empty() bool

func (*BlockDecoder) Err

func (d *BlockDecoder) Err() error

func (*BlockDecoder) Next

func (d *BlockDecoder) Next() *origins.Fact

type BlockEncoder

type BlockEncoder struct {
	Count int
	// contains filtered or unexported fields
}

BlockEncoder encodes facts into a buffer.

func NewBlockEncoder

func NewBlockEncoder() *BlockEncoder

func (*BlockEncoder) Bytes

func (e *BlockEncoder) Bytes() []byte

Bytes returns the unread slice of encoded bytes.

func (*BlockEncoder) Reset

func (e *BlockEncoder) Reset()

Reset resets the internal buffer and sets the count to zero.

func (*BlockEncoder) Write

func (e *BlockEncoder) Write(f *origins.Fact) error

Write encodes a fact and writes to the block.

type Log

type Log struct {
	// Name of the log. Currently, only the "commit" log is in use.
	Name string

	// Domain the log is created in.
	Domain string

	// ID of the segment that is the head of the log.
	Head *uuid.UUID
}

A Log represents a chain of segments with the log maintaining a pointer to the most recent segment in the chain.

func GetLog

func GetLog(e storage.Tx, domain, name string) (*Log, error)

type ProtoFact

type ProtoFact struct {
	Added            *bool   `protobuf:"varint,1,req" json:"Added,omitempty"`
	EntityDomain     *string `protobuf:"bytes,2,req" json:"EntityDomain,omitempty"`
	Entity           *string `protobuf:"bytes,3,req" json:"Entity,omitempty"`
	AttributeDomain  *string `protobuf:"bytes,4,req" json:"AttributeDomain,omitempty"`
	Attribute        *string `protobuf:"bytes,5,req" json:"Attribute,omitempty"`
	ValueDomain      *string `protobuf:"bytes,6,opt" json:"ValueDomain,omitempty"`
	Value            *string `protobuf:"bytes,7,req" json:"Value,omitempty"`
	Time             *int64  `protobuf:"varint,8,opt" json:"Time,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

Facts do not contain omit the domain and transaction ID since this info is contained in the tiers accessed above the fact. Specifically, the domain is required to access the fact, so it is attached to the fact when decoded. Likewise, the the transaction ID is referenced by the segment that is accessed prior to decoding facts. The fact operation is currently encoded as a boolean where true denotes "assert" and false denotes "retract".

func (*ProtoFact) GetAdded

func (m *ProtoFact) GetAdded() bool

func (*ProtoFact) GetAttribute

func (m *ProtoFact) GetAttribute() string

func (*ProtoFact) GetAttributeDomain

func (m *ProtoFact) GetAttributeDomain() string

func (*ProtoFact) GetEntity

func (m *ProtoFact) GetEntity() string

func (*ProtoFact) GetEntityDomain

func (m *ProtoFact) GetEntityDomain() string

func (*ProtoFact) GetTime

func (m *ProtoFact) GetTime() int64

func (*ProtoFact) GetValue

func (m *ProtoFact) GetValue() string

func (*ProtoFact) GetValueDomain

func (m *ProtoFact) GetValueDomain() string

func (*ProtoFact) ProtoMessage

func (*ProtoFact) ProtoMessage()

func (*ProtoFact) Reset

func (m *ProtoFact) Reset()

func (*ProtoFact) String

func (m *ProtoFact) String() string

type ProtoLog

type ProtoLog struct {
	Head             []byte `protobuf:"bytes,1,opt" json:"Head,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

A log is the header of a linked list of segments. It is one of the few mutable values since it holds the pointer to the head of the linked list. Upon a successful transaction, the head is updated to point to the most segment.

func (*ProtoLog) GetHead

func (m *ProtoLog) GetHead() []byte

func (*ProtoLog) ProtoMessage

func (*ProtoLog) ProtoMessage()

func (*ProtoLog) Reset

func (m *ProtoLog) Reset()

func (*ProtoLog) String

func (m *ProtoLog) String() string

type ProtoSegment

type ProtoSegment struct {
	UUID             []byte  `protobuf:"bytes,1,req" json:"UUID,omitempty"`
	Transaction      *uint64 `protobuf:"varint,2,req" json:"Transaction,omitempty"`
	Time             *int64  `protobuf:"varint,3,req" json:"Time,omitempty"`
	Blocks           *int32  `protobuf:"varint,4,req" json:"Blocks,omitempty"`
	Count            *int32  `protobuf:"varint,5,req" json:"Count,omitempty"`
	Bytes            *int32  `protobuf:"varint,6,req" json:"Bytes,omitempty"`
	Next             []byte  `protobuf:"bytes,7,opt" json:"Next,omitempty"`
	Base             []byte  `protobuf:"bytes,8,opt" json:"Base,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

A segment behaves as a node in a linked list in the scope of a domain. It corresponds to a transaction and maintains stats about contained facts. To access the facts, the segment key is combined with a block index, e.g segment.1.0 which translates to "segment 1 block 0".

func (*ProtoSegment) GetBase

func (m *ProtoSegment) GetBase() []byte

func (*ProtoSegment) GetBlocks

func (m *ProtoSegment) GetBlocks() int32

func (*ProtoSegment) GetBytes

func (m *ProtoSegment) GetBytes() int32

func (*ProtoSegment) GetCount

func (m *ProtoSegment) GetCount() int32

func (*ProtoSegment) GetNext

func (m *ProtoSegment) GetNext() []byte

func (*ProtoSegment) GetTime

func (m *ProtoSegment) GetTime() int64

func (*ProtoSegment) GetTransaction

func (m *ProtoSegment) GetTransaction() uint64

func (*ProtoSegment) GetUUID

func (m *ProtoSegment) GetUUID() []byte

func (*ProtoSegment) ProtoMessage

func (*ProtoSegment) ProtoMessage()

func (*ProtoSegment) Reset

func (m *ProtoSegment) Reset()

func (*ProtoSegment) String

func (m *ProtoSegment) String() string

type Segment

type Segment struct {
	// Unique identifier of the segment.
	UUID *uuid.UUID

	// ID of the transaction this segment was created in.
	Transaction uint64

	// The domain this segment corresponds to.
	Domain string

	// Time the segment was committed.
	Time time.Time

	// Number of blocks in this segment.
	Blocks int

	// Total number of facts in the segment.
	Count int

	// Total number of bytes of the segment take up.
	Bytes int

	// ID of the segment that acted as the basis for this one. This
	// is defined as the time the transaction starts.
	Base *uuid.UUID

	// ID of the segment that this segment succeeds. Typically this is
	// the same value as Base, except when a conflict is resolved and
	// the segment position is changed.
	Next *uuid.UUID
}

Segment represents a transacted set of facts. Segments are broken up into fixed-sized blocks to facilitate flushing the data to disk during a long-running transaction. Each segment maintains the basis

func GetSegment

func GetSegment(e storage.Tx, domain string, id *uuid.UUID) (*Segment, error)

GetSegment returns a segment from storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL