mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
remove extraneous fragment.rows* methods
variadic filters makes separate methods unnecessary
This commit is contained in:
parent
4f3f2e1a49
commit
8cd82af2e7
3 changed files with 6 additions and 15 deletions
|
|
@ -1022,7 +1022,7 @@ func (e *executor) executeRowsShard(ctx context.Context, index string, c *pql.Ca
|
|||
if columnID, ok, err := c.UintArg("column"); err != nil {
|
||||
return nil, err
|
||||
} else if ok {
|
||||
return frag.rowsForColumnWithFilter(start, columnID, filters...), nil
|
||||
return frag.rowsForColumn(start, columnID, filters...), nil
|
||||
} else {
|
||||
return frag.rows(start, filters...), nil
|
||||
}
|
||||
|
|
|
|||
13
fragment.go
13
fragment.go
|
|
@ -1771,12 +1771,7 @@ type rowFilter func(rowID uint64) (bool, bool)
|
|||
|
||||
// rows returns all rows by calling rowsWithFilter()
|
||||
// with a completely unrestrictive filter.
|
||||
|
||||
func (f *fragment) rows(start uint64, filters ...rowFilter) []uint64 {
|
||||
return f.rowsWithFilter(start, filters...)
|
||||
}
|
||||
|
||||
func (f *fragment) rowsWithFilter(start uint64, filters ...rowFilter) []uint64 {
|
||||
startKey := rowToKey(start)
|
||||
i, _ := f.storage.Containers.Iterator(startKey)
|
||||
rows := make([]uint64, 0)
|
||||
|
|
@ -1815,11 +1810,7 @@ func (f *fragment) rowsWithFilter(start uint64, filters ...rowFilter) []uint64 {
|
|||
return rows
|
||||
}
|
||||
|
||||
func (f *fragment) rowsForColumn(columnID uint64) []uint64 {
|
||||
return f.rowsForColumnWithFilter(0, columnID)
|
||||
}
|
||||
|
||||
func (f *fragment) rowsForColumnWithFilter(start, columnID uint64, filters ...rowFilter) []uint64 {
|
||||
func (f *fragment) rowsForColumn(start, columnID uint64, filters ...rowFilter) []uint64 {
|
||||
if columnID/ShardWidth != f.shard {
|
||||
panic(fmt.Sprintln("fragment.rowsForColumn should never be called with a columnID which is not in the fragment's shard",
|
||||
columnID, columnID/ShardWidth, f.shard))
|
||||
|
|
@ -2149,7 +2140,7 @@ func newRowsVector(f *fragment) *rowsVector {
|
|||
// Additionally, it returns true if a value was found,
|
||||
// otherwise it returns false.
|
||||
func (v *rowsVector) Get(colID uint64) (uint64, bool) {
|
||||
rows := v.f.rowsForColumn(colID)
|
||||
rows := v.f.rowsForColumn(0, colID)
|
||||
if len(rows) == 1 {
|
||||
return rows[0], true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1346,7 +1346,7 @@ func TestFragment_RowsIteration(t *testing.T) {
|
|||
t.Fatalf("Do not match %v %v", expectedAll, ids)
|
||||
}
|
||||
|
||||
ids = f.rowsForColumn(1)
|
||||
ids = f.rowsForColumn(0, 1)
|
||||
if !reflect.DeepEqual(expectedOdd, ids) {
|
||||
t.Fatalf("Do not match %v %v", expectedOdd, ids)
|
||||
}
|
||||
|
|
@ -1370,7 +1370,7 @@ func TestFragment_RowsIteration(t *testing.T) {
|
|||
t.Fatalf("Do not match %v %v", expected, ids)
|
||||
}
|
||||
|
||||
ids = f.rowsForColumn(66000)
|
||||
ids = f.rowsForColumn(0, 66000)
|
||||
if !reflect.DeepEqual(expected, ids) {
|
||||
t.Fatalf("Do not match %v %v", expected, ids)
|
||||
}
|
||||
|
|
@ -1392,7 +1392,7 @@ func TestFragment_RowsIteration(t *testing.T) {
|
|||
if !reflect.DeepEqual(expectedRows, ids) {
|
||||
t.Fatalf("Do not match %v %v", expectedRows, ids)
|
||||
}
|
||||
ids = f.rowsForColumn(c)
|
||||
ids = f.rowsForColumn(0, c)
|
||||
if !reflect.DeepEqual(expectedRows, ids) {
|
||||
t.Fatalf("Do not match %v %v", expectedRows, ids)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue