Documentation ¶
Overview ¶
Package types contains most of the data structures available to/from Noms.
Index ¶
- Constants
- Variables
- func CamelCaseFieldName(input string) string
- func EncodeValue(v Value, vw ValueWriter) chunks.Chunk
- func EncodedIndexValue(v Value) string
- func EncodedValue(v Value) string
- func EncodedValueMaxLines(v Value, maxLines uint32) string
- func EncodedValueWithTags(v Value) string
- func EnsureHash(h *hash.Hash, v Value) hash.Hash
- func EscapeStructField(input string) string
- func HeightOrder(a, b Ref) bool
- func IsPrimitiveKind(k NomsKind) bool
- func IsSubtype(requiredType, concreteType *Type) bool
- func IsValidStructFieldName(name string) bool
- func NewStreamingList(vrw ValueReadWriter, values <-chan Value) <-chan List
- func NewStreamingMap(vrw ValueReadWriter, kvs <-chan Value) <-chan Map
- func NewStreamingSet(vrw ValueReadWriter, vals <-chan Value) <-chan Set
- func ValueCanBePathIndex(v Value) bool
- func WriteEncodedValue(w io.Writer, v Value) error
- func WriteEncodedValueMaxLines(w io.Writer, v Value, maxLines uint32) error
- func WriteEncodedValueWithTags(w io.Writer, v Value) error
- type BatchStore
- type BatchStoreAdaptor
- func (bsa *BatchStoreAdaptor) AddHints(hints Hints)
- func (bsa *BatchStoreAdaptor) Close() error
- func (bsa *BatchStoreAdaptor) Flush()
- func (bsa *BatchStoreAdaptor) Get(h hash.Hash) chunks.Chunk
- func (bsa *BatchStoreAdaptor) Root() hash.Hash
- func (bsa *BatchStoreAdaptor) SchedulePut(c chunks.Chunk, refHeight uint64, hints Hints)
- func (bsa *BatchStoreAdaptor) UpdateRoot(current, last hash.Hash) bool
- type Blob
- func (b Blob) Concat(other Blob) Blob
- func (b Blob) Empty() bool
- func (b Blob) Equals(other Value) bool
- func (b Blob) Hash() hash.Hash
- func (b Blob) Len() uint64
- func (b Blob) Less(other Value) bool
- func (b Blob) Reader() io.ReadSeeker
- func (b Blob) Splice(idx uint64, deleteCount uint64, data []byte) Blob
- func (b Blob) Type() *Type
- func (b Blob) WalkRefs(cb RefCallback)
- func (b Blob) WalkValues(cb ValueCallback)
- type BlobReader
- type Bool
- type Collection
- type CompoundDesc
- type CycleDesc
- type DecodedChunk
- type DiffChangeType
- type EditDistanceEqualsFn
- type FieldMap
- type FieldPath
- type GraphBuilder
- type HashIndexPath
- type Hints
- type IndexPath
- type IntersectionIterator
- type List
- func (l List) Append(vs ...Value) 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) Empty() bool
- func (l List) Equals(other Value) bool
- func (l List) Get(idx uint64) Value
- func (l List) Hash() hash.Hash
- func (l List) Insert(idx uint64, vs ...Value) List
- func (l List) Iter(f listIterFunc)
- func (l List) IterAll(f listIterAllFunc)
- func (l List) Iterator() ListIterator
- func (l List) IteratorAt(index uint64) ListIterator
- func (l List) Len() uint64
- func (l List) Less(other Value) bool
- func (l List) Map(mf MapFunc) []interface{}deprecated
- func (l List) Remove(start uint64, end uint64) List
- func (l List) RemoveAt(idx uint64) List
- func (l List) Set(idx uint64, v Value) List
- func (l List) Splice(idx uint64, deleteCount uint64, vs ...Value) List
- func (l List) Type() *Type
- func (l List) WalkRefs(cb RefCallback)
- func (l List) WalkValues(cb ValueCallback)
- type ListIterator
- type Map
- func (m Map) Diff(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (m Map) DiffLeftRight(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (m Map) Empty() bool
- func (m Map) Equals(other Value) bool
- func (m Map) First() (Value, Value)
- func (m Map) Get(key Value) Value
- func (m Map) Has(key Value) bool
- func (m Map) Hash() hash.Hash
- func (m Map) Iter(cb mapIterCallback)
- func (m Map) IterAll(cb mapIterAllCallback)
- func (m Map) IterFrom(start Value, cb mapIterCallback)
- func (m Map) Last() (Value, Value)
- func (m Map) Len() uint64
- func (m Map) Less(other Value) bool
- func (m Map) MaybeGet(key Value) (v Value, ok bool)
- func (m Map) Remove(k Value) Map
- func (m Map) Set(key Value, val Value) Map
- func (m Map) SetM(kv ...Value) Map
- func (m Map) Type() *Type
- func (m Map) WalkRefs(cb RefCallback)
- func (m Map) WalkValues(cb ValueCallback)
- type MapFunc
- type NomsKind
- type Number
- type Path
- type PathPart
- type PrimitiveDesc
- type Ref
- func (r Ref) Equals(other Value) bool
- func (r Ref) Hash() hash.Hash
- func (r Ref) Height() uint64
- func (r Ref) Less(other Value) bool
- func (r Ref) TargetHash() hash.Hash
- func (r Ref) TargetValue(vr ValueReader) Value
- func (r Ref) Type() *Type
- func (r 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) Diff(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Set) DiffLeftRight(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Set) Empty() bool
- func (s Set) Equals(other Value) bool
- func (s Set) First() Value
- func (s Set) Has(v Value) bool
- func (s Set) Hash() hash.Hash
- func (s Set) Insert(values ...Value) Set
- func (s Set) Iter(cb setIterCallback)
- func (s Set) IterAll(cb setIterAllCallback)
- func (s Set) Iterator() SetIterator
- func (s Set) Len() uint64
- func (s Set) Less(other Value) bool
- func (s Set) Remove(values ...Value) Set
- func (s Set) Type() *Type
- func (s Set) WalkRefs(cb RefCallback)
- func (s Set) WalkValues(cb ValueCallback)
- type SetIterator
- type Splice
- type String
- type Struct
- func (s Struct) Diff(last Struct, changes chan<- ValueChanged, closeChan <-chan struct{})
- func (s Struct) Equals(other Value) bool
- func (s Struct) Get(n string) Value
- func (s Struct) Hash() hash.Hash
- func (s Struct) Less(other Value) bool
- func (s Struct) MaybeGet(n string) (Value, bool)
- func (s Struct) Set(n string, v Value) Struct
- func (s Struct) Type() *Type
- func (s Struct) WalkRefs(cb RefCallback)
- func (s Struct) WalkValues(cb ValueCallback)
- type StructData
- type StructDesc
- type Type
- func MakeCycleType(level uint32) *Type
- func MakeListType(elemType *Type) *Type
- func MakeMapType(keyType, valType *Type) *Type
- func MakePrimitiveType(k NomsKind) *Type
- func MakePrimitiveTypeByString(p string) *Type
- func MakeRefType(elemType *Type) *Type
- func MakeSetType(elemType *Type) *Type
- func MakeStructType(name string, fieldNames []string, fieldTypes []*Type) *Type
- func MakeStructTypeFromFields(name string, fields FieldMap) *Type
- func MakeUnionType(elemTypes ...*Type) *Type
- func (t *Type) Describe() (out string)
- func (t *Type) Equals(other Value) (res bool)
- func (t *Type) HasUnresolvedCycle() bool
- func (t *Type) Hash() hash.Hash
- func (t *Type) Kind() NomsKind
- func (t *Type) Less(other Value) (res bool)
- func (t *Type) Type() *Type
- func (t *Type) WalkRefs(cb RefCallback)
- func (t *Type) WalkValues(cb ValueCallback)
- type TypeCache
- type TypeDesc
- type TypeMap
- type UnionIterator
- type ValidatingBatchingSink
- func (vbs *ValidatingBatchingSink) DecodeUnqueued(c *chunks.Chunk) DecodedChunk
- func (vbs *ValidatingBatchingSink) Enqueue(c chunks.Chunk, v Value) chunks.BackpressureError
- func (vbs *ValidatingBatchingSink) Flush() (err chunks.BackpressureError)
- func (vbs *ValidatingBatchingSink) Prepare(hints Hints)
- type Value
- type ValueCallback
- type ValueChanged
- type ValueReadWriter
- type ValueReader
- type ValueSlice
- type ValueStore
- 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 = Struct{ValueSlice{}, EmptyStructType, &hash.Hash{}}
var EmptyStructType = MakeStructType("", []string{}, []*Type{})
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 EncodeValue ¶
func EncodeValue(v Value, vw ValueWriter) chunks.Chunk
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 EncodedValueWithTags ¶
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 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 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 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
func NewStreamingSet ¶
func NewStreamingSet(vrw ValueReadWriter, vals <-chan Value) <-chan Set
func ValueCanBePathIndex ¶
func WriteEncodedValue ¶
WriteEncodedValue writes the serialization of a value
func WriteEncodedValueMaxLines ¶
WriteEncodedValue writes the serialization of a value. Writing will be stopped and an error returned after |maxLines|.
Types ¶
type BatchStore ¶
type BatchStore interface { // Get returns from the store the Value Chunk by h. If h is absent from the store, chunks.EmptyChunk is returned. Get(h hash.Hash) chunks.Chunk // SchedulePut enqueues a write for the Chunk c with the given refHeight. Typically, the Value which was encoded to provide c can also be queried for its refHeight. The call may or may not block until c is persisted. The provided hints are used to assist in validation. Validation requires checking that all refs embedded in c are themselves valid, which could naively be done by resolving each one. Instead, hints provides a (smaller) set of refs that point to Chunks that themselves contain many of c's refs. Thus, by checking only the hinted Chunks, c can be validated with fewer read operations. // c may or may not be persisted when Put() returns, but is guaranteed to be persistent after a call to Flush() or Close(). SchedulePut(c chunks.Chunk, refHeight uint64, hints Hints) // AddHints allows additional hints, as used by SchedulePut, to be added for use in the current batch. AddHints(hints Hints) // Flush causes enqueued Puts to be persisted. Flush() chunks.RootTracker io.Closer }
BatchStore provides an interface similar to chunks.ChunkStore, but batch-oriented. Instead of Put(), it provides SchedulePut(), which enqueues a Chunk to be sent at a possibly later time.
func NewBatchStoreAdaptor ¶
func NewBatchStoreAdaptor(cs chunks.ChunkStore) BatchStore
NewBatchStoreAdaptor returns a BatchStore instance backed by a ChunkStore. Takes ownership of cs and manages its lifetime; calling Close on the returned BatchStore will Close cs.
type BatchStoreAdaptor ¶
type BatchStoreAdaptor struct {
// contains filtered or unexported fields
}
BatchStoreAdaptor provides a naive implementation of BatchStore should only be used with ChunkStores that can Put relatively quickly. It provides no actual batching or validation. Its intended use is for adapting a ChunkStore for use in something that requires a BatchStore.
func (*BatchStoreAdaptor) AddHints ¶
func (bsa *BatchStoreAdaptor) AddHints(hints Hints)
AddHints is a noop.
func (*BatchStoreAdaptor) Close ¶
func (bsa *BatchStoreAdaptor) Close() error
Close closes the underlying ChunkStore
func (*BatchStoreAdaptor) Get ¶
func (bsa *BatchStoreAdaptor) Get(h hash.Hash) chunks.Chunk
Get simply proxies to the backing ChunkStore
func (*BatchStoreAdaptor) Root ¶
func (bsa *BatchStoreAdaptor) Root() hash.Hash
func (*BatchStoreAdaptor) SchedulePut ¶
func (bsa *BatchStoreAdaptor) SchedulePut(c chunks.Chunk, refHeight uint64, hints Hints)
SchedulePut simply calls Put on the underlying ChunkStore, and ignores hints.
func (*BatchStoreAdaptor) UpdateRoot ¶
func (bsa *BatchStoreAdaptor) UpdateRoot(current, last hash.Hash) bool
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blob represents a list of Blobs.
func NewBlob ¶
NewBlob creates a Blob by reading from every Reader in rs and concatenating the result. NewBlob uses one goroutine per Reader. Chunks are kept in memory as they're created - to reduce memory pressure and write to disk instead, use NewStreamingBlob with a non-nil reader.
func NewEmptyBlob ¶
func NewEmptyBlob() Blob
func NewStreamingBlob ¶
func NewStreamingBlob(vrw ValueReadWriter, rs ...io.Reader) Blob
NewStreamingBlob creates a Blob by reading from every Reader in rs and concatenating the result. NewStreamingBlob uses one goroutine per Reader. If vrw is not nil, chunks are written to vrw instead of kept in memory.
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) Reader ¶
func (b Blob) Reader() io.ReadSeeker
BUG 155 - Should provide Write... Maybe even have Blob implement ReadWriteSeeker
func (Blob) WalkRefs ¶
func (b Blob) WalkRefs(cb RefCallback)
func (Blob) WalkValues ¶
func (b Blob) WalkValues(cb ValueCallback)
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 (v Bool) WalkRefs(cb RefCallback)
func (Bool) WalkValues ¶
func (v Bool) WalkValues(cb ValueCallback)
type Collection ¶
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) HasUnresolvedCycle ¶
func (c CompoundDesc) HasUnresolvedCycle(visited []*Type) bool
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 }
Gets 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, verbose bool) *GraphBuilder
NewGraphBuilder() returns an new GraphBuilder object.
func (*GraphBuilder) Build ¶
func (b *GraphBuilder) Build() Value
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, false) 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)
ListAppends() 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 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) (res Value)
func (HashIndexPath) String ¶
func (hip HashIndexPath) String() string
type Hints ¶
Hints are a set of hashes that should be used to speed up the validation of one or more Chunks.
type IndexPath ¶
type IndexPath struct { // The value of the index, e.g. `[42]` or `["value"]`. 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 }
Indexes 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 ¶
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) 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 ¶
func (l List) Iter(f listIterFunc)
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 ¶
func (l List) IterAll(f listIterAllFunc)
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) Remove ¶
Remove returns a new list where the items at index start (inclusive) through end (exclusive) have been removed. This panics if end is smaller than start.
func (List) RemoveAt ¶
RemoveAt returns a new list where a single element at index idx have been removed.
func (List) Set ¶
Set returns a new list where the valie at the given index have been replaced with v. If idx is out bounds then this panics.
func (List) Splice ¶
Splice returns a new list where deleteCount values have been removed at idx and vs have been inserted instead. This function panics if idx or deleteCount is out of bounds.
func (List) WalkRefs ¶
func (l List) WalkRefs(cb RefCallback)
func (List) WalkValues ¶
func (l List) WalkValues(cb ValueCallback)
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 (Map) Diff ¶
func (m Map) Diff(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
Computes the diff from |last| to |m| using "best" algorithm, which balances returning results early vs completing quickly.
func (Map) DiffLeftRight ¶
func (m Map) DiffLeftRight(last Map, changes chan<- ValueChanged, closeChan <-chan struct{})
Like Diff() but uses a left-to-right streaming approach, optimised for returning results early, but not completing quickly.
func (Map) WalkRefs ¶
func (m Map) WalkRefs(cb RefCallback)
func (Map) WalkValues ¶
func (m Map) WalkValues(cb ValueCallback)
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 StructKind TypeKind CycleKind // Only used in encoding/decoding. 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 is an address to a Noms value - and unlike hashes (i.e. #abcd...) they can address inlined values. See https://github.com/attic-labs/noms/blob/master/doc/spelling.md.
type PrimitiveDesc ¶
type PrimitiveDesc NomsKind
PrimitiveDesc implements TypeDesc for all primitive Noms types: Blob Bool Number Package String Type Value
func (PrimitiveDesc) HasUnresolvedCycle ¶
func (p PrimitiveDesc) HasUnresolvedCycle(visited []*Type) bool
func (PrimitiveDesc) Kind ¶
func (p PrimitiveDesc) Kind() NomsKind
type Ref ¶
type Ref struct {
// contains filtered or unexported fields
}
func (Ref) TargetHash ¶
func (Ref) TargetValue ¶
func (r Ref) TargetValue(vr ValueReader) Value
func (Ref) WalkRefs ¶
func (r 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 (Set) Diff ¶
func (s Set) Diff(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
Computes the diff from |last| to |s| using "best" algorithm, which balances returning results early vs completing quickly.
func (Set) DiffLeftRight ¶
func (s Set) DiffLeftRight(last Set, changes chan<- ValueChanged, closeChan <-chan struct{})
Like Diff() but uses 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) WalkRefs ¶
func (s Set) WalkRefs(cb RefCallback)
func (Set) WalkValues ¶
func (s Set) WalkValues(cb ValueCallback)
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 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 NewStructWithType ¶
func NewStructWithType(t *Type, data ValueSlice) Struct
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) 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 (s 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) Field ¶
func (s StructDesc) Field(name string) *Type
func (StructDesc) HasUnresolvedCycle ¶
func (s StructDesc) HasUnresolvedCycle(visited []*Type) bool
func (StructDesc) IterFields ¶
func (s StructDesc) IterFields(cb func(name string, t *Type))
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 Type ¶
type Type struct { Desc TypeDesc // contains filtered or unexported fields }
func MakeCycleType ¶
func MakeListType ¶
func MakeMapType ¶
func MakePrimitiveType ¶
func MakeRefType ¶
func MakeSetType ¶
func MakeStructType ¶
func MakeUnionType ¶
func (*Type) HasUnresolvedCycle ¶
func (*Type) WalkRefs ¶
func (t *Type) WalkRefs(cb RefCallback)
func (*Type) WalkValues ¶
func (t *Type) WalkValues(cb ValueCallback)
type TypeCache ¶
type TypeCache struct {
// contains filtered or unexported fields
}
func NewTypeCache ¶
func NewTypeCache() *TypeCache
type TypeDesc ¶
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 ValidatingBatchingSink ¶
type ValidatingBatchingSink struct {
// contains filtered or unexported fields
}
func NewValidatingBatchingSink ¶
func NewValidatingBatchingSink(cs chunks.ChunkStore) *ValidatingBatchingSink
func (*ValidatingBatchingSink) DecodeUnqueued ¶
func (vbs *ValidatingBatchingSink) DecodeUnqueued(c *chunks.Chunk) DecodedChunk
DecodeUnqueued 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. However, if c has already been Enqueued, DecodeUnqueued returns an empty DecodedChunk.
func (*ValidatingBatchingSink) Enqueue ¶
func (vbs *ValidatingBatchingSink) Enqueue(c chunks.Chunk, v Value) chunks.BackpressureError
Enequeue adds c to the queue of Chunks waiting to be Put into vbs' backing ChunkStore. It is assumed that v is the Value decoded from c, and so v can be used to validate the ref-completeness of c. The instance keeps an internal buffer of Chunks, spilling to the ChunkStore when the buffer is full. If an attempt to Put Chunks fails, this method returns the BackpressureError from the underlying ChunkStore.
func (*ValidatingBatchingSink) Flush ¶
func (vbs *ValidatingBatchingSink) Flush() (err chunks.BackpressureError)
Flush Puts any Chunks buffered by Enqueue calls into the backing ChunkStore. If the attempt to Put fails, this method returns the BackpressureError returned by the underlying ChunkStore.
func (*ValidatingBatchingSink) Prepare ¶
func (vbs *ValidatingBatchingSink) Prepare(hints Hints)
Prepare primes the type info cache used to validate Enqueued Chunks by reading the Chunks referenced by the provided hints.
type Value ¶
type Value interface { // 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) // Type returns the type of the Noms value. All Noms values carry their runtime Noms type. Type() *Type }
Value is the interface all Noms values implement.
func DecodeFromBytes ¶
func DecodeFromBytes(data []byte, vr ValueReader, tc *TypeCache) Value
func DecodeValue ¶
func DecodeValue(c chunks.Chunk, vr ValueReader) 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 V Value }
type ValueReadWriter ¶
type ValueReadWriter interface { ValueReader ValueWriter // contains filtered or unexported methods }
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 ¶
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) 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 ValueStore ¶
type ValueStore struct {
// contains filtered or unexported fields
}
ValueStore provides methods to read and write Noms Values to a BatchStore. It validates Values as they are written, but does not guarantee that these Values are persisted to the BatchStore until a subsequent Flush. or Close. Currently, WriteValue validates the following properties of a Value v: - v can be correctly serialized and its Ref taken - all Refs in v point to a Value that can be read from this ValueStore - all Refs in v point to a Value of the correct Type
func NewTestValueStore ¶
func NewTestValueStore() *ValueStore
NewTestValueStore creates a simple struct that satisfies ValueReadWriter and is backed by a chunks.TestStore.
func NewValueStore ¶
func NewValueStore(bs BatchStore) *ValueStore
NewValueStore returns a ValueStore instance that owns the provided BatchStore and manages its lifetime. Calling Close on the returned ValueStore will Close bs.
func NewValueStoreWithCache ¶
func NewValueStoreWithCache(bs BatchStore, cacheSize uint64) *ValueStore
func (*ValueStore) BatchStore ¶
func (lvs *ValueStore) BatchStore() BatchStore
func (*ValueStore) Close ¶
func (lvs *ValueStore) Close() error
Close closes the underlying BatchStore
func (*ValueStore) Flush ¶
func (lvs *ValueStore) Flush()
func (*ValueStore) ReadValue ¶
func (lvs *ValueStore) ReadValue(r 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) 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 ¶
- assert_type.go
- batch_store.go
- blob.go
- blob_leaf_sequence.go
- bool.go
- codec.go
- collection.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_iterator.go
- list_leaf_sequence.go
- map.go
- mapMutator.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
- setMutator.go
- set_iterator.go
- set_leaf_sequence.go
- string.go
- struct.go
- type.go
- type_cache.go
- type_desc.go
- validating_batching_sink.go
- value.go
- value_decoder.go
- value_encoder.go
- value_store.go