From 2bc103dc3c7de30efc4a035015f4047174d8e033 Mon Sep 17 00:00:00 2001 From: Ashwin <ashwin2007ray@gmail.com> Date: Thu, 3 Mar 2016 19:53:58 +1100 Subject: [PATCH] Changes to take into account that values are posting lists --- tools/merge/rocksmerge.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/merge/rocksmerge.go b/tools/merge/rocksmerge.go index e900cf76..45db281c 100644 --- a/tools/merge/rocksmerge.go +++ b/tools/merge/rocksmerge.go @@ -23,13 +23,15 @@ import ( "flag" "io/ioutil" + "github.com/dgraph-io/dgraph/posting" + "github.com/dgraph-io/dgraph/posting/types" "github.com/dgraph-io/dgraph/store/rocksdb" "github.com/dgraph-io/dgraph/x" ) type Item struct { key, value []byte - storeIdx int + storeIdx int // index of the store among the K stores } type PriorityQueue []*Item @@ -59,6 +61,20 @@ func (pq *PriorityQueue) Pop() interface{} { return item } +func compareValue(a, b interface{}) bool { + var x, y types.Posting + p1 := a.(*posting.List) + if ok := p1.Get(&x, 0); !ok { + glog.Fatal("While retrieving entry from posting list") + } + p2 := b.(*posting.List) + if ok := p2.Get(&y, 0); !ok { + glog.Fatal("While retrieving entry from posting list") + } + + return x.Uid() == y.Uid() +} + func main() { flag.Parse() if len(*stores) == 0 { @@ -95,6 +111,8 @@ func main() { it := curDb.NewIterator(ropt) it.SeekToFirst() if !it.Valid() { + itVec = append(itVec, it) + glog.Infof("Store empty() %v", *stores+f.Name()) continue } pq[i] = &Item{ @@ -119,8 +137,7 @@ func main() { top := heap.Pop(&pq).(*Item) if bytes.Compare(top.key, lastKey) == 0 { - if bytes.Compare(top.value, lastValue) != 0 { - // TODO::value comparison considering timestamps + if compareValue(top.value, lastValue) == false { glog.Fatalf("different value for same key %s", lastKey) } } else { -- GitLab