API Reference

The modules of the mlambda-data package, by layer. The REST API the service serves is in API Spec.

ORM

Orm.Entity

Name Type
trait Entity e mapping :: Mapping e, toColumns :: e -> Columns, fromColumns :: Columns -> Maybe e, keyOf :: e -> Bytes
mappedTo String -> TableBuilder -> Mapping e
trait ColumnValue v toValue :: v -> Bytes, fromValue :: Bytes -> Maybe v (instances: String, Int, Bool)
fieldOf ColumnValue v => String -> v -> Column
fieldValue ColumnValue v => String -> Columns -> Maybe v

Orm.Repository

Name Type
openRepository Entity e => Address DataEngine -> Either Fault (Repository e)
save Entity e => Repository e -> e -> Either Fault Int
find Entity e => Repository e -> Bytes -> Either Fault (Maybe e)
remove Repository e -> Bytes -> Either Fault Int
select Entity e => Repository e -> Selection -> Either Fault [e]
joinWith (Entity l, Entity r) => Repository l -> Repository r -> String -> [Filter] -> Either Fault [(l, r)]

Orm.Spec

Name Type
data Spec Where Filter \| Both Spec Spec \| OneOf Spec Spec \| Negated Spec \| Everything
selecting Spec -> Selection
orderedBy String -> Bool -> Selection -> Selection (True: descending)
withPage Int -> Int -> Selection -> Selection (skip, at most; 0: all)

Orm.Replicated

Name Type
openReplicated Entity e => Coordinator -> Address DataEngine -> Either Fault (Replicated e)
saveReplicated, findReplicated, removeReplicated as the repository’s, on a quorum of the key’s replicas
selectReplicated Entity e => Replicated e -> Selection -> Either Fault [e] (this node’s engine)

Engine

Engine.DataEngine

An actor (actorOf system (parameters [("root", path)])). Its messages:

Message Does
EngineDefine db table reply Defines a table (or finds it)
EngineWrite, EngineRead, EngineDelete A row by key
EngineBulkWrite db table rows stamp reply Many rows in one logged batch
EngineQuery db table query reply Rows passing filters, ordered and paged
EngineJoin db left right column filters reply A hash join
EngineFlush, EngineCompact Flush a table’s memtable; compact its SSTables
EngineLogWrites How many writes a table’s log holds

Engine.Query

Name Meaning
data FilterOp OpEq, OpGt, OpGte, OpLt, OpLte, OpPrefix
data Filter Filter column op valueBytes
data Query Query filters orderColumn descending skip limit
data Row Row key columns timestamp
data QueryResult QueryResult rows total more

Engine.Planner

trait Planner; RulePlanner answers one filter through an index that fits (hash lookup, B-tree point, range or prefix) and scans otherwise.

Tables

Table.Schema

Name Meaning
data DataType Int32Type, Int64Type, Float64Type, TextType, BlobType, BooleanType, TimestampType, UuidType
data ColumnDef ColumnDef name type nullable
data IndexKind BTreeKind, HashKind, BloomKind, InvertedKind
data Replication Replication factor strategy (SimpleStrategy, NetworkTopologyStrategy)
data TableDef Columns, partition key, clustering key, indexes, replication

Table.Builder

tableBuilder, column, nullableColumn, partitionKey, clusteringKey, btreeIndex, hashIndex, invertedIndex, replicas, placedBy, and build :: TableBuilder -> Either String TableDef.

Table.Evolution

trait Evolution, with AddColumn, DropColumn, WidenColumn, RenameColumn (and Change, any of them).

Table.Constraints

trait Constraint, with NotNull, OfType, KnownColumns, MaxBytes.

Table.Actors

The schema registry: CreateTable, AlterTable, DropTable, TableOf, TablesOf; each change a new version.

Indexes (Index.*)

Module What
Index.BTree Sorted keys: points, ranges, prefixes
Index.HashIndex Equality, buckets grown when full
Index.Bloom m bits, k probes; about 1% false positives at 10 bits a key and 7 probes
Index.Inverted Words to row keys; a search answers the rows holding every word
Index.Class, Index.Actors The index interface and its actors

Storage (Storage.*)

Wal, Memtable, SSTable, Compaction, Snapshot, Manifest, and their actors (WalActor, MemtableActor, CompactionActor). See the Developer Guide.

Filesystem (Filesystem.*)

Namespace (paths to files), FileActor (a file of blocks), Block (a block on disk).

Distributed (Distributed.*)

Module What
Distributed.Ring The consistent-hash ring: ringOf vnodes nodes, owners of a key, shares
Distributed.Coordinator writeAt, readAt, deleteAt at One, Quorum or All; read repair
Distributed.Replica A node’s share as a hosted actor (replica/<node>)
Distributed.Node A node’s coordinator over its actor host

API (Api.*)

Module What
Api.Gateway The REST routes (as API Spec)
Api.Hubs, Api.HubActor, Api.SignalR The five live channels over SignalR’s JSON protocol
Api.Tokens Access tokens (JWT)
Api.Service The database as a service on an actor host

Auth (Auth.*)

Auth.Jwt, Auth.Passwords (PBKDF2), Auth.Permissions (the most specific permission decides), Auth.AuthActor, Auth.Services (login, lockout after five failed attempts).

Management (Management.*)

Management.Failures (failure kinds and guardians), Management.CompactionBreaker (compaction paced by the disk’s load).