Skip to content

Commit

Permalink
MB-36088 - Refactored much of data type comparisons and added N1QL-li…
Browse files Browse the repository at this point in the history
…ke collate to fast matcher
  • Loading branch information
nelio2k committed Nov 4, 2019
1 parent 47d764f commit abdb374
Show file tree
Hide file tree
Showing 8 changed files with 802 additions and 109 deletions.
25 changes: 17 additions & 8 deletions fastMatcher.go
Expand Up @@ -14,10 +14,11 @@ type slotData struct {
var emptySlotData slotData

type FastMatcher struct {
def MatchDef
slots []slotData
buckets *binTreeState
tokens jsonTokenizer
def MatchDef
slots []slotData
buckets *binTreeState
tokens jsonTokenizer
collateUsed bool
}

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

// Mark the result of this operation
m.buckets.MarkNode(bucketIdx, opRes)

if !validOp {
// TODO FIX
m.buckets.MarkNode(bucketIdx, false)
} else {
m.buckets.MarkNode(bucketIdx, opRes)
m.collateUsed = true
}

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

func (m *FastMatcher) MatchWithStatus(data []byte) (bool, int, error) {
var statusFlags int
matched, err := m.Match(data)
if m.collateUsed {
statusFlags |= MatcherCollateUsed
}
return matched, statusFlags, err
}

func (m *FastMatcher) ExpressionMatched(expressionIdx int) bool {
binTreeIdx := m.def.MatchBuckets[expressionIdx]
return m.buckets.IsResolved(binTreeIdx) &&
Expand Down
1 change: 1 addition & 0 deletions fastMatcher_test.go
Expand Up @@ -178,6 +178,7 @@ func TestMatcherMissingNotEquals(t *testing.T) {
"5b47eb098eee4b4c4330ec64",
"5b47eb0936ff92a567a0307e",
"5b47eb096b1d911c0b9492fb",
"5b47eb0950e9076fc0aecd52",
})
}

Expand Down

0 comments on commit abdb374

Please sign in to comment.