Files
dolt/chunks/chunk_store.go
2015-09-22 17:30:14 -07:00

36 lines
1.1 KiB
Go

package chunks
import (
"io"
"github.com/attic-labs/noms/ref"
)
// ChunkStore is the core storage abstraction in noms. We can put data anyplace we have a ChunkStore implementation for.
type ChunkStore interface {
ChunkSource
ChunkSink
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 ref, but it is typically used by higher layers (such as DataStore) to store a ref to a value that represents the current state and entire history of a datastore.
type RootTracker interface {
Root() ref.Ref
UpdateRoot(current, last ref.Ref) bool
}
// ChunkSource is a place to get chunks from.
type ChunkSource interface {
// Get gets a reader for the value of the Ref in the store. If the ref is absent from the store nil is returned.
Get(ref ref.Ref) Chunk
// Returns true iff the value at the address |ref| is contained in the source
Has(ref ref.Ref) bool
}
// ChunkSink is a place to put chunks.
type ChunkSink interface {
Put(c Chunk)
io.Closer
}