Documentation ¶
Overview ¶
Package types contains most of the data structures available to/from Noms.
Index ¶
- Constants
- Variables
- func CamelCaseFieldName(input string) string
- func ContainCommonSupertype(a, b *Type) bool
- func EncodeValue(v Value) chunks.Chunk
- func EncodedIndexValue(v Value) string
- func EncodedValue(v Value) string
- func EncodedValueMaxLines(v Value, maxLines uint32) string
- func EnsureHash(h *hash.Hash, v Value) hash.Hash
- func EscapeStructField(input string) string
- func HasStructCycles(t *Type) bool
- func HeightOrder(a, b Ref) bool
- func IsPrimitiveKind(k NomsKind) bool
- func IsSubtype(requiredType, concreteType *Type) bool
- func IsSubtypeDisallowExtraStructFields(requiredType, concreteType *Type) bool
- func IsValidStructFieldName(name string) bool
- func IsValueSubtypeOf(v Value, t *Type) bool
- func IsValueSubtypeOfDetails(v Value, t *Type) (bool, bool)
- func NewStreamingList(vrw ValueReadWriter, values <-chan Value) <-chan List
- func NewStreamingMap(vrw ValueReadWriter, kvs <-chan Value) <-chan Map
- func NewStreamingSet(vrw ValueReadWriter, vChan <-chan Value) <-chan Set
- func PanicIfDangling(unresolved hash.HashSet, cs chunks.ChunkStore)
- func RegisterHRSCommenter(typename, unique string, commenter HRSCommenter)
- func UnregisterHRSCommenter(typename, unique string)
- func ValueCanBePathIndex(v Value) bool
- func WalkRefs(c chunks.Chunk, cb RefCallback)
- func WalkValues(target Value, vr ValueReader, cb SkipValueCallback)
- func WriteEncodedValue(w io.Writer, v Value) error
- func WriteEncodedValueMaxLines(w io.Writer, v Value, maxLines uint32) error
- func WriteValueStats(w io.Writer, v Value, vr ValueReader)
- type AtAnnotation
- type Blob
- func (b Blob) Concat(other Blob) Blob
- func (b Blob) Copy(w io.Writer) (n int64)
- func (b Blob) CopyReadAhead(w io.Writer, chunkSize uint64, concurrency int) (n int64)
- func (b Blob) Edit() *BlobEditor
- func (b Blob) ReadAt(p []byte, off int64) (n int, err error)
- func (b Blob) Reader() *BlobReader
- func (b Blob) Value() Value
- func (b Blob) WalkValues(cb ValueCallback)
- type BlobEditor
- func (be *BlobEditor) Blob() Blob
- func (be *BlobEditor) Kind() NomsKind
- func (be *BlobEditor) Len() uint64
- func (be *BlobEditor) Read(p []byte) (n int, err error)
- func (be *BlobEditor) Seek(offset int64, whence int) (int64, error)
- func (be *BlobEditor) Splice(idx uint64, deleteCount uint64, insert []byte) *BlobEditor
- func (be *BlobEditor) Value() Value
- func (be *BlobEditor) Write(p []byte) (n int, err error)
- type BlobReader
- type Bool
- type Collection
- type CompoundDesc
- type CycleDesc
- type DecodedChunk
- type DiffChangeType
- type EditDistanceEqualsFn
- type FieldMap
- type FieldPath
- type GraphBuilder
- type HRSCommenter
- type HashIndexPath
- type IndexPath
- type IntersectionIterator
- type List
- func (l List) Concat(other List) List
- func (l List) Diff(last List, changes chan<- Splice, closeChan <-chan struct{})
- func (l List) DiffWithLimit(last List, changes chan<- Splice, closeChan <-chan struct{}, ...)
- func (l List) Edit() *ListEditor
- func (l List) Get(idx uint64) Value
- func (l List) Iter(f func(v Value, index uint64) (stop bool))
- func (l List) IterAll(f func(v Value, index uint64))
- func (l List) IterRange(startIdx, endIdx uint64, f func(v Value, idx uint64))
- func (l List) Iterator() ListIterator
- func (l List) IteratorAt(index uint64) ListIterator
- func (l List) Value() Value
- func (l List) WalkValues(cb ValueCallback)
- type ListEditor
- func (le *ListEditor) Append(vs ...Valuable) *ListEditor
- func (le *ListEditor) Get(idx uint64) Valuable
- func (le *ListEditor) Insert(idx uint64, vs ...Valuable) *ListEditor
- func (le *ListEditor) Kind() NomsKind
- func (le *ListEditor) Len() uint64
- func (le *ListEditor) List() List
- func (le *ListEditor) Remove(start uint64, end uint64) *ListEditor
- func (le *ListEditor) RemoveAt(idx uint64) *ListEditor
- func (le *ListEditor) Set(idx uint64, v Valuable) *ListEditor
- func (le *ListEditor) Splice(idx uint64, deleteCount uint64, vs ...Valuable) *ListEditor
- func (le *ListEditor) Value() Value
- type ListIterator
- type Map
- func (m Map) Any(cb func(k, v Value) bool) (yep bool)
- func (m Map) At(idx uint64) (key, value Value)
- func (m Map) Diff(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (m Map) DiffHybrid(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (m Map) DiffLeftRight(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (m Map) Edit() *MapEditor
- func (m Map) First() (Value, Value)
- func (m Map) Get(key Value) Value
- func (m Map) Has(key Value) bool
- func (m Map) Iter(cb mapIterCallback)
- func (m Map) IterAll(cb mapIterAllCallback)
- func (m Map) IterFrom(start Value, cb mapIterCallback)
- func (m Map) Iterator() *MapIterator
- func (m Map) IteratorAt(pos uint64) *MapIterator
- func (m Map) IteratorFrom(key Value) *MapIterator
- func (m Map) Last() (Value, Value)
- func (m Map) MaybeGet(key Value) (v Value, ok bool)
- func (m Map) Value() Value
- func (m Map) WalkValues(cb ValueCallback)
- type MapEditor
- func (me *MapEditor) Get(k Value) Valuable
- func (me *MapEditor) Has(k Value) bool
- func (me *MapEditor) Kind() NomsKind
- func (me *MapEditor) Map() Map
- func (me *MapEditor) Remove(k Value) *MapEditor
- func (me *MapEditor) Set(k Value, v Valuable) *MapEditor
- func (me *MapEditor) SetM(kv ...Valuable) *MapEditor
- func (me *MapEditor) Value() Value
- type MapIterator
- type NomsKind
- type Number
- type Path
- type PathPart
- type PrimitiveDesc
- type Ref
- func (v Ref) Equals(other Value) bool
- func (v Ref) Hash() hash.Hash
- func (r Ref) Height() uint64
- func (v Ref) IsZeroValue() bool
- func (v Ref) Kind() NomsKind
- func (v Ref) Less(other Value) bool
- func (r Ref) TargetHash() hash.Hash
- func (r Ref) TargetType() *Type
- func (r Ref) TargetValue(vr ValueReader) Value
- func (r Ref) Value() Value
- func (v Ref) WalkRefs(cb RefCallback)
- func (r Ref) WalkValues(cb ValueCallback)
- type RefByHeight
- func (h *RefByHeight) DropIndices(indices []int)
- func (h RefByHeight) Empty() bool
- func (h RefByHeight) Len() int
- func (h RefByHeight) Less(i, j int) bool
- func (h RefByHeight) MaxHeight() uint64
- func (h RefByHeight) PeekAt(idx int) (peek Ref)
- func (h RefByHeight) PeekEnd() (head Ref)
- func (h *RefByHeight) PopBack() Ref
- func (h *RefByHeight) PopRefsOfHeight(height uint64) (refs RefSlice)
- func (h *RefByHeight) PushBack(r Ref)
- func (h RefByHeight) Swap(i, j int)
- func (h *RefByHeight) Unique()
- type RefCallback
- type RefSlice
- type Set
- func (s Set) At(idx uint64) Value
- func (s Set) Diff(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Set) DiffHybrid(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Set) DiffLeftRight(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Set) Edit() *SetEditor
- func (s Set) First() Value
- func (s Set) Has(v Value) bool
- func (s Set) Iter(cb setIterCallback)
- func (s Set) IterAll(cb setIterAllCallback)
- func (s Set) Iterator() SetIterator
- func (s Set) IteratorAt(idx uint64) SetIterator
- func (s Set) IteratorFrom(val Value) SetIterator
- func (s Set) Value() Value
- func (s Set) WalkValues(cb ValueCallback)
- type SetEditor
- type SetIterator
- type SkipValueCallback
- type Splice
- type String
- type Struct
- func (s Struct) Delete(n string) Struct
- func (s Struct) Diff(last Struct, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Struct) Empty() bool
- func (v Struct) Equals(other Value) bool
- func (s Struct) Get(n string) Value
- func (v Struct) Hash() hash.Hash
- func (v Struct) IsZeroValue() bool
- func (s Struct) IterFields(cb func(name string, value Value) (stop bool))
- func (v Struct) Kind() NomsKind
- func (s Struct) Len() int
- func (v Struct) Less(other Value) bool
- func (s Struct) MaybeGet(n string) (v Value, found bool)
- func (s Struct) Name() string
- func (s Struct) Set(n string, v Value) Struct
- func (s Struct) SetName(name string) Struct
- func (s Struct) Value() Value
- func (v Struct) WalkRefs(cb RefCallback)
- func (s Struct) WalkValues(cb ValueCallback)
- type StructData
- type StructDesc
- type StructField
- type StructTemplate
- type TargetAnnotation
- type Type
- func MakeCycleType(name string) *Type
- func MakeListType(elemType *Type) *Type
- func MakeMapType(keyType, valType *Type) *Type
- func MakePrimitiveType(k NomsKind) *Type
- func MakeRefType(elemType *Type) *Type
- func MakeSetType(elemType *Type) *Type
- func MakeStructType(name string, fields ...StructField) *Type
- func MakeStructTypeFromFields(name string, fields FieldMap) *Type
- func MakeUnionType(elemTypes ...*Type) *Type
- func MakeUnionTypeIntersectStructs(elemTypes ...*Type) *Type
- func TypeOf(v Value) *Type
- func (t *Type) Describe() (out string)
- func (t *Type) Equals(other Value) (res bool)
- func (t *Type) Hash() hash.Hash
- func (t *Type) Kind() NomsKind
- func (t *Type) Less(other Value) (res bool)
- func (t *Type) TargetKind() NomsKind
- func (t *Type) Value() Value
- func (t *Type) WalkRefs(cb RefCallback)
- func (t *Type) WalkValues(cb ValueCallback)
- type TypeAnnotation
- type TypeDesc
- type UnionIterator
- type ValidatingDecoder
- type Valuable
- type Value
- type ValueCallback
- type ValueChanged
- type ValueReadWriter
- type ValueReader
- type ValueSlice
- type ValueStats
- type ValueStore
- func (lvs *ValueStore) ChunkStore() chunks.ChunkStore
- func (lvs *ValueStore) Close() error
- func (lvs *ValueStore) Commit(current, last hash.Hash) bool
- func (lvs *ValueStore) ReadManyValues(hashes hash.HashSlice) ValueSlice
- func (lvs *ValueStore) ReadValue(h hash.Hash) Value
- func (lvs *ValueStore) Rebase()
- func (lvs *ValueStore) Root() hash.Hash
- func (lvs *ValueStore) SetEnforceCompleteness(enforce bool)
- func (lvs *ValueStore) WriteValue(v Value) Ref
- type ValueWriter
Examples ¶
Constants ¶
const ( DEFAULT_MAX_SPLICE_MATRIX_SIZE = 2e7 SPLICE_UNASSIGNED = math.MaxUint64 UNCHANGED = 0 UPDATED = 1 INSERTED = 2 REMOVED = 3 )
Variables ¶
var BlobType = makePrimitiveType(BlobKind)
var BoolType = makePrimitiveType(BoolKind)
var EmptyStruct = newStruct("", nil, nil)
var EmptyStructType = MakeStructType("")
var KindToString = map[NomsKind]string{ BlobKind: "Blob", BoolKind: "Bool", CycleKind: "Cycle", ListKind: "List", MapKind: "Map", NumberKind: "Number", RefKind: "Ref", SetKind: "Set", StructKind: "Struct", StringKind: "String", TypeKind: "Type", UnionKind: "Union", ValueKind: "Value", }
var NumberType = makePrimitiveType(NumberKind)
var StringType = makePrimitiveType(StringKind)
var TypeType = makePrimitiveType(TypeKind)
var ValueType = makePrimitiveType(ValueKind)
Functions ¶
func CamelCaseFieldName ¶
func ContainCommonSupertype ¶
ContainCommonSupertype returns true if it's possible to synthesize a non-trivial (i.e. not empty) supertype from types |a| and |b|.
It is useful for determining whether a subset of values can be extracted from one object to produce another object.
The rules for determining whether |a| and |b| intersect are:
- if either type is Value, return true
- if either type is Union, return true iff at least one variant of |a| intersects with one variant of |b|
- if |a| & |b| are not the same kind, return false
- else
- if both are structs, return true iff their names are equal or one name is "", they share a field name and the type of that field intersects
- if both are refs, sets or lists, return true iff the element type intersects
- if both are maps, return true iff they have a key with the same type and value types that intersect
- else return true
func EncodeValue ¶
func EncodedIndexValue ¶
func EncodedValue ¶
EncodedValue returns a string containing the serialization of a value.
func EncodedValueMaxLines ¶
EncodedValueMaxLines returns a string containing the serialization of a value. The string is truncated at |maxLines|.
func EscapeStructField ¶
EscapeStructField escapes names for use as noms structs with regards to non CSV imported data. Disallowed characters are encoded as 'Q<hex-encoded-utf8-bytes>'. Note that Q itself is also escaped since it is the escape character.
func HasStructCycles ¶
HasStructCycles determines if the type contains any struct cycles.
func HeightOrder ¶
HeightOrder returns true if a is 'higher than' b, generally if its ref-height is greater. If the two are of the same height, fall back to sorting by TargetHash.
func IsPrimitiveKind ¶
IsPrimitiveKind returns true if k represents a Noms primitive type, which excludes collections (List, Map, Set), Refs, Structs, Symbolic and Unresolved types.
func IsSubtype ¶
IsSubtype determines whether concreteType is a subtype of requiredType. For example, `Number` is a subtype of `Number | String`.
func IsSubtypeDisallowExtraStructFields ¶
IsSubtypeDisallowExtraFields is a slightly weird variant of IsSubtype. It returns true IFF IsSubtype(requiredType, concreteType) AND Structs in concreteType CANNOT have field names absent in requiredType ISSUE: https://github.com/ndau/noms/issues/3446
func IsValidStructFieldName ¶
IsValidStructFieldName returns whether the name is valid as a field name in a struct. Valid names must start with `a-zA-Z` and after that `a-zA-Z0-9_`.
func IsValueSubtypeOf ¶
func IsValueSubtypeOfDetails ¶
IsValueSubtypeOfDetails returns two values:
isSub - which indicates whether v is a subtype of t. hasExtra - which indicates whether v has additional fields. This field has no meaning if IsSub is false.
For example, given the following data:
type1 := struct S { v := Struct S1 { a Number | string a: "hello" b ?int b: 2 } }
IsValueSubtypeOfDetails(v, type1) would return isSub == true, and hasExtra == false
And given these types:
type2 := struct S { v := Struct S1 { a Number | string a: "hello" b ?int b: 2 } c: "hello again" }
IsValueSubtypeOfDetails(v, type1) would return isSub == true, and hasExtra == true
func NewStreamingList ¶
func NewStreamingList(vrw ValueReadWriter, values <-chan Value) <-chan List
NewStreamingList creates a new List, populated with values, chunking if and when needed. As chunks are created, they're written to vrw -- including the root chunk of the list. Once the caller has closed values, the caller can read the completed List from the returned channel.
func NewStreamingMap ¶
func NewStreamingMap(vrw ValueReadWriter, kvs <-chan Value) <-chan Map
NewStreamingMap takes an input channel of values and returns a output channel that will produce a finished Map. Values sent to the input channel must be alternating keys and values. (e.g. k1, v1, k2, v2...). Moreover keys need to be added to the channel in Noms sortorder, adding key values to the input channel out of order will result in a panic. Once the input channel is closed by the caller, a finished Map will be sent to the output channel. See graph_builder.go for building collections with values that are not in order.
func NewStreamingSet ¶
func NewStreamingSet(vrw ValueReadWriter, vChan <-chan Value) <-chan Set
NewStreamingSet takes an input channel of values and returns a output channel that will produce a finished Set. Values that are sent to the input channel must be in Noms sortorder, adding values to the input channel out of order will result in a panic. Once the input channel is closed by the caller, a finished Set will be sent to the output channel. See graph_builder.go for building collections with values that are not in order.
func PanicIfDangling ¶
func PanicIfDangling(unresolved hash.HashSet, cs chunks.ChunkStore)
func RegisterHRSCommenter ¶
func RegisterHRSCommenter(typename, unique string, commenter HRSCommenter)
RegisterHRSCommenter is called to with three arguments:
typename: the name of the struct this function will be applied to unique: an arbitrary string to differentiate functions that should be applied to different structs that have the same name (e.g. two implementations of the "Employee" type. commenter: an interface with a 'Comment()' function that gets called for all Values with this name. The function should verify the type of the Value and, if appropriate, return a non-empty string to be appended as the comment
func UnregisterHRSCommenter ¶
func UnregisterHRSCommenter(typename, unique string)
UnregisterHRSCommenter will remove a commenter function for a specified typename/unique string combination.
func ValueCanBePathIndex ¶
func WalkRefs ¶
func WalkRefs(c chunks.Chunk, cb RefCallback)
WalkRefs calls cb() on each Ref that can be decoded from |c|. The results are precisely equal to DecodeValue(c).WalkRefs(cb), but this should be much faster.
func WalkValues ¶
func WalkValues(target Value, vr ValueReader, cb SkipValueCallback)
WalkValues recursively walks over all types.Values reachable from r and calls cb on them.
func WriteEncodedValue ¶
WriteEncodedValue writes the serialization of a value
func WriteEncodedValueMaxLines ¶
WriteEncodedValueMaxLines writes the serialization of a value. Writing will be stopped and an error returned after |maxLines|.
func WriteValueStats ¶
func WriteValueStats(w io.Writer, v Value, vr ValueReader)
Types ¶
type AtAnnotation ¶
type AtAnnotation struct { // Index is the position to resolve at. If negative, it means an index // relative to the end of the collection. Index int64 // IntoKey see IndexPath.IntoKey. IntoKey bool }
AtAnnotation is a PathPart annotation that gets the value of a collection at a position, rather than a key. This is equivalent to IndexPath for lists, but different for sets and maps.
func NewAtAnnotation ¶
func NewAtAnnotation(idx int64) AtAnnotation
func NewAtAnnotationIntoKeyPath ¶
func NewAtAnnotationIntoKeyPath(idx int64) AtAnnotation
func (AtAnnotation) Resolve ¶
func (ann AtAnnotation) Resolve(v Value, vr ValueReader) Value
func (AtAnnotation) String ¶
func (ann AtAnnotation) String() (str string)
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob represents a list of Blobs.
func NewBlob ¶
func NewBlob(vrw ValueReadWriter, rs ...io.Reader) Blob
NewBlob creates a Blob by reading from every Reader in rs and concatenating the result. NewBlob uses one goroutine per Reader.
func NewEmptyBlob ¶
func NewEmptyBlob(vrw ValueReadWriter) Blob
func (Blob) Concat ¶
Concat returns a new Blob comprised of this joined with other. It only needs to visit the rightmost prolly tree chunks of this Blob, and the leftmost prolly tree chunks of other, so it's efficient.
func (Blob) CopyReadAhead ¶
CopyReadAhead copies the entire contents of |b| to |w|, and attempts to stay |concurrency| |chunkSize| blocks of bytes ahead of the last byte written to |w|.
func (Blob) Edit ¶
func (b Blob) Edit() *BlobEditor
func (Blob) ReadAt ¶
ReadAt implements the ReaderAt interface. Eagerly loads requested byte-range from the blob p-tree.
func (Blob) Reader ¶
func (b Blob) Reader() *BlobReader
func (Blob) WalkValues ¶
func (b Blob) WalkValues(cb ValueCallback)
type BlobEditor ¶
type BlobEditor struct {
// contains filtered or unexported fields
}
func NewBlobEditor ¶
func NewBlobEditor(b Blob) *BlobEditor
func (*BlobEditor) Blob ¶
func (be *BlobEditor) Blob() Blob
func (*BlobEditor) Kind ¶
func (be *BlobEditor) Kind() NomsKind
func (*BlobEditor) Len ¶
func (be *BlobEditor) Len() uint64
func (*BlobEditor) Splice ¶
func (be *BlobEditor) Splice(idx uint64, deleteCount uint64, insert []byte) *BlobEditor
func (*BlobEditor) Value ¶
func (be *BlobEditor) Value() Value
type BlobReader ¶
type BlobReader struct {
// contains filtered or unexported fields
}
type Bool ¶
type Bool bool
Bool is a Noms Value wrapper around the primitive bool type.
func (Bool) WalkRefs ¶
func (b Bool) WalkRefs(cb RefCallback)
func (Bool) WalkValues ¶
func (b Bool) WalkValues(cb ValueCallback)
type Collection ¶
type Collection interface { Value Empty() bool Len() uint64 // contains filtered or unexported methods }
func LoadLeafNodes ¶
func LoadLeafNodes(cols []Collection, startIdx, endIdx uint64) ([]Collection, uint64)
LoadLeafNodes loads the set of leaf nodes which contain the items [startIdx -> endIdx). Returns the set of nodes and the offset within the first sequence which corresponds to |startIdx|.
type CompoundDesc ¶
type CompoundDesc struct { ElemTypes typeSlice // contains filtered or unexported fields }
CompoundDesc describes a List, Map, Set, Ref, or Union type. ElemTypes indicates what type or types are in the container indicated by kind, e.g. Map key and value or Set element.
func (CompoundDesc) Kind ¶
func (c CompoundDesc) Kind() NomsKind
type DecodedChunk ¶
DecodedChunk holds a pointer to a Chunk and the Value that results from calling DecodeFromBytes(c.Data()).
type DiffChangeType ¶
type DiffChangeType uint8
const ( DiffChangeAdded DiffChangeType = iota DiffChangeRemoved DiffChangeModified )
type EditDistanceEqualsFn ¶
type FieldPath ¶
type FieldPath struct { // The name of the field, e.g. `.Name`. Name string }
FieldPath references Struct field values by name.
func NewFieldPath ¶
type GraphBuilder ¶
type GraphBuilder struct {
// contains filtered or unexported fields
}
func NewGraphBuilder ¶
func NewGraphBuilder(vrw ValueReadWriter, rootKind NomsKind) *GraphBuilder
NewGraphBuilder returns an new GraphBuilder object.
func (*GraphBuilder) Build ¶
func (b *GraphBuilder) Build() Value
Build builds and returns the graph. This method should only be called after all calls to the mutation operations (i.e. MapSet, SetInsert, and ListAppend) have completed. It is the caller's responsibility to ensure that this is the case. Build() will panic if called more than once on any GraphBuilder object.
Example ¶
vs := newTestValueStore() defer vs.Close() gb := NewGraphBuilder(vs, MapKind) gb.SetInsert([]Value{String("parent"), String("children")}, String("John")) gb.SetInsert([]Value{String("parent"), String("children")}, String("Mary")) gb.SetInsert([]Value{String("parent"), String("children")}, String("Frieda")) gb.MapSet([]Value{String("parent"), String("ages")}, String("Father"), Number(42)) gb.MapSet([]Value{String("parent"), String("ages")}, String("Mother"), Number(44)) gb.ListAppend([]Value{String("parent"), String("chores")}, String("Make dinner")) gb.ListAppend([]Value{String("parent"), String("chores")}, String("Wash dishes")) gb.ListAppend([]Value{String("parent"), String("chores")}, String("Make breakfast")) gb.ListAppend([]Value{String("parent"), String("chores")}, String("Wash dishes")) gb.MapSet([]Value{String("parent")}, String("combinedAge"), Number(86)) m := gb.Build() fmt.Println("map:", EncodedValue(m))
Output:
func (*GraphBuilder) ListAppend ¶
func (b *GraphBuilder) ListAppend(keys []Value, v Value)
ListAppend will append |v| to the list at path |p|. Intermediate maps referenced by |keys| are created as necessary. This is threadsafe, may call from multiple go routines, however append semantics are such that the elements will be appended in order that functions are called, so order has to be managed by caller.
func (*GraphBuilder) MapSet ¶
func (b *GraphBuilder) MapSet(keys []Value, k Value, v Value)
MapSet will add the key/value pair |k, v| to the map found by traversing the graph using the |keys| slice. Intermediate maps referenced by |keys| are created as necessary. This is threadsafe, may call from multiple go routines.
func (*GraphBuilder) SetInsert ¶
func (b *GraphBuilder) SetInsert(keys []Value, v Value)
SetInsert will insert the value |v| into the set at path |keys|. Intermediate maps referenced by |keys| are created as necessary. This is threadsafe, may call from multiple go routines.
type HRSCommenter ¶
Function type for commenter functions
func GetHRSCommenters ¶
func GetHRSCommenters(typename string) []HRSCommenter
GetHRSCommenters the map of 'unique' strings to HRSCommentFunc for a specified typename.
type HashIndexPath ¶
type HashIndexPath struct { // The hash of the key or value to search for. Maps and Set are ordered, so // this in O(log(size)). Hash hash.Hash // Whether this index should resolve to the key of a map, given by a `@key` // annotation. Typically IntoKey is false, and indices would resolve to the // values. E.g. given `{a: 42}` and if the hash of `"a"` is `#abcd`, then // `[#abcd]` resolves to `42`. If IntoKey is true, then it resolves to `"a"`. // This is useful for when Map keys aren't primitive values, e.g. a struct, // since struct literals can't be spelled using a Path. IntoKey bool }
Indexes into Maps by the hash of a key, or a Set by the hash of a value.
func NewHashIndexIntoKeyPath ¶
func NewHashIndexIntoKeyPath(h hash.Hash) HashIndexPath
func NewHashIndexPath ¶
func NewHashIndexPath(h hash.Hash) HashIndexPath
func (HashIndexPath) Resolve ¶
func (hip HashIndexPath) Resolve(v Value, vr ValueReader) (res Value)
func (HashIndexPath) String ¶
func (hip HashIndexPath) String() (str string)
type IndexPath ¶
type IndexPath struct { // The value of the index, e.g. `[42]` or `["value"]`. If Index is a negative // number and the path is resolved in a List, it means index from the back. Index Value // Whether this index should resolve to the key of a map, given by a `@key` // annotation. Typically IntoKey is false, and indices would resolve to the // values. E.g. given `{a: 42}` then `["a"]` resolves to `42`. If IntoKey is // true, then it resolves to `"a"`. For IndexPath this isn't particularly // useful - it's mostly provided for consistency with HashIndexPath - but // note that given `{a: 42}` then `["b"]` resolves to nil, not `"b"`. IntoKey bool }
IndexPath ndexes into Maps and Lists by key or index.
func NewIndexIntoKeyPath ¶
func NewIndexPath ¶
type IntersectionIterator ¶
type IntersectionIterator struct {
// contains filtered or unexported fields
}
IntersectionIterator only returns values that are returned in both of its child iterators. The values from Next() are returned in noms-defined order with all duplicates removed.
func (*IntersectionIterator) Next ¶
func (i *IntersectionIterator) Next() Value
func (*IntersectionIterator) SkipTo ¶
func (i *IntersectionIterator) SkipTo(v Value) Value
type List ¶
type List struct {
// contains filtered or unexported fields
}
List represents a list or an array of Noms values. A list can contain zero or more values of zero or more types. The type of the list will reflect the type of the elements in the list. For example:
l := NewList(Number(1), Bool(true)) fmt.Println(l.Type().Describe()) // outputs List<Bool | Number>
Lists, like all Noms values are immutable so the "mutation" methods return a new list.
func NewList ¶
func NewList(vrw ValueReadWriter, values ...Value) List
NewList creates a new List where the type is computed from the elements in the list, populated with values, chunking if and when needed.
func (List) Concat ¶
Concat returns a new List comprised of this joined with other. It only needs to visit the rightmost prolly tree chunks of this List, and the leftmost prolly tree chunks of other, so it's efficient.
func (List) Diff ¶
Diff streams the diff from last to the current list to the changes channel. Caller can close closeChan to cancel the diff operation.
func (List) DiffWithLimit ¶
func (l List) DiffWithLimit(last List, changes chan<- Splice, closeChan <-chan struct{}, maxSpliceMatrixSize uint64)
DiffWithLimit streams the diff from last to the current list to the changes channel. Caller can close closeChan to cancel the diff operation. The maxSpliceMatrixSize determines the how big of an edit distance matrix we are willing to compute versus just saying the thing changed.
func (List) Edit ¶
func (l List) Edit() *ListEditor
func (List) Get ¶
Get returns the value at the given index. If this list has been chunked then this will have to descend into the prolly-tree which leads to Get being O(depth).
func (List) Iter ¶
Iter iterates over the list and calls f for every element in the list. If f returns true then the iteration stops.
func (List) IterAll ¶
IterAll iterates over the list and calls f for every element in the list. Unlike Iter there is no way to stop the iteration and all elements are visited.
func (List) Iterator ¶
func (l List) Iterator() ListIterator
Iterator returns a ListIterator which can be used to iterate efficiently over a list.
func (List) IteratorAt ¶
func (l List) IteratorAt(index uint64) ListIterator
IteratorAt returns a ListIterator starting at index. If index is out of bound the iterator will have reached its end on creation.
func (List) WalkValues ¶
func (l List) WalkValues(cb ValueCallback)
type ListEditor ¶
type ListEditor struct {
// contains filtered or unexported fields
}
func NewListEditor ¶
func NewListEditor(l List) *ListEditor
func (*ListEditor) Append ¶
func (le *ListEditor) Append(vs ...Valuable) *ListEditor
func (*ListEditor) Get ¶
func (le *ListEditor) Get(idx uint64) Valuable
func (*ListEditor) Insert ¶
func (le *ListEditor) Insert(idx uint64, vs ...Valuable) *ListEditor
func (*ListEditor) Kind ¶
func (le *ListEditor) Kind() NomsKind
func (*ListEditor) Len ¶
func (le *ListEditor) Len() uint64
func (*ListEditor) List ¶
func (le *ListEditor) List() List
func (*ListEditor) Remove ¶
func (le *ListEditor) Remove(start uint64, end uint64) *ListEditor
func (*ListEditor) RemoveAt ¶
func (le *ListEditor) RemoveAt(idx uint64) *ListEditor
func (*ListEditor) Set ¶
func (le *ListEditor) Set(idx uint64, v Valuable) *ListEditor
func (*ListEditor) Splice ¶
func (le *ListEditor) Splice(idx uint64, deleteCount uint64, vs ...Valuable) *ListEditor
func (*ListEditor) Value ¶
func (le *ListEditor) Value() Value
type ListIterator ¶
type ListIterator struct {
// contains filtered or unexported fields
}
ListIterator can be used to efficiently iterate through a Noms List.
func (ListIterator) Next ¶
func (li ListIterator) Next() (out Value)
Next returns subsequent Values from a List, starting with the index at which the iterator was created. If there are no more Values, Next() returns nil.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func NewMap ¶
func NewMap(vrw ValueReadWriter, kv ...Value) Map
func (Map) Diff ¶
func (m Map) Diff(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
Diff computes the diff from |last| to |m| using the top-down algorithm, which completes as fast as possible while taking longer to return early results than left-to-right.
func (Map) DiffHybrid ¶
func (m Map) DiffHybrid(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
DiffHybrid computes the diff from |last| to |m| using a hybrid algorithm which balances returning results early vs completing quickly, if possible.
func (Map) DiffLeftRight ¶
func (m Map) DiffLeftRight(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
DiffLeftRight computes the diff from |last| to |m| using a left-to-right streaming approach, optimised for returning results early, but not completing quickly.
func (Map) Iterator ¶
func (m Map) Iterator() *MapIterator
func (Map) IteratorAt ¶
func (m Map) IteratorAt(pos uint64) *MapIterator
func (Map) IteratorFrom ¶
func (m Map) IteratorFrom(key Value) *MapIterator
func (Map) WalkValues ¶
func (m Map) WalkValues(cb ValueCallback)
type MapEditor ¶
type MapEditor struct {
// contains filtered or unexported fields
}
MapEditor allows for efficient editing of Map-typed prolly trees. Edits are buffered to memory and can be applied via Build(), which returns a new Map. Prior to Build(), Get() & Has() will return the value that the resulting Map would return if it were built immediately prior to the respective call. Note: The implementation biases performance towards a usage which applies edits in key-order.
func NewMapEditor ¶
type MapIterator ¶
type MapIterator struct {
// contains filtered or unexported fields
}
MapIterator can efficiently iterate through a Noms Map.
func (*MapIterator) Entry ¶
func (mi *MapIterator) Entry() (k Value, v Value)
func (*MapIterator) Key ¶
func (mi *MapIterator) Key() Value
func (*MapIterator) Next ¶
func (mi *MapIterator) Next() bool
Next returns the subsequent entries from the Map, starting with the entry at which the iterator was created. If there are no more entries, Next() returns nils.
func (*MapIterator) Position ¶
func (mi *MapIterator) Position() uint64
func (*MapIterator) Prev ¶
func (mi *MapIterator) Prev() bool
Prev returns the previous entry from the Map. If there is no previous entry, Prev() returns nils.
func (*MapIterator) Valid ¶
func (mi *MapIterator) Valid() bool
func (*MapIterator) Value ¶
func (mi *MapIterator) Value() Value
type NomsKind ¶
type NomsKind uint8
NomsKind allows a TypeDesc to indicate what kind of type is described.
const ( BoolKind NomsKind = iota NumberKind StringKind BlobKind ValueKind ListKind MapKind RefKind SetKind // Keep StructKind and CycleKind together. StructKind CycleKind TypeKind UnionKind )
All supported kinds of Noms types are enumerated here. The ordering of these (especially Bool, Number and String) is important for ordering of values.
type Number ¶
type Number float64
Number is a Noms Value wrapper around the primitive float64 type.
func (Number) WalkRefs ¶
func (v Number) WalkRefs(cb RefCallback)
func (Number) WalkValues ¶
func (v Number) WalkValues(cb ValueCallback)
type Path ¶
type Path []PathPart
A Path locates a value in Noms relative to some other value. For locating values absolutely within a database, see AbsolutePath. To locate values globally, see Spec.
For more details, see: https://github.com/ndau/noms/blob/master/doc/spelling.md.
func MustParsePath ¶
MustParsePath parses str into a Path, or panics if parsing failed.
type PrimitiveDesc ¶
type PrimitiveDesc NomsKind
PrimitiveDesc implements TypeDesc for all primitive Noms types: Blob Bool Number String Type Value
func (PrimitiveDesc) Kind ¶
func (p PrimitiveDesc) Kind() NomsKind
type Ref ¶
type Ref struct {
// contains filtered or unexported fields
}
func ToRefOfValue ¶
ToRefOfValue returns a new Ref that points to the same target as |r|, but with the type 'Ref<Value>'.
func (Ref) IsZeroValue ¶
func (v Ref) IsZeroValue() bool
IsZeroValue can be used to test if a Value is the same as T{}.
func (Ref) TargetHash ¶
func (Ref) TargetType ¶
func (Ref) TargetValue ¶
func (r Ref) TargetValue(vr ValueReader) Value
func (Ref) WalkRefs ¶
func (v Ref) WalkRefs(cb RefCallback)
func (Ref) WalkValues ¶
func (r Ref) WalkValues(cb ValueCallback)
type RefByHeight ¶
type RefByHeight []Ref
RefByHeight implements sort.Interface to order by increasing HeightOrder(). It uses increasing order because this causes repeated pushes and pops of the 'tallest' Refs to re-use memory, avoiding reallocations. We might consider making this a firmer abstraction boundary as a part of BUG 2182
func (*RefByHeight) DropIndices ¶
func (h *RefByHeight) DropIndices(indices []int)
DropIndices takes a slice of integer indices into h and splices out the Refs at those indices.
func (RefByHeight) Empty ¶
func (h RefByHeight) Empty() bool
func (RefByHeight) Len ¶
func (h RefByHeight) Len() int
func (RefByHeight) Less ¶
func (h RefByHeight) Less(i, j int) bool
func (RefByHeight) MaxHeight ¶
func (h RefByHeight) MaxHeight() uint64
MaxHeight returns the height of the 'tallest' Ref in h.
func (RefByHeight) PeekAt ¶
func (h RefByHeight) PeekAt(idx int) (peek Ref)
PeekAt returns, but does not remove, the Ref at h[idx]. If the index is out of range, returns the empty Ref.
func (RefByHeight) PeekEnd ¶
func (h RefByHeight) PeekEnd() (head Ref)
PeekEnd returns, but does not Pop the tallest Ref in h.
func (*RefByHeight) PopBack ¶
func (h *RefByHeight) PopBack() Ref
func (*RefByHeight) PopRefsOfHeight ¶
func (h *RefByHeight) PopRefsOfHeight(height uint64) (refs RefSlice)
PopRefsOfHeight pops off and returns all refs r in h for which r.Height() == height.
func (*RefByHeight) PushBack ¶
func (h *RefByHeight) PushBack(r Ref)
func (RefByHeight) Swap ¶
func (h RefByHeight) Swap(i, j int)
func (*RefByHeight) Unique ¶
func (h *RefByHeight) Unique()
type RefCallback ¶
type RefCallback func(ref Ref)
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func NewSet ¶
func NewSet(vrw ValueReadWriter, v ...Value) Set
func (Set) Diff ¶
func (s Set) Diff(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
Diff computes the diff from |last| to |m| using the top-down algorithm, which completes as fast as possible while taking longer to return early results than left-to-right.
func (Set) DiffHybrid ¶
func (s Set) DiffHybrid(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
DiffHybrid computes the diff from |last| to |s| using a hybrid algorithm which balances returning results early vs completing quickly, if possible.
func (Set) DiffLeftRight ¶
func (s Set) DiffLeftRight(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
DiffLeftRight computes the diff from |last| to |s| using a left-to-right streaming approach, optimised for returning results early, but not completing quickly.
func (Set) Iterator ¶
func (s Set) Iterator() SetIterator
func (Set) IteratorAt ¶
func (s Set) IteratorAt(idx uint64) SetIterator
func (Set) IteratorFrom ¶
func (s Set) IteratorFrom(val Value) SetIterator
func (Set) WalkValues ¶
func (s Set) WalkValues(cb ValueCallback)
type SetEditor ¶
type SetEditor struct {
// contains filtered or unexported fields
}
SetEditor allows for efficient editing of Set-typed prolly trees. Edits are buffered to memory and can be applied via Build(), which returns a new Set. Prior to Build(), Get() & Has() will return the value that the resulting Set would return if it were built immediately prior to the respective call. Note: The implementation biases performance towards a usage which applies edits in key-order.
func NewSetEditor ¶
type SetIterator ¶
type SetIterator interface { // Next returns subsequent values from a set. It returns nil, when no objects remain. Next() Value // SkipTo(v) advances to and returns the next value in the iterator >= v. // Note: if the iterator has already returned the value being skipped to, it will return the next // value (just as if Next() was called). For example, given the following set: // s = Set{ 0, 3, 6, 9, 12, 15, 18 } // An iterator on the set would return: // i := s.Iterator() // i.Next() return 0 // i.SkipTo(4) -- returns 6 // i.skipTo(3) -- returns 9 (this is the next value in the iterator >= 3) // i.skipTo(12) -- returns 12 // i.skipTo(12) -- return 15 (this is the next value in the iterator >= 12) // i.skipTo(20) -- returns nil // If there are no values left in the iterator that are >= v, // the iterator will skip to the end of the sequence and return nil. SkipTo(v Value) Value }
SetIterator defines methods that can be used to efficiently iterate through a set in 'Noms-defined' sorted order.
func NewIntersectionIterator ¶
func NewIntersectionIterator(iterA, iterB SetIterator) SetIterator
NewIntersectionIterator creates a intersect iterator from two other SetIterators.
func NewUnionIterator ¶
func NewUnionIterator(iterA, iterB SetIterator) SetIterator
NewUnionIterator creates a union iterator from two other SetIterators.
type SkipValueCallback ¶
type Splice ¶
Read a Splice as "at SpAt (in the previous state), SpRemoved elements were removed and SpAdded elements were inserted, which can be found starting at SpFrom in the current state"
type String ¶
type String string
String is a Noms Value wrapper around the primitive string type.
func (String) WalkRefs ¶
func (s String) WalkRefs(cb RefCallback)
func (String) WalkValues ¶
func (s String) WalkValues(cb ValueCallback)
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
func NewStruct ¶
func NewStruct(name string, data StructData) Struct
func (Struct) Delete ¶
Delete returns a new struct where the field name has been removed. If name is not an existing field in the struct then the current struct is returned.
func (Struct) Diff ¶
func (s Struct) Diff(last Struct, changes chan<- ValueChanged, closeChan <-chan struct{})
func (Struct) Get ¶
Get returns the value of a field in the struct. If the struct does not a have a field with the name name then this panics.
func (Struct) IsZeroValue ¶
func (v Struct) IsZeroValue() bool
IsZeroValue can be used to test if a Value is the same as T{}.
func (Struct) IterFields ¶
IterFields iterates over the fields, calling cb for every field in the struct.
func (Struct) MaybeGet ¶
MaybeGet returns the value of a field in the struct. If the struct does not a have a field with the name name then this returns (nil, false).
func (Struct) Set ¶
Set returns a new struct where the field name has been set to value. If name is not an existing field in the struct or the type of value is different from the old value of the struct field a new struct type is created.
func (Struct) WalkRefs ¶
func (v Struct) WalkRefs(cb RefCallback)
func (Struct) WalkValues ¶
func (s Struct) WalkValues(cb ValueCallback)
type StructData ¶
type StructDesc ¶
type StructDesc struct { Name string // contains filtered or unexported fields }
StructDesc describes a custom Noms Struct.
func (StructDesc) IterFields ¶
func (s StructDesc) IterFields(cb func(name string, t *Type, optional bool))
func (StructDesc) Kind ¶
func (s StructDesc) Kind() NomsKind
func (StructDesc) Len ¶
func (s StructDesc) Len() int
Len returns the number of fields in the struct
type StructField ¶
StructField describes a field in a struct type.
type StructTemplate ¶
type StructTemplate struct {
// contains filtered or unexported fields
}
StructTemplate allows creating a template for structs with a known shape (name and fields). If a lot of structs of the same shape are being created then using a StructTemplate makes that slightly more efficient.
func MakeStructTemplate ¶
func MakeStructTemplate(name string, fieldNames []string) (t StructTemplate)
MakeStructTemplate creates a new StructTemplate or panics if the name and fields are not valid.
func (StructTemplate) NewStruct ¶
func (st StructTemplate) NewStruct(values []Value) Struct
NewStruct creates a new Struct from the StructTemplate. The order of the values must match the order of the field names of the StructTemplate.
type TargetAnnotation ¶
type TargetAnnotation struct { }
TargetAnnotation is a PathPart annotation to resolve to the targetValue of the Ref it is resolved on.
func (TargetAnnotation) Resolve ¶
func (ann TargetAnnotation) Resolve(v Value, vr ValueReader) Value
func (TargetAnnotation) String ¶
func (ann TargetAnnotation) String() string
type Type ¶
type Type struct {
Desc TypeDesc
}
func MakeCycleType ¶
func MakeListType ¶
func MakeMapType ¶
func MakePrimitiveType ¶
func MakeRefType ¶
func MakeSetType ¶
func MakeStructType ¶
func MakeStructType(name string, fields ...StructField) *Type
func MakeUnionType ¶
MakeUnionType creates a new union type unless the elemTypes can be folded into a single non union type.
func MakeUnionTypeIntersectStructs ¶
MakeUnionTypeIntersectStructs is a bit of strange function. It creates a simplified union type except for structs, where it creates interesection types. This function will go away so do not use it!
func TypeOf ¶
TypeOf returns the type describing the value. This is not an exact type but often a simplification of the concrete type.
func (*Type) TargetKind ¶
func (*Type) WalkRefs ¶
func (t *Type) WalkRefs(cb RefCallback)
func (*Type) WalkValues ¶
func (t *Type) WalkValues(cb ValueCallback)
type TypeAnnotation ¶
type TypeAnnotation struct { }
TypeAnnotation is a PathPart annotation to resolve to the type of the value it's resolved in.
func (TypeAnnotation) Resolve ¶
func (ann TypeAnnotation) Resolve(v Value, vr ValueReader) Value
func (TypeAnnotation) String ¶
func (ann TypeAnnotation) String() string
type TypeDesc ¶
type TypeDesc interface { Kind() NomsKind // contains filtered or unexported methods }
TypeDesc describes a type of the kind returned by Kind(), e.g. Map, Number, or a custom type.
type UnionIterator ¶
type UnionIterator struct {
// contains filtered or unexported fields
}
UnionIterator combines the results from two other iterators. The values from Next() are returned in noms-defined order with all duplicates removed.
func (*UnionIterator) Next ¶
func (u *UnionIterator) Next() Value
func (*UnionIterator) SkipTo ¶
func (u *UnionIterator) SkipTo(v Value) Value
type ValidatingDecoder ¶
type ValidatingDecoder struct {
// contains filtered or unexported fields
}
func NewValidatingDecoder ¶
func NewValidatingDecoder(cs chunks.ChunkStore) *ValidatingDecoder
func (*ValidatingDecoder) Decode ¶
func (vbs *ValidatingDecoder) Decode(c *chunks.Chunk) DecodedChunk
Decode decodes c and checks that the hash of the resulting value matches c.Hash(). It returns a DecodedChunk holding both c and a pointer to the decoded Value.
type Valuable ¶
type Valuable interface { // Kind is the NomsKind describing the kind of value this is. Kind() NomsKind Value() Value }
Valuable is an interface from which a Value can be retrieved.
type Value ¶
type Value interface { Valuable // Equals determines if two different Noms values represents the same underlying value. Equals(other Value) bool // Less determines if this Noms value is less than another Noms value. // When comparing two Noms values and both are comparable and the same type (Bool, Number or // String) then the natural ordering is used. For other Noms values the Hash of the value is // used. When comparing Noms values of different type the following ordering is used: // Bool < Number < String < everything else. Less(other Value) bool // Hash is the hash of the value. All Noms values have a unique hash and if two values have the // same hash they must be equal. Hash() hash.Hash // WalkValues iterates over the immediate children of this value in the DAG, if any, not including // Type() WalkValues(ValueCallback) // WalkRefs iterates over the refs to the underlying chunks. If this value is a collection that has been // chunked then this will return the refs of th sub trees of the prolly-tree. WalkRefs(RefCallback) // contains filtered or unexported methods }
Value is the interface all Noms values implement.
func DecodeFromBytes ¶
func DecodeFromBytes(data []byte, vrw ValueReadWriter) Value
func DecodeValue ¶
func DecodeValue(c chunks.Chunk, vrw ValueReadWriter) Value
DecodeValue decodes a value from a chunk source. It is an error to provide an empty chunk.
type ValueCallback ¶
type ValueCallback func(v Value)
type ValueChanged ¶
type ValueChanged struct { ChangeType DiffChangeType Key, OldValue, NewValue Value }
type ValueReadWriter ¶
type ValueReadWriter interface { ValueReader ValueWriter }
ValueReadWriter is an interface that knows how to read and write Noms Values, e.g. datas/Database. Required to avoid import cycle between this package and the package that implements Value read/writing.
type ValueReader ¶
type ValueReader interface { ReadValue(h hash.Hash) Value ReadManyValues(hashes hash.HashSlice) ValueSlice }
ValueReader is an interface that knows how to read Noms Values, e.g. datas/Database. Required to avoid import cycle between this package and the package that implements Value reading.
type ValueSlice ¶
type ValueSlice []Value
func (ValueSlice) Contains ¶
func (vs ValueSlice) Contains(v Value) bool
func (ValueSlice) Equals ¶
func (vs ValueSlice) Equals(other ValueSlice) bool
func (ValueSlice) Len ¶
func (vs ValueSlice) Len() int
func (ValueSlice) Less ¶
func (vs ValueSlice) Less(i, j int) bool
func (ValueSlice) Swap ¶
func (vs ValueSlice) Swap(i, j int)
type ValueStats ¶
type ValueStats interface {
String() string
}
type ValueStore ¶
type ValueStore struct {
// contains filtered or unexported fields
}
ValueStore provides methods to read and write Noms Values to a ChunkStore. It minimally validates Values as they're written, but does not guarantee that these Values are persisted through the ChunkStore until a subsequent Flush. Currently, WriteValue validates the following properties of a Value v: - v can be correctly serialized and its Ref taken
func NewValueStore ¶
func NewValueStore(cs chunks.ChunkStore) *ValueStore
NewValueStore returns a ValueStore instance that owns the provided ChunkStore and manages its lifetime. Calling Close on the returned ValueStore will Close() cs.
func (*ValueStore) ChunkStore ¶
func (lvs *ValueStore) ChunkStore() chunks.ChunkStore
func (*ValueStore) Close ¶
func (lvs *ValueStore) Close() error
Close closes the underlying ChunkStore
func (*ValueStore) Commit ¶
func (lvs *ValueStore) Commit(current, last hash.Hash) bool
Commit() flushes all bufferedChunks into the ChunkStore, with best-effort locality, and attempts to Commit, updating the root to |current| (or keeping it the same as Root()). If the root has moved since this ValueStore was opened, or last Rebased(), it will return false and will have internally rebased. Until Commit() succeeds, no work of the ValueStore will be visible to other readers of the underlying ChunkStore.
func (*ValueStore) ReadManyValues ¶
func (lvs *ValueStore) ReadManyValues(hashes hash.HashSlice) ValueSlice
ReadManyValues reads and decodes Values indicated by |hashes| from lvs and returns the found Values in the same order. Any non-present Values will be represented by nil.
func (*ValueStore) ReadValue ¶
func (lvs *ValueStore) ReadValue(h hash.Hash) Value
ReadValue reads and decodes a value from lvs. It is not considered an error for the requested chunk to be empty; in this case, the function simply returns nil.
func (*ValueStore) Rebase ¶
func (lvs *ValueStore) Rebase()
func (*ValueStore) Root ¶
func (lvs *ValueStore) Root() hash.Hash
func (*ValueStore) SetEnforceCompleteness ¶
func (lvs *ValueStore) SetEnforceCompleteness(enforce bool)
func (*ValueStore) WriteValue ¶
func (lvs *ValueStore) WriteValue(v Value) Ref
WriteValue takes a Value, schedules it to be written it to lvs, and returns an appropriately-typed types.Ref. v is not guaranteed to be actually written until after Flush().
type ValueWriter ¶
ValueWriter is an interface that knows how to write Noms Values, e.g. datas/Database. Required to avoid import cycle between this package and the package that implements Value writing.
Source Files ¶
- blob.go
- blob_editor.go
- blob_leaf_sequence.go
- bool.go
- codec.go
- collection.go
- common_supertype.go
- edit_distance.go
- encode_human_readable.go
- get_hash.go
- graph_builder.go
- indexed_sequence_diff.go
- indexed_sequences.go
- leaf_sequence.go
- less.go
- list.go
- list_editor.go
- list_iterator.go
- list_leaf_sequence.go
- make_type.go
- map.go
- map_editor.go
- map_iterator.go
- map_leaf_sequence.go
- meta_sequence.go
- noms_kind.go
- number.go
- number_util.go
- opcache.go
- opcache_compare.go
- ordered_sequences.go
- ordered_sequences_diff.go
- path.go
- ref.go
- ref_heap.go
- rolling_value_hasher.go
- rungen.go
- sequence.go
- sequence_chunker.go
- sequence_concat.go
- sequence_cursor.go
- set.go
- set_editor.go
- set_iterator.go
- set_leaf_sequence.go
- simplify.go
- string.go
- struct.go
- subtype.go
- type.go
- type_desc.go
- validate_type.go
- validating_decoder.go
- value.go
- value_decoder.go
- value_stats.go
- value_store.go
- walk.go
- walk_refs.go