This commit is contained in:
Aliaksandr Valialkin 2024-05-17 11:04:50 +02:00
parent 900d74a560
commit 160034bda3
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
3 changed files with 15 additions and 7 deletions

View file

@ -95,7 +95,7 @@ func (br *blockResult) clone() *blockResult {
// initFromNeededColumns initializes br from brSrc, by copying only the given neededColumns for rows identified by set bits at bm.
//
// The br valid until brSrc is reset or bm is updated.
// The br valid until brSrc or bm is updated.
func (br *blockResult) initFromNeededColumns(brSrc *blockResult, bm *bitmap, neededColumns []string) {
br.reset()
@ -106,6 +106,11 @@ func (br *blockResult) initFromNeededColumns(brSrc *blockResult, bm *bitmap, nee
})
br.timestamps = dstTimestamps
if len(br.timestamps) == 0 {
// There is no need in initializing columns for zero rows.
return
}
for _, neededColumn := range neededColumns {
cSrc := brSrc.getColumnByName(neededColumn)
@ -1277,6 +1282,9 @@ func (br *blockResult) areSameColumns(columnNames []string) bool {
}
func (br *blockResult) getColumnByName(columnName string) *blockResultColumn {
if columnName == "" {
columnName = "_msg"
}
for _, c := range br.getColumns() {
if c.name == columnName {
return c

View file

@ -32,8 +32,8 @@ func (fp *filterPhrase) String() string {
return quoteFieldNameIfNeeded(fp.fieldName) + quoteTokenIfNeeded(fp.phrase)
}
func (fp *filterPhrase) updateNeededFields(neededColumns fieldsSet) {
neededColumns.add(fp.fieldName)
func (fp *filterPhrase) updateNeededFields(neededFields fieldsSet) {
neededFields.add(fp.fieldName)
}
func (fp *filterPhrase) getTokens() []string {

View file

@ -523,16 +523,16 @@ func parsePipeStats(lex *lexer) (*pipeStats, error) {
}
f.f = sf
neededFields := newFieldsSet()
f.f.updateNeededFields(neededFields)
f.neededFieldsForFunc = neededFields.getAll()
if lex.isKeyword("if") {
iff, err := parseIfFilter(lex)
if err != nil {
return nil, fmt.Errorf("cannot parse 'if' filter for %s: %w", sf, err)
}
f.iff = iff
neededFields := newFieldsSet()
iff.updateNeededFields(neededFields)
f.neededFieldsForFunc = neededFields.getAll()
}
resultName, err := parseResultName(lex)