Skip to content

Commit

Permalink
Removing ProcessHistogramQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed May 7, 2024
1 parent 2de9dbd commit dbeec7b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 90 deletions.
35 changes: 0 additions & 35 deletions quesma/clickhouse/quesma_communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"math/rand"
"mitmproxy/quesma/logger"
"mitmproxy/quesma/model"
"sort"
"strings"
"time"
)
Expand Down Expand Up @@ -46,40 +45,6 @@ func (lm *LogManager) ProcessSelectQuery(ctx context.Context, table *Table, quer
return rows, err
}

func makeBuckets(ctx context.Context, result []model.QueryResultRow, bucket time.Duration) []model.QueryResultRow {
if len(result) == 0 {
return result
}

// type check only for 1st row, as all rows probably have the same type, and there can be a lot of them
firstKey := result[0].Cols[model.ResultColKeyIndex].Value
if _, ok := firstKey.(int64); !ok {
logger.ErrorWithCtx(ctx).Msgf("expected key to be int64, got %T, key: %v. Returning unchanged.", firstKey, firstKey)
return result
}

sort.Slice(result, func(i, j int) bool {
return result[i].Cols[model.ResultColKeyIndex].Value.(int64) < result[j].Cols[model.ResultColKeyIndex].Value.(int64)
})
for i := range result {
timestamp := result[i].Cols[model.ResultColKeyIndex].Value.(int64) * bucket.Milliseconds()
result[i].Cols[model.ResultColKeyIndex].Value = timestamp
result[i].Cols = append(result[i].Cols, model.QueryResultCol{
ColName: "key_as_string",
Value: time.UnixMilli(timestamp).UTC().Format("2006-01-02T15:04:05.000"),
})
}
return result
}

func (lm *LogManager) ProcessHistogramQuery(ctx context.Context, table *Table, query *model.Query, bucket time.Duration) ([]model.QueryResultRow, error) {
result, err := executeQuery(ctx, lm, table.Name, query.String(), []string{"key", "doc_count"}, []interface{}{int64(0), uint64(0)})
if err != nil {
return nil, err
}
return makeBuckets(ctx, result, bucket), nil
}

// TODO add support for autocomplete for attributes, if we'll find it needed
func (lm *LogManager) ProcessFacetsQuery(ctx context.Context, table *Table, query *model.Query) ([]model.QueryResultRow, error) {
colNames, err := table.extractColumns(query, false)
Expand Down
55 changes: 0 additions & 55 deletions quesma/clickhouse/quesma_communicator_test.go

This file was deleted.

0 comments on commit dbeec7b

Please sign in to comment.