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) { func (br *blockResult) fetchRequestedColumns(bs *blockSearch, bm *bitmap) {
for _, columnName := range bs.bsw.so.resultColumnNames { for _, columnName := range bs.bsw.so.neededColumnNames {
switch columnName { switch columnName {
case "_stream": case "_stream":
if !br.addStreamColumn(bs) { if !br.addStreamColumn(bs) {

View file

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

View file

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

View file

@ -19,8 +19,8 @@ type genericSearchOptions struct {
// filter is the filter to use for the search // filter is the filter to use for the search
filter filter filter filter
// resultColumnNames is names of columns to return in the result // neededColumnNames is names of columns to return in the result
resultColumnNames []string neededColumnNames []string
// needAllColumns is set to true when all the columns must be returned in the result // needAllColumns is set to true when all the columns must be returned in the result
needAllColumns bool needAllColumns bool
@ -44,8 +44,8 @@ type searchOptions struct {
// filter is the filter to use for the search // filter is the filter to use for the search
filter filter filter filter
// resultColumnNames is names of columns to return in the result // neededColumnNames is names of columns to return in the result
resultColumnNames []string neededColumnNames []string
// needAllColumns is set to true when all the columns must be returned in the result // needAllColumns is set to true when all the columns must be returned in the result
needAllColumns bool needAllColumns bool
@ -53,12 +53,12 @@ type searchOptions struct {
// RunQuery runs the given q and calls writeBlock for results. // 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 { 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{ so := &genericSearchOptions{
tenantIDs: tenantIDs, tenantIDs: tenantIDs,
filter: q.f, filter: q.f,
resultColumnNames: resultColumnNames, neededColumnNames: neededColumnNames,
needAllColumns: slices.Contains(resultColumnNames, "*"), needAllColumns: slices.Contains(neededColumnNames, "*"),
} }
workersCount := cgroup.AvailableCPUs() workersCount := cgroup.AvailableCPUs()
@ -323,7 +323,7 @@ func (pt *partition) search(ft *filterTime, sf *StreamFilter, f filter, so *gene
minTimestamp: ft.minTimestamp, minTimestamp: ft.minTimestamp,
maxTimestamp: ft.maxTimestamp, maxTimestamp: ft.maxTimestamp,
filter: f, filter: f,
resultColumnNames: so.resultColumnNames, neededColumnNames: so.neededColumnNames,
needAllColumns: so.needAllColumns, needAllColumns: so.needAllColumns,
} }
return pt.ddb.search(soInternal, workCh, stopCh) return pt.ddb.search(soInternal, workCh, stopCh)

View file

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