Documentation ¶
Index ¶
- Variables
- func TempID() tempID
- type AssertMode
- type AssertResult
- type Assertable
- type Assertion
- type Config
- type Connection
- type Database
- type EncodedTuple
- type EncodedValue
- type Entity
- type EntityData
- type Fact
- type ID
- type IDManager
- type Ident
- type IdentManager
- type Indexer
- type Lookup
- type ResolvedAssertion
- type Resolver
- type TempIDs
- type TupleHeader
- type Tx
- type TypeTag
- type TypedTuple
- type TypedValue
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSuchEntity = fmt.Errorf("no such entity") ErrConflict = fmt.Errorf("conflict") )
var ( ErrNoSuchIdent = errors.New("ident does not exist") ErrIdentAlreadyExists = errors.New("ident already exists") )
var ErrPropertyNotFound = errors.New("property not found")
var NullIdent = Ident{}
Functions ¶
Types ¶
type AssertMode ¶
type AssertMode uint8
const ( AssertModeInvalid AssertMode = iota AssertModeAddition AssertModeRetraction AssertModeRedaction )
func (AssertMode) String ¶
func (i AssertMode) String() string
type AssertResult ¶
type AssertResult struct { DB Database Data []ResolvedAssertion TempIDs TempIDs }
type Assertable ¶
type Assertable interface { // Assertions gets zero or more assertions to submit. This method is only // responsible for preparing data into zero or more Assertions, not // resolving any IDs. This will be done within the Connection while // preparing a transaction. Assertions(conn *Connection) ([]Assertion, error) }
type Assertion ¶
type Assertion struct {
// contains filtered or unexported fields
}
Assertion represents some action (add/retract/redact) and the unresolved
func (Assertion) Assertions ¶
func (a Assertion) Assertions(conn *Connection) ([]Assertion, error)
Assertions implements Assertable for Assertion. This method allows an assertion to be passed directly to *Connection.Assert().
type Config ¶
type Config struct { IdentManager IDManager Indexer }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is the structure used to maintain
func NewConnection ¶
func NewConnection(cfg Config) *Connection
func (*Connection) Assert ¶
func (conn *Connection) Assert(assertables ...Assertable) (*AssertResult, error)
func (*Connection) GetEntity ¶
func (conn *Connection) GetEntity(idResolver Resolver) (Entity, error)
func (*Connection) InitializeDB ¶
func (conn *Connection) InitializeDB() error
InitializeDB sets up all of the required resources in the underlying storage engine for the database to which the peer is connected. It should only be called once, before transacting any data.
func (*Connection) ResolveIdents ¶
func (conn *Connection) ResolveIdents(idents []any) (ids []Ident, err error)
ResolveIdents takes a slice of arguments, each of which may be an already-resolved ID or a string ident. It resolves the arguments to their canonical form. The resulting `ids` will be parallel to the given `idents`. This method will not allocate, and an error will be returned if any of the arguments cannot be resolved to an ident.
type EncodedTuple ¶
type EncodedTuple []byte
Tuple is a tuple of values that are encoded together. They are typically used as keys in the database's indexes. One advantage of tuple encoding is that it allows for efficient prefix scans, as the tuple is encoded in a lexicographically sortable way. Our tuples are inspired by FoundationDB's Tuple layer. See https://apple.github.io/foundationdb/data-modeling.html#tuples and https://github.com/apple/foundationdb/blob/main/design/tuple.md for more information.
type EncodedValue ¶
type EncodedValue []byte
EncodedValue is a value that has been encoded into a byte slice.
type Entity ¶
type Entity struct {
// contains filtered or unexported fields
}
Entity is an immutable record that contains that state of all attributes associated with a particular ID at some point in time.
func (Entity) Get ¶
func (e Entity) Get(conn *Connection, attribute any) (Value, error)
Get ... attribute may either be a string attribute ident or a resolved ID representing the attribute to retrieve.
func (Entity) GetData ¶
func (e Entity) GetData(conn *Connection) (EntityData, error)
type EntityData ¶
func (EntityData) Assertions ¶
func (ed EntityData) Assertions(conn *Connection) ([]Assertion, error)
Assertions implements Assertable for EntityData. This method resolves attribute idents because it needs and
type ID ¶
type ID int64
ID is an identifier that uniquely identifies an entity or ident.
const ( // System-managed idents. IDID ID = -1*iota - 1 IDIdent IDType IDCompositeComponents IDCardinality IDUnique IDIndexed IDDoc IDTxCommitTime // System-managed enumerated values. IDCardinalityOne IDCardinalityMany IDTypeString ID = -500 + -1*iota IDTypeBoolean IDTypeInt64 IDTypeInt32 IDTypeInt16 IDTypeInt8 IDTypeFloat64 IDTypeFloat32 IDTypeDecimal IDTypeTimestamp IDTypeDate IDTypeRef IDTypeBinary IDTypeUUID IDTypeULID IDTypeComposite )
type Ident ¶
Ident is an ident that has been resolved such that we can access both canonical ID and string representations.
func ResolveIdent ¶
func ResolveIdent(conn *Connection, ident any) (Ident, error)
func (Ident) MustResolve ¶
func (ident Ident) MustResolve(conn *Connection) ID
type IdentManager ¶
type IdentManager interface { // LoadIdents LoadIdents() ([]Ident, error) // LookupIdentIDs will return IDs for all of the names supplied. This will // return `ErrNoSuchIdent` if any name supplied does not represent a valid // ident. LookupIdentIDs([]string) ([]ID, error) // LookupIdentNames returns a list of names for the IDs supplied. This will // return `ErrNoSuchIdent` if any ID supplied does not represent a valid // ident. LookupIdentNames([]ID) ([]string, error) // StoreIdent will store the ident in the backing store. This will return // `ErrIdentAlreadyExists` if the ident already exists. StoreIdent(Ident) error }
IdentManager controls the mapping of string idents to IDs. Each peer maintains a cache of ident mappings in memory, which it hydrates on start-up. Because the system maintains a set of well-known idents < 0, the IdentManager must guarantee that it only allocates positive idents.
type Indexer ¶
type Indexer interface { Write([]ResolvedAssertion) error ScanEAVT(entityID ID, attribute *ID) (dataflow.Producer[Fact], error) ScanAEVT(attribute ID, entityID *ID) (dataflow.Producer[Fact], error) ScanAVET(attribute ID, val Value) (dataflow.Producer[Fact], error) ScanVAET(val Value, attribute *ID) (dataflow.Producer[Fact], error) }
type ResolvedAssertion ¶
type ResolvedAssertion struct { Fact // contains filtered or unexported fields }
func (ResolvedAssertion) Mode ¶
func (ra ResolvedAssertion) Mode() AssertMode
type Resolver ¶
type Resolver interface {
Resolve(conn *Connection) (ID, error)
}
type TempIDs ¶
func (TempIDs) LookupTempID ¶
type TupleHeader ¶
type TupleHeader struct {
Types []rtype.ConcreteType
}
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is is a transaction entity. Transaction entities are normal entities, but they are associated with a database value as of a particular point in time, and they themselves are not associated with any other transaction.
type TypedTuple ¶
type TypedTuple struct { TupleHeader Values []Value }
func NewTypedTuple ¶
func NewTypedTuple(values ...TypedValue) TypedTuple
type TypedValue ¶
type TypedValue struct { Type rtype.ConcreteType Value any }
Value is a typed value that can be stored in a database.