Skip to content
Snippets Groups Projects
Commit 2bc103dc authored by Ashwin's avatar Ashwin
Browse files

Changes to take into account that values are posting lists

parent d15c1f56
No related branches found
No related tags found
No related merge requests found
...@@ -23,13 +23,15 @@ import ( ...@@ -23,13 +23,15 @@ import (
"flag" "flag"
"io/ioutil" "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/store/rocksdb"
"github.com/dgraph-io/dgraph/x" "github.com/dgraph-io/dgraph/x"
) )
type Item struct { type Item struct {
key, value []byte key, value []byte
storeIdx int storeIdx int // index of the store among the K stores
} }
type PriorityQueue []*Item type PriorityQueue []*Item
...@@ -59,6 +61,20 @@ func (pq *PriorityQueue) Pop() interface{} { ...@@ -59,6 +61,20 @@ func (pq *PriorityQueue) Pop() interface{} {
return item 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() { func main() {
flag.Parse() flag.Parse()
if len(*stores) == 0 { if len(*stores) == 0 {
...@@ -95,6 +111,8 @@ func main() { ...@@ -95,6 +111,8 @@ func main() {
it := curDb.NewIterator(ropt) it := curDb.NewIterator(ropt)
it.SeekToFirst() it.SeekToFirst()
if !it.Valid() { if !it.Valid() {
itVec = append(itVec, it)
glog.Infof("Store empty() %v", *stores+f.Name())
continue continue
} }
pq[i] = &Item{ pq[i] = &Item{
...@@ -119,8 +137,7 @@ func main() { ...@@ -119,8 +137,7 @@ func main() {
top := heap.Pop(&pq).(*Item) top := heap.Pop(&pq).(*Item)
if bytes.Compare(top.key, lastKey) == 0 { if bytes.Compare(top.key, lastKey) == 0 {
if bytes.Compare(top.value, lastValue) != 0 { if compareValue(top.value, lastValue) == false {
// TODO::value comparison considering timestamps
glog.Fatalf("different value for same key %s", lastKey) glog.Fatalf("different value for same key %s", lastKey)
} }
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment