This commit is contained in:
Aliaksandr Valialkin 2024-05-05 03:11:34 +02:00
parent 90390cdc02
commit c716c1f074
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
5 changed files with 26 additions and 26 deletions

View file

@ -121,7 +121,7 @@ func (br *blockResult) fetchAllColumns(bs *blockSearch, bm *bitmap) {
}
func (br *blockResult) fetchRequestedColumns(bs *blockSearch, bm *bitmap) {
for _, columnName := range bs.bsw.so.resultColumnNames {
for _, columnName := range bs.bsw.so.neededColumnNames {
switch columnName {
case "_stream":
if !br.addStreamColumn(bs) {

View file

@ -151,7 +151,7 @@ func TestComplexFilters(t *testing.T) {
testFilterMatchForColumns(t, columns, f, "foo", []int{1, 3, 6})
}
func testFilterMatchForColumns(t *testing.T, columns []column, f filter, resultColumnName string, expectedRowIdxs []int) {
func testFilterMatchForColumns(t *testing.T, columns []column, f filter, neededColumnName string, expectedRowIdxs []int) {
t.Helper()
// Create the test storage
@ -168,7 +168,7 @@ func testFilterMatchForColumns(t *testing.T, columns []column, f filter, resultC
var values []string
for _, c := range columns {
if c.name == resultColumnName {
if c.name == neededColumnName {
values = c.values
break
}
@ -180,20 +180,20 @@ func testFilterMatchForColumns(t *testing.T, columns []column, f filter, resultC
expectedTimestamps[i] = int64(idx) * 1e9
}
testFilterMatchForStorage(t, s, tenantID, f, resultColumnName, expectedResults, expectedTimestamps)
testFilterMatchForStorage(t, s, tenantID, f, neededColumnName, expectedResults, expectedTimestamps)
// Close and delete the test storage
s.MustClose()
fs.MustRemoveAll(storagePath)
}
func testFilterMatchForStorage(t *testing.T, s *Storage, tenantID TenantID, f filter, resultColumnName string, expectedResults []string, expectedTimestamps []int64) {
func testFilterMatchForStorage(t *testing.T, s *Storage, tenantID TenantID, f filter, neededColumnName string, expectedResults []string, expectedTimestamps []int64) {
t.Helper()
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{resultColumnName},
neededColumnNames: []string{neededColumnName},
}
workersCount := 3
s.search(workersCount, so, nil, func(_ uint, br *blockResult) {

View file

@ -201,7 +201,7 @@ func (q *Query) String() string {
return s
}
func (q *Query) getResultColumnNames() []string {
func (q *Query) getNeededColumns() []string {
input := []string{"*"}
dropFields := make(map[string]struct{})

View file

@ -19,8 +19,8 @@ type genericSearchOptions struct {
// filter is the filter to use for the search
filter filter
// resultColumnNames is names of columns to return in the result
resultColumnNames []string
// neededColumnNames is names of columns to return in the result
neededColumnNames []string
// needAllColumns is set to true when all the columns must be returned in the result
needAllColumns bool
@ -44,8 +44,8 @@ type searchOptions struct {
// filter is the filter to use for the search
filter filter
// resultColumnNames is names of columns to return in the result
resultColumnNames []string
// neededColumnNames is names of columns to return in the result
neededColumnNames []string
// needAllColumns is set to true when all the columns must be returned in the result
needAllColumns bool
@ -53,12 +53,12 @@ type searchOptions struct {
// RunQuery runs the given q and calls writeBlock for results.
func (s *Storage) RunQuery(ctx context.Context, tenantIDs []TenantID, q *Query, writeBlock func(workerID uint, timestamps []int64, columns []BlockColumn)) error {
resultColumnNames := q.getResultColumnNames()
neededColumnNames := q.getNeededColumns()
so := &genericSearchOptions{
tenantIDs: tenantIDs,
filter: q.f,
resultColumnNames: resultColumnNames,
needAllColumns: slices.Contains(resultColumnNames, "*"),
neededColumnNames: neededColumnNames,
needAllColumns: slices.Contains(neededColumnNames, "*"),
}
workersCount := cgroup.AvailableCPUs()
@ -323,7 +323,7 @@ func (pt *partition) search(ft *filterTime, sf *StreamFilter, f filter, so *gene
minTimestamp: ft.minTimestamp,
maxTimestamp: ft.maxTimestamp,
filter: f,
resultColumnNames: so.resultColumnNames,
neededColumnNames: so.neededColumnNames,
needAllColumns: so.needAllColumns,
}
return pt.ddb.search(soInternal, workCh, stopCh)

View file

@ -404,7 +404,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
processBlock := func(_ uint, _ *blockResult) {
panic(fmt.Errorf("unexpected match"))
@ -422,7 +422,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
processBlock := func(_ uint, _ *blockResult) {
panic(fmt.Errorf("unexpected match"))
@ -440,7 +440,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
processBlock := func(_ uint, _ *blockResult) {
panic(fmt.Errorf("unexpected match"))
@ -459,7 +459,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -483,7 +483,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: allTenantIDs,
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -504,7 +504,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: allTenantIDs,
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
processBlock := func(_ uint, _ *blockResult) {
panic(fmt.Errorf("unexpected match"))
@ -524,7 +524,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -553,7 +553,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -590,7 +590,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -618,7 +618,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
var rowsCountTotal atomic.Uint32
processBlock := func(_ uint, br *blockResult) {
@ -643,7 +643,7 @@ func TestStorageSearch(t *testing.T) {
so := &genericSearchOptions{
tenantIDs: []TenantID{tenantID},
filter: f,
resultColumnNames: []string{"_msg"},
neededColumnNames: []string{"_msg"},
}
processBlock := func(_ uint, _ *blockResult) {
panic(fmt.Errorf("unexpected match"))