mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #913 from niaow/misaligned-distinct
Fix misaligned bitmaps in Distinct
This commit is contained in:
commit
cac89f4c96
2 changed files with 15 additions and 15 deletions
|
|
@ -1425,7 +1425,7 @@ func (e *executor) executeDistinctShard(ctx context.Context, qcx *Qcx, index str
|
|||
tx, finisher := qcx.GetTx(Txo{Write: !writable, Index: idx, Shard: shard})
|
||||
defer finisher(&err)
|
||||
|
||||
existsBitmap, err := tx.OffsetRange(index, fieldName, view, shard, 0, ShardWidth*0, ShardWidth*1)
|
||||
existsBitmap, err := tx.OffsetRange(index, fieldName, view, shard, ShardWidth*shard, ShardWidth*0, ShardWidth*1)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
|
@ -1436,7 +1436,7 @@ func (e *executor) executeDistinctShard(ctx context.Context, qcx *Qcx, index str
|
|||
return result, nil
|
||||
}
|
||||
|
||||
signBitmap, err := tx.OffsetRange(index, fieldName, view, shard, 0, ShardWidth*1, ShardWidth*2)
|
||||
signBitmap, err := tx.OffsetRange(index, fieldName, view, shard, ShardWidth*shard, ShardWidth*1, ShardWidth*2)
|
||||
if err != nil {
|
||||
return result, nil
|
||||
}
|
||||
|
|
@ -1444,7 +1444,7 @@ func (e *executor) executeDistinctShard(ctx context.Context, qcx *Qcx, index str
|
|||
dataBitmaps := make([]*roaring.Bitmap, depth)
|
||||
|
||||
for i := uint64(0); i < depth; i++ {
|
||||
dataBitmaps[i], err = tx.OffsetRange(index, fieldName, view, shard, 0, ShardWidth*(i+2), ShardWidth*(i+3))
|
||||
dataBitmaps[i], err = tx.OffsetRange(index, fieldName, view, shard, ShardWidth*shard, ShardWidth*(i+2), ShardWidth*(i+3))
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5293,7 +5293,7 @@ func TestExecutor_ForeignIndex(t *testing.T) {
|
|||
)
|
||||
|
||||
// Populate parent data.
|
||||
c.Query(t, "parent", `
|
||||
c.Query(t, "parent", fmt.Sprintf(`
|
||||
Set("one", general=1)
|
||||
Set("two", general=1)
|
||||
Set("three", general=1)
|
||||
|
|
@ -5302,25 +5302,25 @@ func TestExecutor_ForeignIndex(t *testing.T) {
|
|||
Set("twenty-two", general=2)
|
||||
Set("twenty-three", general=2)
|
||||
|
||||
Set("one", general=3)
|
||||
Set("twenty-one", general=3)
|
||||
`)
|
||||
Set("one", general=%d)
|
||||
Set("twenty-one", general=%d)
|
||||
`, ShardWidth, ShardWidth))
|
||||
|
||||
// Populate child data.
|
||||
c.Query(t, "child", `
|
||||
c.Query(t, "child", fmt.Sprintf(`
|
||||
Set(1, parent_id="one")
|
||||
Set(2, parent_id="two")
|
||||
Set(3, parent_id="one")
|
||||
Set(%d, parent_id="one")
|
||||
Set(4, parent_id="twenty-one")
|
||||
`)
|
||||
`, ShardWidth))
|
||||
|
||||
// Populate color data.
|
||||
c.Query(t, "child", `
|
||||
c.Query(t, "child", fmt.Sprintf(`
|
||||
Set(1, color="red")
|
||||
Set(2, color="blue")
|
||||
Set(3, color="blue")
|
||||
Set(%d, color="blue")
|
||||
Set(4, color="red")
|
||||
`)
|
||||
`, ShardWidth))
|
||||
|
||||
distinct := c.Query(t, "child", `Distinct(index="child", field="parent_id")`).Results[0].(pilosa.SignedRow)
|
||||
if !sameStringSlice(distinct.Pos.Keys, []string{"one", "two", "twenty-one"}) {
|
||||
|
|
@ -5328,7 +5328,7 @@ func TestExecutor_ForeignIndex(t *testing.T) {
|
|||
}
|
||||
|
||||
eq := c.Query(t, "child", `Row(parent_id=="one")`).Results[0].(*pilosa.Row)
|
||||
if !reflect.DeepEqual(eq.Columns(), []uint64{1, 3}) {
|
||||
if !reflect.DeepEqual(eq.Columns(), []uint64{1, ShardWidth}) {
|
||||
t.Fatalf("unexpected columns: %v", eq.Columns())
|
||||
}
|
||||
|
||||
|
|
@ -5337,7 +5337,7 @@ func TestExecutor_ForeignIndex(t *testing.T) {
|
|||
t.Fatalf("unexpected columns: %v", neq.Columns())
|
||||
}
|
||||
|
||||
join := c.Query(t, "parent", `Intersect(Row(general=3), Distinct(Row(color="blue"), index="child", field="parent_id"))`).Results[0].(*pilosa.Row)
|
||||
join := c.Query(t, "parent", fmt.Sprintf(`Intersect(Row(general=%d), Distinct(Row(color="blue"), index="child", field="parent_id"))`, ShardWidth)).Results[0].(*pilosa.Row)
|
||||
if !reflect.DeepEqual(join.Keys, []string{"one"}) {
|
||||
t.Fatalf("unexpected keys: %v", join.Keys)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue