mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 23:31:03 +00:00
Merge pull request #339 from kuba--/getridof-rowid
get rid of rowID from groupby on ints response
This commit is contained in:
commit
1a00008dbd
3 changed files with 24 additions and 30 deletions
|
|
@ -1398,14 +1398,13 @@ func decodeFieldRows(a []*internal.FieldRow) []pilosa.FieldRow {
|
|||
for i := range a {
|
||||
fr := a[i]
|
||||
other[i].Field = fr.Field
|
||||
if fr.RowKey == "" {
|
||||
if fr.Value != nil {
|
||||
other[i].Value = &fr.Value.Value
|
||||
} else if fr.RowKey == "" {
|
||||
other[i].RowID = fr.RowID
|
||||
} else {
|
||||
other[i].RowKey = fr.RowKey
|
||||
}
|
||||
if fr.Value != nil {
|
||||
other[i].Value = &fr.Value.Value
|
||||
}
|
||||
}
|
||||
return other
|
||||
}
|
||||
|
|
@ -1532,19 +1531,14 @@ func encodeFieldRows(a []pilosa.FieldRow) []*internal.FieldRow {
|
|||
other := make([]*internal.FieldRow, len(a))
|
||||
for i := range a {
|
||||
fr := a[i]
|
||||
if fr.RowKey == "" {
|
||||
other[i] = &internal.FieldRow{
|
||||
Field: fr.Field,
|
||||
RowID: fr.RowID,
|
||||
}
|
||||
if fr.Value != nil {
|
||||
other[i].Value = &internal.Int64{Value: *fr.Value}
|
||||
}
|
||||
other[i] = &internal.FieldRow{Field: fr.Field}
|
||||
|
||||
if fr.Value != nil {
|
||||
other[i].Value = &internal.Int64{Value: *fr.Value}
|
||||
} else if fr.RowKey == "" {
|
||||
other[i].RowID = fr.RowID
|
||||
} else {
|
||||
other[i] = &internal.FieldRow{
|
||||
Field: fr.Field,
|
||||
RowKey: fr.RowKey,
|
||||
}
|
||||
other[i].RowKey = fr.RowKey
|
||||
}
|
||||
}
|
||||
return other
|
||||
|
|
|
|||
20
executor.go
20
executor.go
|
|
@ -1844,16 +1844,6 @@ type FieldRow struct {
|
|||
// MarshalJSON marshals FieldRow to JSON such that
|
||||
// either a Key or an ID is included.
|
||||
func (fr FieldRow) MarshalJSON() ([]byte, error) {
|
||||
if fr.RowKey != "" {
|
||||
return json.Marshal(struct {
|
||||
Field string `json:"field"`
|
||||
RowKey string `json:"rowKey"`
|
||||
}{
|
||||
Field: fr.Field,
|
||||
RowKey: fr.RowKey,
|
||||
})
|
||||
}
|
||||
|
||||
if fr.Value != nil {
|
||||
return json.Marshal(struct {
|
||||
Field string `json:"field"`
|
||||
|
|
@ -1864,6 +1854,16 @@ func (fr FieldRow) MarshalJSON() ([]byte, error) {
|
|||
})
|
||||
}
|
||||
|
||||
if fr.RowKey != "" {
|
||||
return json.Marshal(struct {
|
||||
Field string `json:"field"`
|
||||
RowKey string `json:"rowKey"`
|
||||
}{
|
||||
Field: fr.Field,
|
||||
RowKey: fr.RowKey,
|
||||
})
|
||||
}
|
||||
|
||||
return json.Marshal(struct {
|
||||
Field string `json:"field"`
|
||||
RowID uint64 `json:"rowID"`
|
||||
|
|
|
|||
|
|
@ -2886,10 +2886,10 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
} else {
|
||||
var a, b, c, d int64 = -2, -1, 0, 4
|
||||
expected := []pilosa.GroupCount{
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", RowID: 0, Value: &a}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", RowID: 1, Value: &b}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", RowID: 2, Value: &c}}, Count: 5},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", RowID: 5, Value: &d}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", Value: &a}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", Value: &b}}, Count: 1},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", Value: &c}}, Count: 5},
|
||||
{Group: []pilosa.FieldRow{{Field: "fint", Value: &d}}, Count: 1},
|
||||
}
|
||||
|
||||
results := res.Results[0].([]pilosa.GroupCount)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue