Example #1
0
func newBatchEx(w *Writer, o store.KVBatchOptions) *BatchEx {
	s := o.NumSets + o.NumMerges
	ss := s + o.NumSets + o.NumMerges
	ssd := ss + o.NumDeletes

	cbufs := make([]unsafe.Pointer, 3)

	C.blevex_forestdb_alloc_direct_batch(C.size_t(o.TotalBytes),
		C.size_t(ssd), (*unsafe.Pointer)(&cbufs[0]))

	buf := unsafeToByteSlice(cbufs[0], o.TotalBytes)
	arr_ptr_char := unsafeToCPtrCharSlice(cbufs[1], ssd)
	arr_size_t := unsafeToCSizeTSlice(cbufs[2], ssd)

	return &BatchEx{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),

		cbufs:             cbufs,
		buf:               buf,
		set_keys:          arr_ptr_char[0:s],
		set_keys_sizes:    arr_size_t[0:s],
		set_vals:          arr_ptr_char[s:ss],
		set_vals_sizes:    arr_size_t[s:ss],
		delete_keys:       arr_ptr_char[ss:ssd],
		delete_keys_sizes: arr_size_t[ss:ssd],
	}
}
Example #2
0
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: levigo.NewWriteBatch(),
	}
	return &rv
}
Example #3
0
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: new(leveldb.Batch),
	}
	return &rv
}
Example #4
0
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: forestdb.NewKVBatch(),
	}
	return &rv
}
Example #5
0
func (w *Writer) NewBatch() store.KVBatch {
	b, err := w.s.ms.NewBatch(0, 0)
	if err != nil {
		return nil
	}

	return &Batch{
		store: w.s,
		merge: store.NewEmulatedMerge(w.s.mo),
		batch: b,
	}
}
Example #6
0
func (b *Batch) Reset() {
	err := b.Close()
	if err != nil {
		b.store.Logf("bleve moss batch.Close err: %v", err)
		return
	}

	batch, err := b.store.ms.NewBatch(0, 0)
	if err == nil {
		b.batch = batch
		b.merge = store.NewEmulatedMerge(b.store.mo)
		b.buf = nil
		b.bufUsed = 0
	}
}
Example #7
0
func (w *Writer) NewBatchEx(options store.KVBatchOptions) (
	[]byte, store.KVBatch, error) {
	numOps := options.NumSets + options.NumDeletes + options.NumMerges

	b, err := w.s.ms.NewBatch(numOps, options.TotalBytes)
	if err != nil {
		return nil, nil, err
	}

	buf, err := b.Alloc(options.TotalBytes)
	if err != nil {
		return nil, nil, err
	}

	return buf, &Batch{
		store:   w.s,
		merge:   store.NewEmulatedMerge(w.s.mo),
		batch:   b,
		buf:     buf,
		bufUsed: 0,
	}, nil
}
Example #8
0
func (b *Batch) Reset() {
	b.batch.Reset()
	b.merge = store.NewEmulatedMerge(b.store.mo)
}
Example #9
0
func (b *Batch) Reset() {
	b.batch.Reset()
	b.merge = store.NewEmulatedMerge(b.w.store.mo)
	b.skipBatchErr = nil
}
Example #10
0
func (b *BatchEx) Reset() {
	b.num_sets = 0
	b.num_deletes = 0

	b.merge = store.NewEmulatedMerge(b.w.store.mo)
}