Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalValue ¶
MarshalValue serializes a single value
func MarshalValueKeys ¶ added in v0.2.6
MarshalValues serializes a Value list for storage.
TODO: Switch from JSON to a more efficient serialization format once we figure out the right data structure?
func UnmarshalValueKeys ¶ added in v0.2.6
Unmarshal serialized value keys list
Types ¶
type Interface ¶
type Interface interface {
// Get retrieves a slice of Value for a multihash.
Get(multihash.Multihash) ([]Value, bool, error)
// Put stores a Value and adds a mapping from each of the given multihashs
// to that Value. If the Value has the same ProviderID and ContextID as a
// previously stored Value, then update the metadata in the stored Value
// with the metadata from the provided Value. Call Put without any
// multihashes to only update existing values.
Put(Value, ...multihash.Multihash) error
// Remove removes the mapping of each multihash to the specified value.
Remove(Value, ...multihash.Multihash) error
// RemoveProvider removes all values for specified provider. This is used
// when a provider is no longer indexed by the indexer.
RemoveProvider(peer.ID) error
// RemoveProviderContext removes all values for specified provider that
// have the specified contextID. This is used when a provider no longer
// provides values for a particular context.
RemoveProviderContext(providerID peer.ID, contextID []byte) error
// Size returns the total bytes of storage used to store the indexed
// content in persistent storage. This does not include memory used by any
// in-memory cache that the indexer implementation may have, as that would
// only contain a limited quantity of data and not represent the total
// amount of data stored by the indexer.
Size() (int64, error)
// Flush commits any changes to the value storage,
Flush() error
// Close gracefully closes the store flushing all pending data from memory,
Close() error
// Iter creates a new value store iterator.
Iter() (Iterator, error)
}
type Iterator ¶
type Iterator interface {
// Next returns the next multihash and the value it indexer. Returns
// io.EOF when finished iterating.
Next() (multihash.Multihash, []Value, error)
}
Iterator iterates multihashes and values in the value store.
It should be assumed that any write operation invalidates the iterator,
type Value ¶
type Value struct {
// PrividerID is the peer ID of the provider of the multihash.
ProviderID peer.ID `json:"p"`
// ContextID identifies the metadata that is part of this value.
ContextID []byte `json:"c"`
// MetadataBytes is serialized metadata. The is kept serialized, because
// the indexer only uses the serialized form of this data.
MetadataBytes []byte `json:"m,omitempty"`
}
Value is the value of an index entry that is stored for each multihash in the indexer.
func UnmarshalValue ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
store
|
|
|
memory
Package memory defines an in-memory value store The index data stored by the memory value store is not persisted.
|
Package memory defines an in-memory value store The index data stored by the memory value store is not persisted. |
|
test
Package test provides tests and benchmarks that are usable by any store that implements store.Interface.
|
Package test provides tests and benchmarks that are usable by any store that implements store.Interface. |
Click to show internal directories.
Click to hide internal directories.