Merge pull request #1228 from dolthub/aaron/nbs-noop-conjoiner

go/store/nbs: WithoutConjoiner() to configure NBS to not conjoin.
This commit is contained in:
Aaron Son
2021-01-19 16:53:57 -08:00
committed by GitHub
2 changed files with 30 additions and 0 deletions

View File

@@ -59,6 +59,17 @@ func (c inlineConjoiner) Conjoin(ctx context.Context, upstream manifestContents,
return conjoin(ctx, upstream, mm, p, stats)
}
type noopConjoiner struct {
}
func (c noopConjoiner) ConjoinRequired(ts tableSet) bool {
return false
}
func (c noopConjoiner) Conjoin(ctx context.Context, upstream manifestContents, mm manifestUpdater, p tablePersister, stats *Stats) (manifestContents, error) {
return manifestContents{}, errors.New("unsupported conjoin operation on noopConjoiner")
}
func conjoin(ctx context.Context, upstream manifestContents, mm manifestUpdater, p tablePersister, stats *Stats) (manifestContents, error) {
var conjoined tableSpec
var conjoinees, keepers []tableSpec

View File

@@ -393,6 +393,25 @@ func newNomsBlockStore(ctx context.Context, nbfVerStr string, mm manifestManager
return nbs, nil
}
// WithoutConjoiner returns a new *NomsBlockStore instance that will not
// conjoin table files during manifest updates. Used in some server-side
// contexts when things like table file maintenance is done out-of-process. Not
// safe for use outside of NomsBlockStore construction.
func (nbs *NomsBlockStore) WithoutConjoiner() *NomsBlockStore {
return &NomsBlockStore{
mm: nbs.mm,
p: nbs.p,
c: noopConjoiner{},
mu: sync.RWMutex{},
mt: nbs.mt,
tables: nbs.tables,
upstream: nbs.upstream,
mtSize: nbs.mtSize,
putCount: nbs.putCount,
stats: nbs.stats,
}
}
func (nbs *NomsBlockStore) Put(ctx context.Context, c chunks.Chunk) error {
t1 := time.Now()
a := addr(c.Hash())