mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-25 18:49:36 -06:00
Previously we had flatSet vs chunkedSet, each implementing the Set interface, and SetBuilder dealing with this Set interface. Now we have a chunkedSet interface with setValueChunk and setIndexChunk implementations, SetBuilder dealing with the chunkedSet interface, and a Set class which implements Set primitives on top of a chunkedSet. Of particular note is the introduction of the setChunkStore, an in-memory cache of setChunks keyed by their refs. This is needed right now so that we only have a single SetBuilder implementation which chunks refs, as opposed to 2 SetBuilder implementations, one which chunks refs and the other chunkedSet instances. Something like it will be needed in the longer term to implement lazily loading set chunks, however there will be issues like memory pressure to deal with as well. Follow-ups to this patch include renaming files to reflect their class names better, and doing a bit of function/member renaming to better reflect semantics. I've tried to keep the diff as small as possible.
15 lines
503 B
Go
15 lines
503 B
Go
package newset
|
|
|
|
import "github.com/attic-labs/noms/ref"
|
|
|
|
// A node is intended to map onto a single chunk, which compose together to form a Set. It defines primitive operations which Set can use to implement the set interface.
|
|
type node interface {
|
|
length() uint64 // expensive, but should we cache it for the public API?
|
|
start() ref.Ref
|
|
has(r ref.Ref) bool // expensive
|
|
appendRef(first, r ref.Ref) node
|
|
ref() ref.Ref
|
|
iter(func(int, ref.Ref)) // expensive
|
|
fmt(indent int) string // expensive
|
|
}
|