示例#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],
	}
}
示例#2
0
文件: writer.go 项目: drewwells/bleve
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: levigo.NewWriteBatch(),
	}
	return &rv
}
示例#3
0
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: new(leveldb.Batch),
	}
	return &rv
}
示例#4
0
func (w *Writer) NewBatch() store.KVBatch {
	rv := Batch{
		w:     w,
		merge: store.NewEmulatedMerge(w.store.mo),
		batch: forestdb.NewKVBatch(),
	}
	return &rv
}
示例#5
0
文件: writer.go 项目: ekanite/bleve
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,
	}
}
示例#6
0
文件: batch.go 项目: bcampbell/bleve
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
	}
}
示例#7
0
文件: writer.go 项目: ekanite/bleve
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
}
示例#8
0
func (b *Batch) Reset() {
	b.batch.Reset()
	b.merge = store.NewEmulatedMerge(b.store.mo)
}
示例#9
0
func (b *Batch) Reset() {
	b.batch.Reset()
	b.merge = store.NewEmulatedMerge(b.w.store.mo)
	b.skipBatchErr = nil
}
示例#10
0
func (b *BatchEx) Reset() {
	b.num_sets = 0
	b.num_deletes = 0

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