{"modulePath":"github.com/google/note-maps","version":"v0.1.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package note\n\nPackage note provides types and functions for interacting with a note maps data storage system.\n\nPackage note provides types and functions for interacting with a note maps data storage system.\n\n## Constants\n\n```go\nconst (\n\t// EmptyLoader implements the Loader interface for a note map that is\n\t// always empty.\n\tEmptyLoader emptyLoader = 0\n)\n```\n\n## Variables\n\n```go\nvar (\n\tInvalidID = errors.New(\"invalid note id\")\n)\n```\n\n## Functions\n\n```go\nfunc Patch(a *TruncatedNote, ops []Operation) error\n```\nPatch applies a set of operations to a.\n\n## Types\n\n```go\ntype Database interface {\n\tDatabaseReader\n\tDatabaseWriter\n\tio.Closer\n}\n```\nDatabase provides atomic isolated read and write operations over a note map.\n\nAn instance of Database should be closed when it is no longer needed.\n\n```go\ntype DatabaseReader interface {\n\t// IsolatedRead invokes f with a FindLoader that will read from an\n\t// unchanging version of the note map.\n\tIsolatedRead(f func(r FindLoader) error) error\n}\n```\nDatabaseReader provides isolated read operations over a note map.\n\n```go\ntype DatabaseWriter interface {\n\t// IsolatedWrite invokes f with an isolated FindLoadPatcher that can read and\n\t// change a note map.\n\t//\n\t// If f returns an error, none of the changes will be saved. Implementations\n\t// should return an error in any case when changes are not saved.\n\tIsolatedWrite(f func(rw FindLoadPatcher) error) error\n}\n```\nDatabaseWriter provides atomic isolated write operations over a note map.\n\n```go\ntype EmptyNote ID\n```\nEmptyNote is simply an empty GraphNote with nothing more than an ID.\n\n```go\nfunc (x EmptyNote) GetContents() ([]GraphNote, error)\n```\n\n```go\nfunc (x EmptyNote) GetID() ID\n```\n\n```go\nfunc (x EmptyNote) GetTypes() ([]GraphNote, error)\n```\n\n```go\nfunc (x EmptyNote) GetValue() (string, GraphNote, error)\n```\n\n```go\ntype FindLoadPatcher interface {\n\tFinder\n\tLoader\n\tPatcher\n}\n```\nFindLoadPatcher combines the Finder, Loader, and Patcher interfaces.\n\n```go\ntype FindLoader interface {\n\tFinder\n\tLoader\n}\n```\nFindLoader combines the Finder and Loader interfaces.\n\n```go\ntype Finder interface {\n\tFind(*Query) ([]GraphNote, error)\n}\n```\nFinder can be implemented to support finding notes in a note map according to a query.\n\n```go\ntype GraphNote interface {\n\tGetID() ID\n\tGetValue() (string, GraphNote, error)\n\tGetContents() ([]GraphNote, error)\n\tGetTypes() ([]GraphNote, error)\n}\n```\nGraphNote is a graph-like interface to a note in a note map.\n\nSince traversing from note to note in a note map may require fragile operations like loading query results from a storage backend, most methods can return an error instead of the requested data.\n\n```go\nfunc ExpandNote(tn TruncatedNote, l Loader) GraphNote\n```\nExpandNote uses tn and l to provide a full GraphNote implementation.\n\n```go\nfunc LoadOne(l Loader, id ID) (GraphNote, error)\n```\nLoadOne is a convenience function for loading just one note.\n\n```go\ntype ID string\n```\nID is the type of values that identify note.\n\n```go\nconst EmptyID ID = \"\"\n```\nEmptyID is the zero or nil value for note identifiers, and never identifies a valid note.\n\nEmptyID exists only to make code that specifies the zero value for note identifiers a bit more readable.\n\n```go\nfunc RandomID() ID\n```\nRandomID returns a pseudo-random ID using package math/rand.\n\n```go\nfunc (id ID) Empty() bool\n```\n\n```go\nfunc (x ID) String() string\n```\n\n```go\ntype IDSlice []ID\n```\n\n```go\nfunc (xs IDSlice) Append(add ...ID) IDSliceDelta\n```\n\n```go\nfunc (xs IDSlice) Apply(ops []IDSliceOp) IDSlice\n```\n\n```go\nfunc (xs IDSlice) CanApply(ops []IDSliceOp) bool\n```\n\n```go\nfunc (xs IDSlice) Delete(i, num int) IDSliceDelta\n```\n\n```go\nfunc (xs IDSlice) DeleteElements(del ...ID) IDSliceDelta\n```\n\n```go\nfunc (xs IDSlice) Insert(i int, add ...ID) IDSliceDelta\n```\n\n```go\nfunc (xs IDSlice) PrefixMatch(ys []ID) int\n```\nPrefixMatch returns the number of elements at the beginning of xs that match the elements at the beginning of ys.\n\n```go\nfunc (xs IDSlice) Retain(r int) IDSliceDelta\n```\n\n```go\nfunc (ids IDSlice) String() string\n```\n\n```go\ntype IDSliceDelta []IDSliceOp\n```\n\n```go\nfunc IDSliceDiff(a, b []ID) IDSliceDelta\n```\nIDSliceDiff produces a set of operations that can be applied to xs to produce a slice that would match slice b.\n\n```go\nfunc (x IDSliceDelta) Delete(d int) IDSliceDelta\n```\n\n```go\nfunc (x IDSliceDelta) Insert(add ...ID) IDSliceDelta\n```\n\n```go\nfunc (x IDSliceDelta) Rebase(base IDSliceDelta) (IDSliceDelta, error)\n```\n\n```go\nfunc (x IDSliceDelta) Retain(r int) IDSliceDelta\n```\n\n```go\ntype IDSliceOp interface {\n\t// Leaves returns how many elements of a slice of length n would remain\n\t// to be transformed by additional ops after applying this op. Returns\n\t// a negative number if and only if this op cannot be coherently\n\t// applied to a slice of length n.\n\tLeaves(n int) int\n\t// Len returns the number of elements inserted, retained, or deleted by\n\t// this op.\n\tLen() int\n\t// Skip returns an equivalent op that assumes its intent is already carried\n\t// out for the first n elements. May panic if n \u003e Len().\n\tSkip(n int) IDSliceOp\n\t// Rebase transforms op into a rebased op r (or nil), a subsequent op for\n\t// rebasing xn (or nil), and a subsequent base bn (or nil).\n\tRebase(base IDSliceOp) (r IDSliceOp, xn IDSliceOp, bn IDSliceOp)\n\t// Compact expands this op to include o if possible, returning true if\n\t// successful.\n\tCompact(o IDSliceOp) (IDSliceOp, bool)\n\tApply(IDSlice) (include IDSlice, remainder IDSlice)\n\tString() string\n}\n```\n\n```go\ntype IDSliceOpDelete int\n```\n\n```go\nfunc (x IDSliceOpDelete) Apply(xs IDSlice) (IDSlice, IDSlice)\n```\n\n```go\nfunc (x IDSliceOpDelete) Compact(op IDSliceOp) (IDSliceOp, bool)\n```\n\n```go\nfunc (x IDSliceOpDelete) Leaves(in int) int\n```\n\n```go\nfunc (x IDSliceOpDelete) Len() int\n```\n\n```go\nfunc (x IDSliceOpDelete) Rebase(base IDSliceOp) (IDSliceOp, IDSliceOp, IDSliceOp)\n```\n\n```go\nfunc (x IDSliceOpDelete) Skip(n int) IDSliceOp\n```\n\n```go\nfunc (x IDSliceOpDelete) String() string\n```\n\n```go\ntype IDSliceOpInsert []ID\n```\n\n```go\nfunc (x IDSliceOpInsert) Apply(xs IDSlice) (IDSlice, IDSlice)\n```\n\n```go\nfunc (x IDSliceOpInsert) Compact(op IDSliceOp) (IDSliceOp, bool)\n```\n\n```go\nfunc (x IDSliceOpInsert) Leaves(in int) int\n```\n\n```go\nfunc (x IDSliceOpInsert) Len() int\n```\n\n```go\nfunc (x IDSliceOpInsert) Rebase(base IDSliceOp) (IDSliceOp, IDSliceOp, IDSliceOp)\n```\n\n```go\nfunc (x IDSliceOpInsert) Skip(n int) IDSliceOp\n```\n\n```go\nfunc (x IDSliceOpInsert) String() string\n```\n\n```go\ntype IDSliceOpRetain int\n```\n\n```go\nfunc (x IDSliceOpRetain) Apply(xs IDSlice) (IDSlice, IDSlice)\n```\n\n```go\nfunc (x IDSliceOpRetain) Compact(op IDSliceOp) (IDSliceOp, bool)\n```\n\n```go\nfunc (x IDSliceOpRetain) Leaves(in int) int\n```\n\n```go\nfunc (x IDSliceOpRetain) Len() int\n```\n\n```go\nfunc (x IDSliceOpRetain) Rebase(base IDSliceOp) (IDSliceOp, IDSliceOp, IDSliceOp)\n```\n\n```go\nfunc (x IDSliceOpRetain) Skip(n int) IDSliceOp\n```\n\n```go\nfunc (x IDSliceOpRetain) String() string\n```\n\n```go\ntype Loader interface {\n\t// Load returns a slice of all found notes.\n\t//\n\t// All notes exist implicitly, even if they are empty. An error indicates\n\t// something actually went wrong.\n\tLoad(ids []ID) ([]GraphNote, error)\n}\n```\nLoader can be implemented to support loading notes by id.\n\n```go\ntype NoteDelta []NoteOp\n```\n\n```go\nfunc NoteDeltaFromTruncatedNote(n TruncatedNote) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) ChangeContents(d IDSliceDelta) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) ChangeTypes(d IDSliceDelta) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) ChangeValueString(d runes.StringDelta) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) ChangeValueType(vt ID) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) GetContentIDs() IDSlice\n```\n\n```go\nfunc (xs NoteDelta) GetID() ID\n```\n\n```go\nfunc (xs NoteDelta) GetTypeIDs() IDSlice\n```\n\n```go\nfunc (xs NoteDelta) GetValueString() runes.String\n```\n\n```go\nfunc (xs NoteDelta) GetValueTypeID() ID\n```\n\n```go\nfunc (xs NoteDelta) SetID(id ID) NoteDelta\n```\n\n```go\nfunc (xs NoteDelta) Truncate() TruncatedNote\n```\n\n```go\ntype NoteMapDelta []NoteMapOp\n```\n\n```go\nfunc (xs NoteMapDelta) ChangeNote(n NoteDelta) NoteMapDelta\n```\n\n```go\ntype NoteMapOp interface{}\n```\n\n```go\ntype NoteMapOpNoteDelta NoteDelta\n```\n\n```go\ntype NoteOp interface{}\n```\n\n```go\ntype NoteOpContentsDelta IDSliceDelta\n```\n\n```go\ntype NoteOpID ID\n```\n\n```go\ntype NoteOpTypesDelta IDSliceDelta\n```\n\n```go\ntype NoteOpValueDelta runes.StringDelta\n```\n\n```go\ntype NoteOpValueTypeDelta ID\n```\n\n```go\ntype Op ID\n```\nOp is a minimal implementation of Operation meant to be used as a mixin for operations that affect only one note.\n\n```go\nfunc (x Op) AffectsID(id ID) bool\n```\nAffectsID returns true if x could change a note with ID==id.\n\n```go\nfunc (x Op) GetID() ID\n```\n\n```go\ntype OpContentDelta OpIDSliceDelta\n```\n\n```go\nfunc (o OpContentDelta) String() string\n```\n\n```go\ntype OpIDSliceDelta struct {\n\tOp\n\tIDSliceOps []IDSliceOp\n}\n```\n\n```go\nfunc (o OpIDSliceDelta) String() string\n```\n\n```go\ntype OpSetValue struct {\n\tOp\n\tLexical  string\n\tDatatype ID\n}\n```\nOpSetValue sets the value and data type of a note to Lexical and Datatype.\n\n```go\nfunc (os OpSetValue) String() string\n```\n\n```go\ntype OpSetValueString struct {\n\tOp\n\tLexical string\n}\n```\nOpSetValueString sets the value of a note to Lexical.\n\n```go\nfunc (os OpSetValueString) String() string\n```\n\n```go\ntype OpTypesDelta OpIDSliceDelta\n```\n\n```go\nfunc (o OpTypesDelta) String() string\n```\n\n```go\ntype Operation interface {\n\tAffectsID(id ID) bool\n}\n```\nOperation is implemented by types that can describe changes that might be made to a note map.\n\n```go\nfunc Diff(a, b TruncatedNote) []Operation\n```\nDiff produces a set of operations that if applied to a would make it match b.\n\nDifferences in ID are not considered: a and b are not required to have the same ID, and applying the operations to a will not cause it to have the same ID as b.\n\n```go\ntype OperationSlice []Operation\n```\n\n```go\nfunc (os OperationSlice) InsertContent(id ID, index int, cs ...ID) OperationSlice\n```\nInsertContent returns a new OperationSlice that also inserts cs to the contents of note id at index.\n\n```go\nfunc (os OperationSlice) PatchContent(id ID, ops []IDSliceOp) OperationSlice\n```\nPatchContent returns a new OperationSlice that also applies ops to the contents of note id.\n\n```go\nfunc (os OperationSlice) PatchTypes(id ID, ops []IDSliceOp) OperationSlice\n```\nPatchTypes returns a new OperationSlice that also applies ops to the types of note id.\n\n```go\nfunc (os OperationSlice) SetValue(id ID, vs string, vt ID) OperationSlice\n```\nSetValue returns a new OperationSlice that also sets the value and type of note id to vs and vt.\n\n```go\nfunc (os OperationSlice) SetValueString(id ID, vs string) OperationSlice\n```\nSetValue returns a new OperationSlice that also sets the value of note id to vs.\n\n```go\ntype Patcher interface {\n\tPatch(ops []Operation) error\n}\n```\nPatcher can be implemented to support making changes to notes in a note map by applying a set of differences to them.\n\n```go\ntype Plain struct {\n\tID          ID\n\tValueString string\n\tValueType   *Plain\n\tContents    []*Plain\n\tTypes       []*Plain\n}\n```\nPlain is a \"plain old Go object\" representation of a note that uses pointers to refer directly to related notes in memory.\n\nMost of package notes is designed for working with entire note maps which may not fit in memory. Plain is better suited for working with limited subgraphs, for example when decoding subgraphs that are to be merged into a note map.\n\n```go\nfunc (x *Plain) GraphNote() GraphNote\n```\nGraphNote returns a proxy to x that implements the GraphNote interface.\n\n```go\ntype Query struct {\n}\n```\nQuery limits the notes that will be found when loading information from a graph.\n\nThe default query matches all notes.\n\n```go\ntype Stage struct {\n\tOps  OperationSlice\n\tBase Loader\n}\n```\nStage describes a set of changes that might be made to a note map.\n\nThe default stage describes an empty set of changes to be made to an empty note map.\n\nA default Stage{} is an empty set of changes made to an empty note map.\n\n```go\nfunc (x *Stage) Add(o Operation) *Stage\n```\nAdd simply appends o to the set of operations described by x.\n\n```go\nfunc (x *Stage) GetBase() Loader\n```\nGetBase returns a non-nil Loader derived from x.Base.\n\n```go\nfunc (x *Stage) Note(id ID) *StageNote\n```\nNote returns a note-specific StageNote focused on note with id.\n\n```go\ntype StageNote struct {\n\tStage *Stage\n\tID    ID\n}\n```\nStageNote supports updating the content of a note within a batch, and also implements the GraphNote interface to read the hypothetical state of a note with the batch applied.\n\n```go\nfunc MustStageNote(n *StageNote, err error) *StageNote\n```\n\n```go\nfunc (x *StageNote) AddContent(id ID) (*StageNote, error)\n```\nAddContent expands the staged operations to add content to this note.\n\n```go\nfunc (x *StageNote) GetContentIDs() ([]ID, error)\n```\n\n```go\nfunc (x *StageNote) GetContents() ([]GraphNote, error)\n```\n\n```go\nfunc (x *StageNote) GetID() ID\n```\n\n```go\nfunc (x *StageNote) GetTypeIDs() ([]ID, error)\n```\n\n```go\nfunc (x *StageNote) GetTypes() ([]GraphNote, error)\n```\n\n```go\nfunc (x *StageNote) GetValue() (string, GraphNote, error)\n```\n\n```go\nfunc (x *StageNote) InsertTypes(i int, add ...ID) error\n```\nAddContent expands the staged operations to add content to this note.\n\n```go\nfunc (x *StageNote) Note(id ID) *StageNote\n```\nNote returns the identified note from the underlying stage.\n\n```go\nfunc (x *StageNote) SetValue(lexical string, datatype ID) error\n```\nSetValue expands the staged operations to update the value of this note.\n\n```go\ntype TruncatedNote struct {\n\tID          ID\n\tValueString string\n\tValueType   ID\n\tContents    []ID\n\tTypes       []ID\n}\n```\nTruncatedNote is a minimal representation of a note intended for storage integrations and for algorithms that don't need to traverse a graph of note.\n\n```go\nfunc TruncateNote(n GraphNote) (TruncatedNote, error)\n```\nTruncateNote returns a TruncatedNote representation of n.\n\n```go\nfunc (x TruncatedNote) Equals(y TruncatedNote) bool\n```\nEquals return true if and only if x is deeply equal to y.\n\n","path":"github.com/google/note-maps/note","name":"note","synopsis":"Package note provides types and functions for interacting with a note maps data storage system.","isRedistributable":true}
