Skip to content

Commit

Permalink
store/bigtable: fix range limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangui-Bitfly committed Oct 30, 2024
1 parent 34ce72c commit 36500aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db2/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (db RawStore) parseRow(chainID uint64, number int64, data map[string][]byte
}

func (db RawStore) ReadBlocksByNumber(chainID uint64, start, end int64) ([]*FullBlockRawData, error) {
rows, err := db.store.GetRowsRange(blockKey(chainID, start-1), blockKey(chainID, end))
rows, err := db.store.GetRowsRange(blockKey(chainID, start), blockKey(chainID, end))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion db2/store/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (b BigTableStore) GetRowsRange(table, high, low string) (map[string]map[str
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

rowRange := bigtable.NewRange(low, high)
rowRange := bigtable.NewClosedRange(low, high)

Check failure on line 266 in db2/store/bigtable.go

View workflow job for this annotation

GitHub Actions / Build

undefined: bigtable.NewClosedRange

Check failure on line 266 in db2/store/bigtable.go

View workflow job for this annotation

GitHub Actions / Run CI (ubuntu-latest, 1.21.x)

undefined: bigtable.NewClosedRange
data := make(map[string]map[string][]byte)
err := tbl.ReadRows(ctx, rowRange, func(row bigtable.Row) bool {
data[row.Key()] = make(map[string][]byte)
Expand Down
21 changes: 21 additions & 0 deletions db2/store/bigtable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,24 @@ func TestBigTableStore(t *testing.T) {
t.Errorf("cannot close db: %v", err)
}
}

func TestRangeIncludeLimits(t *testing.T) {
tables := map[string][]string{"testTable": {"testFamily"}}
client, admin := storetest.NewBigTable(t)
store, err := NewBigTableWithClient(context.Background(), client, admin, tables)
if err != nil {
t.Fatal(err)
}
db := Wrap(store, "testTable", "testFamily")

db.Add("1:999999999999", "", []byte("0"), false)
db.Add("1:999999999998", "", []byte("1"), false)

rows, err := db.GetRowsRange("1:999999999999", "1:999999999998")
if err != nil {
t.Fatal(err)
}
if got, want := len(rows), 2; got != want {
t.Errorf("got %v want %v", got, want)
}
}

0 comments on commit 36500aa

Please sign in to comment.