mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-10 07:01:01 +00:00
Finish Seek() for runs
This commit is contained in:
parent
1ff5aab753
commit
d068f53d93
2 changed files with 15 additions and 7 deletions
|
|
@ -869,12 +869,13 @@ func (itr *Iterator) Seek(seek uint64) {
|
|||
}
|
||||
|
||||
j, contains := binSearchRuns(lb, c.runs)
|
||||
if !contains {
|
||||
itr.j = -1
|
||||
itr.k = -1
|
||||
} else {
|
||||
if contains {
|
||||
itr.j = j
|
||||
itr.k = int(lb) - int(c.runs[j].start) - 1
|
||||
} else {
|
||||
// Set iterator to next value in the Bitmap.
|
||||
itr.j = j
|
||||
itr.k = -1
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1686,21 +1686,22 @@ func TestIteratorRuns(t *testing.T) {
|
|||
t.Fatalf("iterator did not seek correctly: %v\n", itr)
|
||||
}
|
||||
itr.Next()
|
||||
itr.Next()
|
||||
val, eof := itr.Next()
|
||||
if !(val == 1000 && !eof) {
|
||||
t.Fatalf("iterator did not next correctly across runs")
|
||||
t.Fatalf("iterator did not next correctly across runs: %v, %v", val, itr)
|
||||
}
|
||||
itr.Next()
|
||||
val, eof = itr.Next()
|
||||
if !(val == 1002 && !eof) {
|
||||
t.Fatalf("iterator did not next correctly within a run")
|
||||
t.Fatalf("iterator did not next correctly within a run: %v, %v", val, itr)
|
||||
}
|
||||
itr.Next()
|
||||
itr.Next()
|
||||
itr.Next()
|
||||
val, eof = itr.Next()
|
||||
if !(val == 100000 && !eof) {
|
||||
t.Fatalf("iterator did not next correctly across containers")
|
||||
t.Fatalf("iterator did not next correctly across containers: %v, %v", val, itr)
|
||||
}
|
||||
|
||||
itr.Seek(500)
|
||||
|
|
@ -1713,11 +1714,17 @@ func TestIteratorRuns(t *testing.T) {
|
|||
t.Fatalf("iterator did not seek correctly in multiple runs: %v\n", itr)
|
||||
}
|
||||
|
||||
itr.Seek(1005)
|
||||
if !(itr.i == 0 && itr.j == 1 && itr.k == 4) {
|
||||
t.Fatalf("iterator did not seek correctly to end of run: %v\n", itr)
|
||||
}
|
||||
|
||||
itr.Seek(100005)
|
||||
if !(itr.i == 1 && itr.j == 0 && itr.k == 4) {
|
||||
t.Fatalf("iterator did not seek correctly in multiple containers: %v\n", itr)
|
||||
}
|
||||
|
||||
val, eof = itr.Next()
|
||||
val, eof = itr.Next()
|
||||
if !(val == 0 && eof) {
|
||||
t.Fatalf("iterator did not eof correctly: %d, %v\n", val, eof)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue