Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #110 from travisturner/queryresulttype-switch
Browse files Browse the repository at this point in the history
Queryresulttype switch
  • Loading branch information
travisturner authored Jan 24, 2018
2 parents 459a331 + 6c3a0d7 commit ed17c17
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,32 +126,39 @@ type QueryResult struct {

func newQueryResultFromInternal(result *pbuf.QueryResult) (*QueryResult, error) {
var bitmapResult *BitmapResult
var countItems []*CountResultItem
var err error
var sum int64
var count uint64
var changed bool

if result.Type == QueryResultTypeBitmap {
// TODO: consider removing these defaults and only apply them to the switch
// cases for which they pertain.
bitmapResult = &BitmapResult{}
count = result.N
countItems = countItemsFromInternal(result.Pairs)

switch result.Type {
case QueryResultTypeBitmap:
bitmapResult, err = newBitmapResultFromInternal(result.Bitmap)
if err != nil {
return nil, err
}
} else {
bitmapResult = &BitmapResult{}
}
if result.Type == QueryResultTypeSumCount {
case QueryResultTypePairs:
//countItems = countItemsFromInternal(result.Pairs)
case QueryResultTypeSumCount:
sum = result.SumCount.Sum
count = uint64(result.SumCount.Count)
} else {
case QueryResultTypeUint64:
count = result.N
}
if result.Type == QueryResultTypeBool {
case QueryResultTypeBool:
changed = result.Changed
}

return &QueryResult{
Type: result.Type,
Bitmap: bitmapResult,
CountItems: countItemsFromInternal(result.Pairs),
CountItems: countItems,
Count: count,
Sum: sum,
Changed: changed,
Expand Down

0 comments on commit ed17c17

Please sign in to comment.