From dd921d31e36737a65533bdc860846e94fdccfae1 Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Tue, 7 Apr 2015 11:12:28 -0400 Subject: [PATCH] undoing f92ab131e4e40da401faf1523412cbd08af93f4f we now guarantee bytes were copied earlier in the chain the kv store is NOT responsible for making an additional copy closes #181 --- index/store/gtreap/gtreap.go | 4 ++-- index/store/gtreap/gtreap_test.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/index/store/gtreap/gtreap.go b/index/store/gtreap/gtreap.go index 34e1c04e..174f384b 100644 --- a/index/store/gtreap/gtreap.go +++ b/index/store/gtreap/gtreap.go @@ -163,7 +163,7 @@ func (w *Writer) Close() error { func (w *Writer) Set(k, v []byte) (err error) { w.s.m.Lock() - w.s.t = w.s.t.Upsert(&Item{k: k, v: append([]byte(nil), v...)}, rand.Int()) + w.s.t = w.s.t.Upsert(&Item{k: k, v: v}, rand.Int()) w.s.m.Unlock() return nil @@ -283,7 +283,7 @@ func (w *Iterator) Close() error { } func (w *Batch) Set(k, v []byte) { - w.items = append(w.items, &Item{k, append([]byte(nil), v...)}) + w.items = append(w.items, &Item{k, v}) } func (w *Batch) Delete(k []byte) { diff --git a/index/store/gtreap/gtreap_test.go b/index/store/gtreap/gtreap_test.go index 19cbf317..62763530 100644 --- a/index/store/gtreap/gtreap_test.go +++ b/index/store/gtreap/gtreap_test.go @@ -167,7 +167,6 @@ func CommonTestReaderIsolation(t *testing.T, s store.KVStore) { t.Fatal(err) } writer.Close() - valB[0] = 'X' // Modify the bytes so we check that writer got its own copy. // ensure that a newer reader sees it newReader, err := s.Reader() @@ -180,7 +179,7 @@ func CommonTestReaderIsolation(t *testing.T, s store.KVStore) { t.Error(err) } if !reflect.DeepEqual(val, []byte("val-b")) { - t.Errorf("expected val-b, got nil") + t.Errorf("expected val-b, got %s", val) } // ensure that the director iterator sees it