MCPcopy Create free account
hub / github.com/couchbase/moss / TestStorePartialCompactionWithMergeOperator

Function TestStorePartialCompactionWithMergeOperator

store_test.go:2385–2512  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2383}
2384
2385func TestStorePartialCompactionWithMergeOperator(t *testing.T) {
2386 tmpDir, _ := ioutil.TempDir("", "mossStore")
2387 defer os.RemoveAll(tmpDir)
2388
2389 var err error
2390 var store *Store
2391 var coll Collection
2392
2393 spo := StorePersistOptions{CompactionConcern: CompactionDisable}
2394
2395 store, coll, err = OpenStoreCollection(tmpDir,
2396 StoreOptions{
2397 CollectionOptions: CollectionOptions{
2398 MergeOperator: &MergeOperatorStringAppend{Sep: ":"},
2399 },
2400 },
2401 spo)
2402 if err != nil || store == nil {
2403 t.Errorf("OpenStoreCollection failed, err: %v", err)
2404 }
2405 defer coll.Close()
2406 defer store.Close()
2407
2408 var b Batch
2409
2410 // Execute first batch, so "k0" ==> "a".
2411
2412 b, err = coll.NewBatch(0, 0)
2413 if err != nil {
2414 t.Errorf("expected NewBatch() to succeed")
2415 }
2416 b.Set([]byte("k0"), []byte("a"))
2417
2418 err = coll.ExecuteBatch(b, WriteOptions{})
2419 if err != nil {
2420 t.Errorf("expected ExecuteBatch() to work")
2421 }
2422 waitForPersistence(coll)
2423
2424 store.m.Lock()
2425 store.footer.m.Lock()
2426 if len(store.footer.ss.a) != 1 {
2427 t.Errorf("expected ss height of 1")
2428 }
2429 store.footer.m.Unlock()
2430 store.m.Unlock()
2431
2432 // Execute second batch, so "k0" ==> "a:b".
2433
2434 b, err = coll.NewBatch(0, 0)
2435 if err != nil {
2436 t.Errorf("expected NewBatch() to succeed")
2437 }
2438 b.Merge([]byte("k0"), []byte("b"))
2439
2440 err = coll.ExecuteBatch(b, WriteOptions{})
2441 if err != nil {
2442 t.Errorf("expected ExecuteBatch() to work")

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CloseMethod · 0.95
NewBatchMethod · 0.95
SetMethod · 0.95
ExecuteBatchMethod · 0.95
MergeMethod · 0.95
SnapshotMethod · 0.95
GetMethod · 0.95
snapshotMethod · 0.95
compactMethod · 0.95
SnapshotMethod · 0.95
OpenStoreCollectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…