From c716c1f074487ad3b7d60219e09d07a6c8b2719b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 5 May 2024 03:11:34 +0200 Subject: [PATCH] wip --- lib/logstorage/block_result.go | 2 +- lib/logstorage/filter_test.go | 10 +++++----- lib/logstorage/parser.go | 2 +- lib/logstorage/storage_search.go | 16 ++++++++-------- lib/logstorage/storage_search_test.go | 22 +++++++++++----------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/logstorage/block_result.go b/lib/logstorage/block_result.go index 9941d939c..ab556a401 100644 --- a/lib/logstorage/block_result.go +++ b/lib/logstorage/block_result.go @@ -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) { diff --git a/lib/logstorage/filter_test.go b/lib/logstorage/filter_test.go index e05792d11..875ecc333 100644 --- a/lib/logstorage/filter_test.go +++ b/lib/logstorage/filter_test.go @@ -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) { diff --git a/lib/logstorage/parser.go b/lib/logstorage/parser.go index ff3b998ca..7d4d16f8d 100644 --- a/lib/logstorage/parser.go +++ b/lib/logstorage/parser.go @@ -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{}) diff --git a/lib/logstorage/storage_search.go b/lib/logstorage/storage_search.go index 5abadecbc..3615be02a 100644 --- a/lib/logstorage/storage_search.go +++ b/lib/logstorage/storage_search.go @@ -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) diff --git a/lib/logstorage/storage_search_test.go b/lib/logstorage/storage_search_test.go index 5c1c00bbf..0958c9190 100644 --- a/lib/logstorage/storage_search_test.go +++ b/lib/logstorage/storage_search_test.go @@ -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"))