types

package
v0.0.0-...-e5fa29d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 30 Imported by: 196

Documentation

Overview

Package types contains most of the data structures available to/from Noms.

Index

Examples

Constants

View Source
const (
	DEFAULT_MAX_SPLICE_MATRIX_SIZE = 2e7
	SPLICE_UNASSIGNED              = math.MaxUint64

	UNCHANGED = 0
	UPDATED   = 1
	INSERTED  = 2
	REMOVED   = 3
)

Variables

View Source
var BlobType = makePrimitiveType(BlobKind)
View Source
var BoolType = makePrimitiveType(BoolKind)
View Source
var EmptyStruct = newStruct("", nil, nil)
View Source
var EmptyStructType = MakeStructType("")
View Source
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",
}
View Source
var NumberType = makePrimitiveType(NumberKind)
View Source
var StringType = makePrimitiveType(StringKind)
View Source
var TypeType = makePrimitiveType(TypeKind)
View Source
var ValueType = makePrimitiveType(ValueKind)

Functions

func CamelCaseFieldName

func CamelCaseFieldName(input string) string

func ContainCommonSupertype

func ContainCommonSupertype(a, b *Type) bool

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 EncodeValue(v Value) chunks.Chunk

func EncodedIndexValue

func EncodedIndexValue(v Value) string

func EncodedValue

func EncodedValue(v Value) string

EncodedValue returns a string containing the serialization of a value.

func EncodedValueMaxLines

func EncodedValueMaxLines(v Value, maxLines uint32) string

EncodedValueMaxLines returns a string containing the serialization of a value. The string is truncated at |maxLines|.

func EnsureHash

func EnsureHash(h *hash.Hash, v Value) hash.Hash

func EscapeStructField

func EscapeStructField(input string) string

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

func HasStructCycles(t *Type) bool

HasStructCycles determines if the type contains any struct cycles.

func HeightOrder

func HeightOrder(a, b Ref) bool

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

func IsPrimitiveKind(k NomsKind) bool

IsPrimitiveKind returns true if k represents a Noms primitive type, which excludes collections (List, Map, Set), Refs, Structs, Symbolic and Unresolved types.

func IsSubtype

func IsSubtype(requiredType, concreteType *Type) bool

IsSubtype determines whether concreteType is a subtype of requiredType. For example, `Number` is a subtype of `Number | String`.

func IsSubtypeDisallowExtraStructFields

func IsSubtypeDisallowExtraStructFields(requiredType, concreteType *Type) bool

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/attic-labs/noms/issues/3446

func IsValidStructFieldName

func IsValidStructFieldName(name string) bool

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 IsValueSubtypeOf(v Value, t *Type) bool

func IsValueSubtypeOfDetails

func IsValueSubtypeOfDetails(v Value, t *Type) (bool, bool)

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 ValueCanBePathIndex(v Value) bool

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

func WriteEncodedValue(w io.Writer, v Value) error

WriteEncodedValue writes the serialization of a value

func WriteEncodedValueMaxLines

func WriteEncodedValueMaxLines(w io.Writer, v Value, maxLines uint32) error

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

func (b Blob) Concat(other Blob) Blob

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) Copy

func (b Blob) Copy(w io.Writer) (n int64)

func (Blob) CopyReadAhead

func (b Blob) CopyReadAhead(w io.Writer, chunkSize uint64, concurrency int) (n int64)

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

func (b Blob) ReadAt(p []byte, off int64) (n int, err error)

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) Value

func (b Blob) Value() Value

Value interface

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) Read

func (be *BlobEditor) Read(p []byte) (n int, err error)

func (*BlobEditor) Seek

func (be *BlobEditor) Seek(offset int64, whence int) (int64, error)

func (*BlobEditor) Splice

func (be *BlobEditor) Splice(idx uint64, deleteCount uint64, insert []byte) *BlobEditor

func (*BlobEditor) Value

func (be *BlobEditor) Value() Value

func (*BlobEditor) Write

func (be *BlobEditor) Write(p []byte) (n int, err error)

type BlobReader

type BlobReader struct {
	// contains filtered or unexported fields
}

func (*BlobReader) Read

func (cbr *BlobReader) Read(p []byte) (n int, err error)

func (*BlobReader) Seek

func (cbr *BlobReader) Seek(offset int64, whence int) (int64, error)

type Bool

type Bool bool

Bool is a Noms Value wrapper around the primitive bool type.

func (Bool) Equals

func (b Bool) Equals(other Value) bool

func (Bool) Hash

func (b Bool) Hash() hash.Hash

func (Bool) Kind

func (b Bool) Kind() NomsKind

func (Bool) Less

func (b Bool) Less(other Value) bool

func (Bool) Value

func (b Bool) Value() Value

Value interface

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 CycleDesc

type CycleDesc string

func (CycleDesc) Kind

func (c CycleDesc) Kind() NomsKind

type DecodedChunk

type DecodedChunk struct {
	Chunk *chunks.Chunk
	Value *Value
}

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 EditDistanceEqualsFn func(prevIndex uint64, currentIndex uint64) bool

type FieldMap

type FieldMap map[string]*Type

type FieldPath

type FieldPath struct {
	// The name of the field, e.g. `.Name`.
	Name string
}

FieldPath references Struct field values by name.

func NewFieldPath

func NewFieldPath(name string) FieldPath

func (FieldPath) Resolve

func (fp FieldPath) Resolve(v Value, vr ValueReader) Value

func (FieldPath) String

func (fp FieldPath) String() string

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

type HRSCommenter interface {
	Comment(Value) string
}

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 NewIndexIntoKeyPath(idx Value) IndexPath

func NewIndexPath

func NewIndexPath(idx Value) IndexPath

func (IndexPath) Resolve

func (ip IndexPath) Resolve(v Value, vr ValueReader) Value

func (IndexPath) String

func (ip IndexPath) String() (str string)

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

func (l List) Concat(other List) List

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

func (l List) Diff(last List, changes chan<- Splice, closeChan <-chan struct{})

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

func (l List) Get(idx uint64) Value

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 func(v Value, index uint64) (stop bool))

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 func(v Value, index uint64))

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) IterRange

func (l List) IterRange(startIdx, endIdx uint64, f func(v Value, idx uint64))

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) Value

func (l List) Value() Value

Value interface

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) Any

func (m Map) Any(cb func(k, v Value) bool) (yep bool)

Any returns true if cb() return true for any of the items in the map.

func (Map) At

func (m Map) At(idx uint64) (key, value Value)

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) Edit

func (m Map) Edit() *MapEditor

func (Map) First

func (m Map) First() (Value, Value)

func (Map) Get

func (m Map) Get(key Value) Value

func (Map) Has

func (m Map) Has(key Value) bool

func (Map) Iter

func (m Map) Iter(cb mapIterCallback)

func (Map) IterAll

func (m Map) IterAll(cb mapIterAllCallback)

func (Map) IterFrom

func (m Map) IterFrom(start Value, cb mapIterCallback)

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) Last

func (m Map) Last() (Value, Value)

func (Map) MaybeGet

func (m Map) MaybeGet(key Value) (v Value, ok bool)

func (Map) Value

func (m Map) Value() Value

Value interface

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

func NewMapEditor(m Map) *MapEditor

func (*MapEditor) Get

func (me *MapEditor) Get(k Value) Valuable

func (*MapEditor) Has

func (me *MapEditor) Has(k Value) bool

func (*MapEditor) Kind

func (me *MapEditor) Kind() NomsKind

func (*MapEditor) Map

func (me *MapEditor) Map() Map

func (*MapEditor) Remove

func (me *MapEditor) Remove(k Value) *MapEditor

func (*MapEditor) Set

func (me *MapEditor) Set(k Value, v Valuable) *MapEditor

func (*MapEditor) SetM

func (me *MapEditor) SetM(kv ...Valuable) *MapEditor

func (*MapEditor) Value

func (me *MapEditor) Value() Value

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.

func (NomsKind) String

func (k NomsKind) String() string

String returns the name of the kind.

type Number

type Number float64

Number is a Noms Value wrapper around the primitive float64 type.

func (Number) Equals

func (v Number) Equals(other Value) bool

func (Number) Hash

func (v Number) Hash() hash.Hash

func (Number) Kind

func (v Number) Kind() NomsKind

func (Number) Less

func (v Number) Less(other Value) bool

func (Number) Value

func (v Number) Value() Value

Value interface

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/attic-labs/noms/blob/master/doc/spelling.md.

func MustParsePath

func MustParsePath(str string) Path

MustParsePath parses str into a Path, or panics if parsing failed.

func ParsePath

func ParsePath(str string) (Path, error)

ParsePath parses str into a Path, or returns an error if parsing failed.

func (Path) Append

func (p Path) Append(pp PathPart) Path

Append makes a copy of a p and appends the PathPart 'pp' to it.

func (Path) Equals

func (p Path) Equals(o Path) bool

func (Path) IsEmpty

func (p Path) IsEmpty() bool

func (Path) Resolve

func (p Path) Resolve(v Value, vr ValueReader) (resolved Value)

Resolve resolves a path relative to some value. A ValueReader is required to resolve paths that contain the @target annotation.

func (Path) String

func (p Path) String() string

type PathPart

type PathPart interface {
	Resolve(v Value, vr ValueReader) Value
	String() string
}

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 NewRef

func NewRef(v Value) Ref

func ToRefOfValue

func ToRefOfValue(r Ref) Ref

ToRefOfValue returns a new Ref that points to the same target as |r|, but with the type 'Ref<Value>'.

func (Ref) Equals

func (v Ref) Equals(other Value) bool

func (Ref) Hash

func (v Ref) Hash() hash.Hash

func (Ref) Height

func (r Ref) Height() uint64

func (Ref) IsZeroValue

func (v Ref) IsZeroValue() bool

IsZeroValue can be used to test if a Value is the same as T{}.

func (Ref) Kind

func (v Ref) Kind() NomsKind

func (Ref) Less

func (v Ref) Less(other Value) bool

func (Ref) TargetHash

func (r Ref) TargetHash() hash.Hash

func (Ref) TargetType

func (r Ref) TargetType() *Type

func (Ref) TargetValue

func (r Ref) TargetValue(vr ValueReader) Value

func (Ref) Value

func (r Ref) Value() Value

Value interface

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 RefSlice

type RefSlice []Ref

RefSlice implements sort.Interface to order by target ref.

func (RefSlice) Len

func (s RefSlice) Len() int

func (RefSlice) Less

func (s RefSlice) Less(i, j int) bool

func (RefSlice) Swap

func (s RefSlice) Swap(i, j int)

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet(vrw ValueReadWriter, v ...Value) Set

func (Set) At

func (s Set) At(idx uint64) Value

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) Edit

func (s Set) Edit() *SetEditor

func (Set) First

func (s Set) First() Value

func (Set) Has

func (s Set) Has(v Value) bool

func (Set) Iter

func (s Set) Iter(cb setIterCallback)

func (Set) IterAll

func (s Set) IterAll(cb setIterAllCallback)

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) Value

func (s Set) Value() Value

Value interface

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

func NewSetEditor(s Set) *SetEditor

func (*SetEditor) Has

func (se *SetEditor) Has(v Value) bool

func (*SetEditor) Insert

func (se *SetEditor) Insert(vs ...Value) *SetEditor

func (*SetEditor) Kind

func (se *SetEditor) Kind() NomsKind

func (*SetEditor) Remove

func (se *SetEditor) Remove(vs ...Value) *SetEditor

func (*SetEditor) Set

func (se *SetEditor) Set() Set

func (*SetEditor) Value

func (se *SetEditor) Value() Value

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 SkipValueCallback func(v Value) bool

type Splice

type Splice struct {
	SpAt      uint64
	SpRemoved uint64
	SpAdded   uint64
	SpFrom    uint64
}

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"

func (Splice) String

func (s Splice) String() string

type String

type String string

String is a Noms Value wrapper around the primitive string type.

func (String) Equals

func (s String) Equals(other Value) bool

func (String) Hash

func (s String) Hash() hash.Hash

func (String) Kind

func (s String) Kind() NomsKind

func (String) Less

func (s String) Less(other Value) bool

func (String) Value

func (s String) Value() Value

Value interface

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

func (s Struct) Delete(n string) Struct

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) Empty

func (s Struct) Empty() bool

func (Struct) Equals

func (v Struct) Equals(other Value) bool

func (Struct) Get

func (s Struct) Get(n string) Value

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) Hash

func (v Struct) Hash() hash.Hash

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

func (s Struct) IterFields(cb func(name string, value Value) (stop bool))

IterFields iterates over the fields, calling cb for every field in the struct.

func (Struct) Kind

func (v Struct) Kind() NomsKind

func (Struct) Len

func (s Struct) Len() int

Len is the number of fields in the struct.

func (Struct) Less

func (v Struct) Less(other Value) bool

func (Struct) MaybeGet

func (s Struct) MaybeGet(n string) (v Value, found bool)

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) Name

func (s Struct) Name() string

Name is the name of the struct.

func (Struct) Set

func (s Struct) Set(n string, v Value) Struct

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) SetName

func (s Struct) SetName(name string) Struct

func (Struct) Value

func (s Struct) Value() Value

Value interface

func (Struct) WalkRefs

func (v Struct) WalkRefs(cb RefCallback)

func (Struct) WalkValues

func (s Struct) WalkValues(cb ValueCallback)

type StructData

type StructData map[string]Value

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) (typ *Type, optional bool)

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

type StructField struct {
	Name     string
	Type     *Type
	Optional bool
}

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 MakeCycleType(name string) *Type

func MakeListType

func MakeListType(elemType *Type) *Type

func MakeMapType

func MakeMapType(keyType, valType *Type) *Type

func MakePrimitiveType

func MakePrimitiveType(k NomsKind) *Type

func MakeRefType

func MakeRefType(elemType *Type) *Type

func MakeSetType

func MakeSetType(elemType *Type) *Type

func MakeStructType

func MakeStructType(name string, fields ...StructField) *Type

func MakeStructTypeFromFields

func MakeStructTypeFromFields(name string, fields FieldMap) *Type

func MakeUnionType

func MakeUnionType(elemTypes ...*Type) *Type

MakeUnionType creates a new union type unless the elemTypes can be folded into a single non union type.

func MakeUnionTypeIntersectStructs

func MakeUnionTypeIntersectStructs(elemTypes ...*Type) *Type

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

func TypeOf(v Value) *Type

TypeOf returns the type describing the value. This is not an exact type but often a simplification of the concrete type.

func (*Type) Describe

func (t *Type) Describe() (out string)

Describe generate text that should parse into the struct being described.

func (*Type) Equals

func (t *Type) Equals(other Value) (res bool)

func (*Type) Hash

func (t *Type) Hash() hash.Hash

func (*Type) Kind

func (t *Type) Kind() NomsKind

func (*Type) Less

func (t *Type) Less(other Value) (res bool)

func (*Type) TargetKind

func (t *Type) TargetKind() NomsKind

func (*Type) Value

func (t *Type) Value() Value

Value interface

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.

func ParsePathIndex

func ParsePathIndex(str string) (idx Value, h hash.Hash, rem string, err error)

Parse a Noms value from the path index syntax. 4 -> types.Number "4" -> types.String true|false -> types.Boolean #<chars> -> hash.Hash

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

type ValueWriter interface {
	WriteValue(v Value) Ref
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL