Skip to content

Commit abdb374

Browse files
committed
MB-36088 - Refactored much of data type comparisons and added N1QL-like collate to fast matcher
1 parent 47d764f commit abdb374

File tree

8 files changed

+802
-109
lines changed

8 files changed

+802
-109
lines changed

fastMatcher.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ type slotData struct {
1414
var emptySlotData slotData
1515

1616
type FastMatcher struct {
17-
def MatchDef
18-
slots []slotData
19-
buckets *binTreeState
20-
tokens jsonTokenizer
17+
def MatchDef
18+
slots []slotData
19+
buckets *binTreeState
20+
tokens jsonTokenizer
21+
collateUsed bool
2122
}
2223

2324
func NewFastMatcher(def *MatchDef) *FastMatcher {
@@ -292,11 +293,10 @@ func (m *FastMatcher) matchOp(op *OpNode, litVal *FastVal) error {
292293
}
293294

294295
// Mark the result of this operation
296+
m.buckets.MarkNode(bucketIdx, opRes)
297+
295298
if !validOp {
296-
// TODO FIX
297-
m.buckets.MarkNode(bucketIdx, false)
298-
} else {
299-
m.buckets.MarkNode(bucketIdx, opRes)
299+
m.collateUsed = true
300300
}
301301

302302
// Check if running this values ops has resolved the entirety
@@ -832,6 +832,15 @@ func (m *FastMatcher) Match(data []byte) (bool, error) {
832832
return m.buckets.IsTrue(0), nil
833833
}
834834

835+
func (m *FastMatcher) MatchWithStatus(data []byte) (bool, int, error) {
836+
var statusFlags int
837+
matched, err := m.Match(data)
838+
if m.collateUsed {
839+
statusFlags |= MatcherCollateUsed
840+
}
841+
return matched, statusFlags, err
842+
}
843+
835844
func (m *FastMatcher) ExpressionMatched(expressionIdx int) bool {
836845
binTreeIdx := m.def.MatchBuckets[expressionIdx]
837846
return m.buckets.IsResolved(binTreeIdx) &&

fastMatcher_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ func TestMatcherMissingNotEquals(t *testing.T) {
178178
"5b47eb098eee4b4c4330ec64",
179179
"5b47eb0936ff92a567a0307e",
180180
"5b47eb096b1d911c0b9492fb",
181+
"5b47eb0950e9076fc0aecd52",
181182
})
182183
}
183184

0 commit comments

Comments
 (0)