-
Notifications
You must be signed in to change notification settings - Fork 178
/
dechecker.go
104 lines (84 loc) · 2.67 KB
/
dechecker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2021-2024 SigScalr, Inc.
//
// This file is part of SigLens Observability Solution
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package segread
import (
"errors"
"github.com/siglens/siglens/pkg/segment/structs"
"github.com/siglens/siglens/pkg/segment/utils"
"github.com/siglens/siglens/pkg/segment/writer"
)
/*
parameters:
matchFilter : input query mf
dictData: mapping of dict keywords --> raw recNums buf slice
returns:
bool: if there is a match
err
*/
func (sfr *SegmentFileReader) ApplySearchToMatchFilterDictCsg(match *structs.MatchFilter,
bsh *structs.BlockSearchHelper) (bool, error) {
if len(match.MatchWords) == 0 {
return false, nil
}
for dwordIdx, dWord := range sfr.deTlv {
matched, err := writer.ApplySearchToMatchFilterRawCsg(match, dWord)
if err != nil {
return false, err
}
if matched {
addRecNumsToMr(uint16(dwordIdx), bsh, sfr)
}
}
return false, nil
}
/*
parameters:
DtypeEnclosure : input qVal
FilterOperator: filter operator
isRegexSearch:
dictData: mapping of dict keywords --> raw recNums buf slice
returns:
bool: if there is a match
err
*/
func (sfr *SegmentFileReader) ApplySearchToExpressionFilterDictCsg(qValDte *utils.DtypeEnclosure,
fop utils.FilterOperator, isRegexSearch bool, bsh *structs.BlockSearchHelper) (bool, error) {
if qValDte == nil {
return false, nil
}
if isRegexSearch && qValDte.GetRegexp() == nil {
return false, errors.New("SegmentFileReader.ApplySearchToExpressionFilterDictCsg: qValDte had nil regexp compilation")
}
dte := &utils.DtypeEnclosure{}
for dwordIdx, dWord := range sfr.deTlv {
matched, err := writer.ApplySearchToExpressionFilterSimpleCsg(qValDte, fop, dWord, isRegexSearch, dte)
if err != nil {
return false, err
}
if matched {
addRecNumsToMr(uint16(dwordIdx), bsh, sfr)
}
}
return false, nil
}
func addRecNumsToMr(dwordIdx uint16, bsh *structs.BlockSearchHelper, sfr *SegmentFileReader) {
for i := uint16(0); i < sfr.blockSummaries[sfr.currBlockNum].RecCount; i++ {
if sfr.deRecToTlv[i] == dwordIdx {
bsh.AddMatchedRecord(uint(i))
}
}
}