|
|
|
@ -133,53 +133,54 @@ func (m MultiStageExpr) stages() ([]log.Stage, error) { |
|
|
|
|
// are as close to the front of the filter as possible.
|
|
|
|
|
func (m MultiStageExpr) reorderStages() []StageExpr { |
|
|
|
|
var ( |
|
|
|
|
result = make([]StageExpr, 0, len(m)) |
|
|
|
|
filters = make([]*LineFilterExpr, 0, len(m)) |
|
|
|
|
rest = make([]StageExpr, 0, len(m)) |
|
|
|
|
result = make([]StageExpr, 0, len(m)) |
|
|
|
|
lineFilters = make([]*LineFilterExpr, 0, len(m)) |
|
|
|
|
notLineFilters = make([]StageExpr, 0, len(m)) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
combineFilters := func() { |
|
|
|
|
if len(lineFilters) > 0 { |
|
|
|
|
result = append(result, combineFilters(lineFilters)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result = append(result, notLineFilters...) |
|
|
|
|
|
|
|
|
|
lineFilters = lineFilters[:0] |
|
|
|
|
notLineFilters = notLineFilters[:0] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for _, s := range m { |
|
|
|
|
switch f := s.(type) { |
|
|
|
|
case *LabelFilterExpr: |
|
|
|
|
combineFilters() |
|
|
|
|
result = append(result, f) |
|
|
|
|
case *LineFilterExpr: |
|
|
|
|
filters = append(filters, f) |
|
|
|
|
lineFilters = append(lineFilters, f) |
|
|
|
|
case *LineFmtExpr: |
|
|
|
|
// line_format modifies the contents of the line so any line filter
|
|
|
|
|
// originally after a line_format must still be after the same
|
|
|
|
|
// line_format.
|
|
|
|
|
|
|
|
|
|
rest = append(rest, f) |
|
|
|
|
notLineFilters = append(notLineFilters, f) |
|
|
|
|
|
|
|
|
|
if len(filters) > 0 { |
|
|
|
|
result = append(result, combineFilters(filters)) |
|
|
|
|
} |
|
|
|
|
result = append(result, rest...) |
|
|
|
|
|
|
|
|
|
filters = filters[:0] |
|
|
|
|
rest = rest[:0] |
|
|
|
|
combineFilters() |
|
|
|
|
case *LabelParserExpr: |
|
|
|
|
rest = append(rest, f) |
|
|
|
|
notLineFilters = append(notLineFilters, f) |
|
|
|
|
|
|
|
|
|
// unpack modifies the contents of the line so any line filter
|
|
|
|
|
// originally after an unpack must still be after the same
|
|
|
|
|
// unpack.
|
|
|
|
|
if f.Op == OpParserTypeUnpack { |
|
|
|
|
if len(filters) > 0 { |
|
|
|
|
result = append(result, combineFilters(filters)) |
|
|
|
|
} |
|
|
|
|
result = append(result, rest...) |
|
|
|
|
|
|
|
|
|
filters = filters[:0] |
|
|
|
|
rest = rest[:0] |
|
|
|
|
combineFilters() |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
rest = append(rest, f) |
|
|
|
|
notLineFilters = append(notLineFilters, f) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(filters) > 0 { |
|
|
|
|
result = append(result, combineFilters(filters)) |
|
|
|
|
} |
|
|
|
|
return append(result, rest...) |
|
|
|
|
combineFilters() |
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func combineFilters(in []*LineFilterExpr) StageExpr { |
|
|
|
|