1
// Copyright (c) 2016 Couchbase, Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
18
"github.com/couchbase/moss"
20
"github.com/blevesearch/bleve/index/store"
25
merge *store.EmulatedMerge
27
buf []byte // Non-nil when using pre-alloc'ed / NewBatchEx().
31
func (b *Batch) Set(key, val []byte) {
34
b.bufUsed += len(key) + len(val)
35
err = b.batch.AllocSet(key, val)
37
err = b.batch.Set(key, val)
41
b.store.Logf("bleve moss batch.Set err: %v", err)
45
func (b *Batch) Delete(key []byte) {
49
err = b.batch.AllocDel(key)
51
err = b.batch.Del(key)
55
b.store.Logf("bleve moss batch.Delete err: %v", err)
59
func (b *Batch) Merge(key, val []byte) {
61
b.bufUsed += len(key) + len(val)
63
b.merge.Merge(key, val)
66
func (b *Batch) Reset() {
69
b.store.Logf("bleve moss batch.Close err: %v", err)
73
batch, err := b.store.ms.NewBatch(0, 0)
76
b.merge = store.NewEmulatedMerge(b.store.mo)
82
func (b *Batch) Close() error {
84
err := b.batch.Close()