Beispiel #1
0
// Builds table from src iterator.
func (t *tOps) createFrom(src iterator.Iterator) (f *tFile, n int, err error) {
	w, err := t.create()
	if err != nil {
		return f, n, err
	}

	defer func() {
		if err != nil {
			w.drop()
		}
	}()

	for src.Next() {
		err = w.append(src.Key(), src.Value())
		if err != nil {
			return
		}
	}
	err = src.Error()
	if err != nil {
		return
	}

	n = w.tw.EntriesLen()
	f, err = w.finish()
	return
}
Beispiel #2
0
func (h *blockHarness) testKV(act string, iter iterator.Iterator, i int) {
	key, value := h.kv[i], h.kv[i+1]
	if !bytes.Equal(iter.Key(), key) {
		h.t.Fatalf("block: %s: key invalid, want=%q got=%q", act, key, iter.Key())
	}
	if !bytes.Equal(iter.Value(), value) {
		h.t.Fatalf("block: %s: value invalid, want=%q got=%q", act, value, iter.Value())
	}
}