Documentation ¶
Overview ¶
Package chunks provides facilities for representing, storing, and fetching content-addressed chunks of Noms data.
Index ¶
- Variables
- func Deserialize(reader io.Reader, chunkChan chan<- *Chunk) (err error)
- func Serialize(chunk Chunk, writer io.Writer)
- type Chunk
- type ChunkSink
- type ChunkSource
- type ChunkStore
- type ChunkWriter
- type DynamoStore
- func (s *DynamoStore) Close() error
- func (s *DynamoStore) Flush()
- func (s *DynamoStore) Get(h hash.Hash) Chunk
- func (s *DynamoStore) GetMany(hashes hash.HashSet, foundChunks chan *Chunk)
- func (s *DynamoStore) Has(h hash.Hash) bool
- func (s *DynamoStore) Put(c Chunk)
- func (s *DynamoStore) PutMany(chunks []Chunk)
- func (s *DynamoStore) Root() hash.Hash
- func (s *DynamoStore) UpdateRoot(current, last hash.Hash) bool
- func (s *DynamoStore) Version() string
- type DynamoStoreFlags
- type Factory
- type GetManyRequest
- type GetRequest
- type HasRequest
- type MemoryStore
- func (ms *MemoryStore) Close() error
- func (ms *MemoryStore) Flush()
- func (ms *MemoryStore) Get(h hash.Hash) Chunk
- func (ms *MemoryStore) GetMany(hashes hash.HashSet, foundChunks chan *Chunk)
- func (ms *MemoryStore) Has(r hash.Hash) bool
- func (ms *MemoryStore) Len() int
- func (ms *MemoryStore) Put(c Chunk)
- func (ms *MemoryStore) PutMany(chunks []Chunk)
- func (ms *MemoryStore) Root() hash.Hash
- func (ms *MemoryStore) UpdateRoot(current, last hash.Hash) bool
- func (ms *MemoryStore) Version() string
- type MemoryStoreFactory
- type OutstandingGet
- type OutstandingGetMany
- type OutstandingHas
- type OutstandingRequest
- type ReadBatch
- type ReadRequest
- type RootTracker
- type TestStore
- func (s *TestStore) Get(h hash.Hash) Chunk
- func (s *TestStore) GetMany(hashes hash.HashSet, foundChunks chan *Chunk)
- func (s *TestStore) Has(h hash.Hash) bool
- func (s *TestStore) Put(c Chunk)
- func (s *TestStore) PutMany(chunks []Chunk)
- func (ms *TestStore) Root() hash.Hash
- func (ms *TestStore) UpdateRoot(current, last hash.Hash) bool
- type TestStoreFactory
Constants ¶
This section is empty.
Variables ¶
var EmptyChunk = NewChunk([]byte{})
Functions ¶
func Deserialize ¶
Deserialize reads off of |reader| until EOF, sending chunks to chunkChan in the order they are read. Objects sent over chunkChan are *Chunk.
Types ¶
type Chunk ¶
type Chunk struct {
// contains filtered or unexported fields
}
Chunk is a unit of stored data in noms
func NewChunk ¶
NewChunk creates a new Chunk backed by data. This means that the returned Chunk has ownership of this slice of memory.
func NewChunkWithHash ¶
NewChunkWithHash creates a new chunk with a known hash. The hash is not re-calculated or verified. This should obviously only be used in cases where the caller already knows the specified hash is correct.
type ChunkSink ¶
type ChunkSink interface { // Put writes c into the ChunkSink, blocking until the operation is complete. Put(c Chunk) // PutMany writes chunks into the sink, blocking until the operation is complete. PutMany(chunks []Chunk) // On return, any previously Put chunks should be durable Flush() io.Closer }
ChunkSink is a place to put chunks.
type ChunkSource ¶
type ChunkSource interface { // Get the Chunk for the value of the hash in the store. If the hash is // absent from the store nil is returned. Get(h hash.Hash) Chunk // GetMany gets the Chunks with |hashes| from the store. On return, // |foundChunks| will have been fully sent all chunks which have been // found. Any non-present chunks will silently be ignored. GetMany(hashes hash.HashSet, foundChunks chan *Chunk) // Returns true iff the value at the address |h| is contained in the source Has(h hash.Hash) bool // Returns the NomsVersion with which this ChunkSource is compatible. Version() string }
ChunkSource is a place to get chunks from.
type ChunkStore ¶
type ChunkStore interface { ChunkSource ChunkSink RootTracker }
ChunkStore is the core storage abstraction in noms. We can put data anyplace we have a ChunkStore implementation for.
type ChunkWriter ¶
type ChunkWriter struct {
// contains filtered or unexported fields
}
ChunkWriter wraps an io.WriteCloser, additionally providing the ability to grab the resulting Chunk for all data written through the interface. Calling Chunk() or Close() on an instance disallows further writing.
func NewChunkWriter ¶
func NewChunkWriter() *ChunkWriter
func (*ChunkWriter) Chunk ¶
func (w *ChunkWriter) Chunk() Chunk
Chunk() closes the writer and returns the resulting Chunk.
func (*ChunkWriter) Close ¶
func (w *ChunkWriter) Close() error
Close() closes computes the hash and Puts it into the ChunkSink Note: The Write() method never returns an error. Instead, like other noms interfaces, errors are reported via panic.
type DynamoStore ¶
type DynamoStore struct {
// contains filtered or unexported fields
}
DynamoStore implements ChunkStore by storing data to DynamoDB and, if needed, S3. It assumes the existence of a DynamoDB table whose primary partition key is in Binary format and named `ref`.
func NewDynamoStore ¶
func NewDynamoStore(table, namespace string, ddb ddbsvc, showStats bool) *DynamoStore
NewDynamoStore returns a new DynamoStore instance pointed at a DynamoDB table in the given region. All keys used to access items are prefixed with the given namespace. Uses the given ddbsvc object to access DynamoDB.
func (*DynamoStore) Close ¶
func (s *DynamoStore) Close() error
func (*DynamoStore) Flush ¶
func (s *DynamoStore) Flush()
func (*DynamoStore) GetMany ¶
func (s *DynamoStore) GetMany(hashes hash.HashSet, foundChunks chan *Chunk)
func (*DynamoStore) Put ¶
func (s *DynamoStore) Put(c Chunk)
func (*DynamoStore) PutMany ¶
func (s *DynamoStore) PutMany(chunks []Chunk)
func (*DynamoStore) Root ¶
func (s *DynamoStore) Root() hash.Hash
func (*DynamoStore) UpdateRoot ¶
func (s *DynamoStore) UpdateRoot(current, last hash.Hash) bool
func (*DynamoStore) Version ¶
func (s *DynamoStore) Version() string
type DynamoStoreFlags ¶
type DynamoStoreFlags struct {
// contains filtered or unexported fields
}
func DynamoFlags ¶
func DynamoFlags(prefix string) DynamoStoreFlags
func (DynamoStoreFlags) CreateFactory ¶
func (f DynamoStoreFlags) CreateFactory() (factree Factory)
func (DynamoStoreFlags) CreateStore ¶
func (f DynamoStoreFlags) CreateStore(ns string) ChunkStore
func (DynamoStoreFlags) Shutter ¶
func (f DynamoStoreFlags) Shutter()
type Factory ¶
type Factory interface { CreateStore(ns string) ChunkStore // Shutter shuts down the factory. Subsequent calls to CreateStore() will fail. Shutter() }
Factory allows the creation of namespaced ChunkStore instances. The details of how namespaces are separated is left up to the particular implementation of Factory and ChunkStore.
func NewMemoryStoreFactory ¶
func NewMemoryStoreFactory() Factory
type GetManyRequest ¶
type GetManyRequest struct {
// contains filtered or unexported fields
}
func NewGetManyRequest ¶
func (GetManyRequest) Hashes ¶
func (g GetManyRequest) Hashes() hash.HashSet
func (GetManyRequest) Outstanding ¶
func (g GetManyRequest) Outstanding() OutstandingRequest
type GetRequest ¶
type GetRequest struct {
// contains filtered or unexported fields
}
func NewGetRequest ¶
func NewGetRequest(r hash.Hash, ch chan<- *Chunk) GetRequest
func (GetRequest) Hashes ¶
func (g GetRequest) Hashes() hash.HashSet
func (GetRequest) Outstanding ¶
func (g GetRequest) Outstanding() OutstandingRequest
type HasRequest ¶
type HasRequest struct {
// contains filtered or unexported fields
}
func NewHasRequest ¶
func NewHasRequest(r hash.Hash, ch chan<- bool) HasRequest
func (HasRequest) Hashes ¶
func (h HasRequest) Hashes() hash.HashSet
func (HasRequest) Outstanding ¶
func (h HasRequest) Outstanding() OutstandingRequest
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
An in-memory implementation of store.ChunkStore. Useful mainly for tests.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Close ¶
func (ms *MemoryStore) Close() error
func (*MemoryStore) Flush ¶
func (ms *MemoryStore) Flush()
func (*MemoryStore) GetMany ¶
func (ms *MemoryStore) GetMany(hashes hash.HashSet, foundChunks chan *Chunk)
func (*MemoryStore) Len ¶
func (ms *MemoryStore) Len() int
func (*MemoryStore) Put ¶
func (ms *MemoryStore) Put(c Chunk)
func (*MemoryStore) PutMany ¶
func (ms *MemoryStore) PutMany(chunks []Chunk)
func (*MemoryStore) UpdateRoot ¶
func (*MemoryStore) Version ¶
func (ms *MemoryStore) Version() string
type MemoryStoreFactory ¶
type MemoryStoreFactory struct {
// contains filtered or unexported fields
}
func (*MemoryStoreFactory) CreateStore ¶
func (f *MemoryStoreFactory) CreateStore(ns string) ChunkStore
func (*MemoryStoreFactory) Shutter ¶
func (f *MemoryStoreFactory) Shutter()
type OutstandingGet ¶
type OutstandingGet chan<- *Chunk
func (OutstandingGet) Fail ¶
func (r OutstandingGet) Fail()
func (OutstandingGet) Satisfy ¶
func (r OutstandingGet) Satisfy(c *Chunk)
type OutstandingGetMany ¶
type OutstandingGetMany struct {
// contains filtered or unexported fields
}
func (OutstandingGetMany) Fail ¶
func (ogm OutstandingGetMany) Fail()
func (OutstandingGetMany) Satisfy ¶
func (ogm OutstandingGetMany) Satisfy(c *Chunk)
type OutstandingHas ¶
type OutstandingHas chan<- bool
func (OutstandingHas) Fail ¶
func (h OutstandingHas) Fail()
func (OutstandingHas) Satisfy ¶
func (h OutstandingHas) Satisfy(c *Chunk)
type OutstandingRequest ¶
type OutstandingRequest interface { Satisfy(c *Chunk) Fail() }
type ReadBatch ¶
type ReadBatch map[hash.Hash][]OutstandingRequest
ReadBatch represents a set of queued Get/Has requests, each of which are blocking on a receive channel for a response.
type ReadRequest ¶
type ReadRequest interface { Hashes() hash.HashSet Outstanding() OutstandingRequest }
type RootTracker ¶
RootTracker allows querying and management of the root of an entire tree of references. The "root" is the single mutable variable in a ChunkStore. It can store any hash, but it is typically used by higher layers (such as Database) to store a hash to a value that represents the current state and entire history of a database.
type TestStore ¶
type TestStore struct { MemoryStore Reads int Hases int Writes int }
func NewTestStore ¶
func NewTestStore() *TestStore
func (*TestStore) UpdateRoot ¶
type TestStoreFactory ¶
TestStoreFactory is public, and exposes Stores to ensure that test code can directly query instances vended by this factory.
func NewTestStoreFactory ¶
func NewTestStoreFactory() *TestStoreFactory
func (*TestStoreFactory) CreateStore ¶
func (f *TestStoreFactory) CreateStore(ns string) ChunkStore
func (*TestStoreFactory) Shutter ¶
func (f *TestStoreFactory) Shutter()