types

package
v0.0.0-...-f2d0646 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2016 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

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 EmptyStructType = MakeStructType("", []string{}, []*Type{})
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 EncodeValue

func EncodeValue(v Value, vw ValueWriter) chunks.Chunk

func EncodedIndexValue

func EncodedIndexValue(v Value) string

func EncodedValue

func EncodedValue(v Value) string

func EncodedValueWithTags

func EncodedValueWithTags(v Value) string

func EnsureHash

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

func EscapeStructField

func EscapeStructField(input string) string

Escapes names for use as noms structs. 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

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 is requiredType. For example, `Number` is a subtype of `Number | String`.

func NewStreamingList

func NewStreamingList(vrw ValueReadWriter, values <-chan Value) <-chan List

NewStreamingList creates a new List with type t, 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, she 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 WriteEncodedValue

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

WriteEncodedValue writes the serialization of a value

func WriteEncodedValueWithTags

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

WriteEncodedValueWithTags writes the serialization of a value prefixed by its type.

Types

type BatchStore

type BatchStore interface {
	// IsValidating indicates whether this implementation can internally enforce chunk validity & completeness. If a BatchStore supports this, it must also support "staging" of writes -- that is, allowing chunks to be written which reference chunks which have yet to be written.
	IsValidating() bool

	// 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) Flush

func (bsa *BatchStoreAdaptor) Flush()

Flush is a noop.

func (*BatchStoreAdaptor) Get

func (bsa *BatchStoreAdaptor) Get(h hash.Hash) chunks.Chunk

Get simply proxies to the backing ChunkStore

func (*BatchStoreAdaptor) IsValidating

func (bsa *BatchStoreAdaptor) IsValidating() bool

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

func NewBlob(r io.Reader) Blob

func NewEmptyBlob

func NewEmptyBlob() Blob

func NewStreamingBlob

func NewStreamingBlob(r io.Reader, vrw ValueReadWriter) Blob

func (Blob) ChildValues

func (b Blob) ChildValues() []Value

func (Blob) Chunks

func (b Blob) Chunks() []Ref

func (Blob) Empty

func (b Blob) Empty() bool

func (Blob) Equals

func (b Blob) Equals(other Value) bool

Value interface

func (Blob) Hash

func (b Blob) Hash() hash.Hash

func (Blob) Len

func (b Blob) Len() uint64

Collection interface

func (Blob) Less

func (b Blob) Less(other Value) bool

func (Blob) Reader

func (b Blob) Reader() io.ReadSeeker

BUG 155 - Should provide Write... Maybe even have Blob implement ReadWriteSeeker

func (Blob) Splice

func (b Blob) Splice(idx uint64, deleteCount uint64, data []byte) Blob

func (Blob) Type

func (b Blob) Type() *Type

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

func (Bool) ChildValues

func (v Bool) ChildValues() []Value

func (Bool) Chunks

func (v Bool) Chunks() []Ref

func (Bool) Equals

func (v Bool) Equals(other Value) bool

Value interface

func (Bool) Hash

func (v Bool) Hash() hash.Hash

func (Bool) Less

func (v Bool) Less(other Value) bool

func (Bool) Type

func (v Bool) Type() *Type

type Collection

type Collection interface {
	Value
	Len() uint64
	Empty() bool
	// contains filtered or unexported methods
}

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 CycleDesc

type CycleDesc uint32

func (CycleDesc) HasUnresolvedCycle

func (c CycleDesc) HasUnresolvedCycle(visited []*Type) bool

func (CycleDesc) Kind

func (c CycleDesc) Kind() NomsKind

type DiffChangeType

type DiffChangeType uint8
const (
	DiffChangeAdded DiffChangeType = iota
	DiffChangeRemoved
	DiffChangeModified
)

type EditDistanceEqualsFn

type EditDistanceEqualsFn func(prevIndex uint64, currentIndex uint64) bool

type FieldPath

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

Gets Struct field values by name.

func NewFieldPath

func NewFieldPath(name string) FieldPath

func (FieldPath) Resolve

func (fp FieldPath) Resolve(v Value) Value

func (FieldPath) String

func (fp FieldPath) String() string

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

type Hints map[hash.Hash]struct{}

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

func NewIndexPath

func NewIndexPath(idx Value) IndexPath

func (IndexPath) Resolve

func (ip IndexPath) Resolve(v Value) Value

func (IndexPath) String

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

type List

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

func NewList

func NewList(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) Append

func (l List) Append(vs ...Value) List

func (List) ChildValues

func (l List) ChildValues() (values []Value)

func (List) Chunks

func (l List) Chunks() []Ref

func (List) Diff

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

func (List) DiffWithLimit

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

func (List) Empty

func (l List) Empty() bool

func (List) Equals

func (l List) Equals(other Value) bool

Value interface

func (List) Get

func (l List) Get(idx uint64) Value

func (List) Hash

func (l List) Hash() hash.Hash

func (List) Insert

func (l List) Insert(idx uint64, vs ...Value) List

func (List) Iter

func (l List) Iter(f listIterFunc)

func (List) IterAll

func (l List) IterAll(f listIterAllFunc)

func (List) Len

func (l List) Len() uint64

Collection interface

func (List) Less

func (l List) Less(other Value) bool

func (List) Map

func (l List) Map(mf MapFunc) []interface{}

func (List) Remove

func (l List) Remove(start uint64, end uint64) List

func (List) RemoveAt

func (l List) RemoveAt(idx uint64) List

func (List) Set

func (l List) Set(idx uint64, v Value) List

func (List) Splice

func (l List) Splice(idx uint64, deleteCount uint64, vs ...Value) List

func (List) Type

func (l List) Type() *Type

type Map

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

func NewMap

func NewMap(kv ...Value) Map

func (Map) ChildValues

func (m Map) ChildValues() (values []Value)

func (Map) Chunks

func (m Map) Chunks() []Ref

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

func (m Map) Empty() bool

func (Map) Equals

func (m Map) Equals(other Value) bool

Value interface

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

func (m Map) Hash() hash.Hash

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

func (m Map) Len() uint64

Collection interface

func (Map) Less

func (m Map) Less(other Value) bool

func (Map) MaybeGet

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

func (Map) Remove

func (m Map) Remove(k Value) Map

func (Map) Set

func (m Map) Set(key Value, val Value) Map

func (Map) SetM

func (m Map) SetM(kv ...Value) Map

func (Map) Type

func (m Map) Type() *Type

type MapFunc

type MapFunc func(v Value, index uint64) interface{}

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

func (Number) ChildValues

func (v Number) ChildValues() []Value

func (Number) Chunks

func (v Number) Chunks() []Ref

func (Number) Equals

func (v Number) Equals(other Value) bool

Value interface

func (Number) Hash

func (v Number) Hash() hash.Hash

func (Number) Less

func (v Number) Less(other Value) bool

func (Number) Type

func (v Number) Type() *Type

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.

func ParsePath

func ParsePath(str string) (Path, error)

func (Path) Resolve

func (p Path) Resolve(v Value) (resolved Value)

func (Path) String

func (p Path) String() string

type PathPart

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

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 NewRef

func NewRef(v Value) Ref

func (Ref) ChildValues

func (r Ref) ChildValues() []Value

func (Ref) Chunks

func (r Ref) Chunks() (chunks []Ref)

func (Ref) Equals

func (r Ref) Equals(other Value) bool

Value interface

func (Ref) Hash

func (r Ref) Hash() hash.Hash

func (Ref) Height

func (r Ref) Height() uint64

func (Ref) Less

func (r Ref) Less(other Value) bool

func (Ref) TargetHash

func (r Ref) TargetHash() hash.Hash

func (Ref) TargetValue

func (r Ref) TargetValue(vr ValueReader) Value

func (Ref) Type

func (r Ref) Type() *Type

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) 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) 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 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(v ...Value) Set

func (Set) ChildValues

func (s Set) ChildValues() (values []Value)

func (Set) Chunks

func (s Set) Chunks() []Ref

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

func (s Set) Empty() bool

func (Set) Equals

func (s Set) Equals(other Value) bool

Value interface

func (Set) First

func (s Set) First() Value

func (Set) Has

func (s Set) Has(v Value) bool

func (Set) Hash

func (s Set) Hash() hash.Hash

func (Set) Insert

func (s Set) Insert(values ...Value) Set

func (Set) Iter

func (s Set) Iter(cb setIterCallback)

func (Set) IterAll

func (s Set) IterAll(cb setIterAllCallback)

func (Set) Len

func (s Set) Len() uint64

Collection interface

func (Set) Less

func (s Set) Less(other Value) bool

func (Set) Remove

func (s Set) Remove(values ...Value) Set

func (Set) Type

func (s Set) Type() *Type

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

func (String) ChildValues

func (fs String) ChildValues() []Value

func (String) Chunks

func (fs String) Chunks() []Ref

func (String) Equals

func (s String) Equals(other Value) bool

Value interface

func (String) Hash

func (s String) Hash() hash.Hash

func (String) Less

func (s String) Less(other Value) bool

func (String) Type

func (fs String) Type() *Type

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

func (s Struct) ChildValues() []Value

func (Struct) Chunks

func (s Struct) Chunks() (chunks []Ref)

func (Struct) Diff

func (s1 Struct) Diff(s2 Struct, changes chan<- ValueChanged, closeChan <-chan struct{})

func (Struct) Equals

func (s Struct) Equals(other Value) bool

Value interface

func (Struct) Get

func (s Struct) Get(n string) Value

func (Struct) Hash

func (s Struct) Hash() hash.Hash

func (Struct) Less

func (s Struct) Less(other Value) bool

func (Struct) MaybeGet

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

func (Struct) Set

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

func (Struct) Type

func (s Struct) Type() *Type

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) *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 MakeCycleType(level uint32) *Type

func MakeListType

func MakeListType(elemType *Type) *Type

func MakeMapType

func MakeMapType(keyType, valType *Type) *Type

func MakePrimitiveType

func MakePrimitiveType(k NomsKind) *Type

func MakePrimitiveTypeByString

func MakePrimitiveTypeByString(p string) *Type

func MakeRefType

func MakeRefType(elemType *Type) *Type

func MakeSetType

func MakeSetType(elemType *Type) *Type

func MakeStructType

func MakeStructType(name string, fieldNames []string, fieldTypes []*Type) *Type

func MakeUnionType

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

func (*Type) ChildValues

func (t *Type) ChildValues() (res []Value)

func (*Type) Chunks

func (t *Type) Chunks() (chunks []Ref)

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)

Value interface

func (*Type) HasUnresolvedCycle

func (t *Type) HasUnresolvedCycle() 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) Type

func (t *Type) Type() *Type

type TypeCache

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

func NewTypeCache

func NewTypeCache() *TypeCache

func (*TypeCache) Lock

func (tc *TypeCache) Lock()

func (*TypeCache) Unlock

func (tc *TypeCache) Unlock()

type TypeDesc

type TypeDesc interface {
	Kind() NomsKind
	HasUnresolvedCycle(visited []*Type) bool
}

TypeDesc describes a type of the kind returned by Kind(), e.g. Map, Number, or a custom type.

type TypeMap

type TypeMap map[string]*Type

type ValidatingBatchingSink

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

func NewValidatingBatchingSink

func NewValidatingBatchingSink(cs chunks.ChunkStore, tc *TypeCache) *ValidatingBatchingSink

func (*ValidatingBatchingSink) Enqueue

Enequeue adds a Chunk to the queue of Chunks waiting to be Put into vbs' backing ChunkStore. 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(other Value) bool
	Less(other Value) bool

	Hash() hash.Hash
	// Returns the immediate children of this value in the DAG, if any, not including Type().
	ChildValues() []Value
	Chunks() []Ref
	Type() *Type
}

Value is implemented by every noms value

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

type ValueReader interface {
	ReadValue(h hash.Hash) Value
}

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

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.

Jump to

Keyboard shortcuts

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