forked from forgejo/forgejo
Update bleve dependency to latest master revision (#6100)
* update bleve to master b17287a86f6cac923a5d886e10618df994eeb54b6724eac2e3b8dde89cfbe3a2 * remove unused pkg from dep file * change bleve from master to recent revision
This commit is contained in:
parent
11e316654e
commit
a380cfd8e0
161 changed files with 9911 additions and 4233 deletions
133
vendor/github.com/couchbase/vellum/fst_iterator.go
generated
vendored
133
vendor/github.com/couchbase/vellum/fst_iterator.go
generated
vendored
|
@ -76,7 +76,8 @@ func newIterator(f *FST, startKeyInclusive, endKeyExclusive []byte,
|
|||
|
||||
// Reset resets the Iterator' internal state to allow for iterator
|
||||
// reuse (e.g. pooling).
|
||||
func (i *FSTIterator) Reset(f *FST, startKeyInclusive, endKeyExclusive []byte, aut Automaton) error {
|
||||
func (i *FSTIterator) Reset(f *FST,
|
||||
startKeyInclusive, endKeyExclusive []byte, aut Automaton) error {
|
||||
if aut == nil {
|
||||
aut = alwaysMatchAutomaton
|
||||
}
|
||||
|
@ -91,14 +92,14 @@ func (i *FSTIterator) Reset(f *FST, startKeyInclusive, endKeyExclusive []byte, a
|
|||
|
||||
// pointTo attempts to point us to the specified location
|
||||
func (i *FSTIterator) pointTo(key []byte) error {
|
||||
|
||||
// tried to seek before start
|
||||
if bytes.Compare(key, i.startKeyInclusive) < 0 {
|
||||
key = i.startKeyInclusive
|
||||
}
|
||||
|
||||
// trid to see past end
|
||||
if i.endKeyExclusive != nil && bytes.Compare(key, i.endKeyExclusive) > 0 {
|
||||
// tried to see past end
|
||||
if i.endKeyExclusive != nil &&
|
||||
bytes.Compare(key, i.endKeyExclusive) > 0 {
|
||||
key = i.endKeyExclusive
|
||||
}
|
||||
|
||||
|
@ -121,21 +122,23 @@ func (i *FSTIterator) pointTo(key []byte) error {
|
|||
i.statesStack = append(i.statesStack, root)
|
||||
i.autStatesStack = append(i.autStatesStack, autStart)
|
||||
for j := 0; j < len(key); j++ {
|
||||
keyJ := key[j]
|
||||
curr := i.statesStack[len(i.statesStack)-1]
|
||||
autCurr := i.autStatesStack[len(i.autStatesStack)-1]
|
||||
|
||||
pos, nextAddr, nextVal := curr.TransitionFor(key[j])
|
||||
pos, nextAddr, nextVal := curr.TransitionFor(keyJ)
|
||||
if nextAddr == noneAddr {
|
||||
// needed transition doesn't exist
|
||||
// find last trans before the one we needed
|
||||
for q := 0; q < curr.NumTransitions(); q++ {
|
||||
if curr.TransitionAt(q) < key[j] {
|
||||
for q := curr.NumTransitions() - 1; q >= 0; q-- {
|
||||
if curr.TransitionAt(q) < keyJ {
|
||||
maxQ = q
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
autNext := i.aut.Accept(autCurr, key[j])
|
||||
autNext := i.aut.Accept(autCurr, keyJ)
|
||||
|
||||
next, err := i.f.decoder.stateAt(nextAddr, nil)
|
||||
if err != nil {
|
||||
|
@ -143,14 +146,16 @@ func (i *FSTIterator) pointTo(key []byte) error {
|
|||
}
|
||||
|
||||
i.statesStack = append(i.statesStack, next)
|
||||
i.keysStack = append(i.keysStack, key[j])
|
||||
i.keysStack = append(i.keysStack, keyJ)
|
||||
i.keysPosStack = append(i.keysPosStack, pos)
|
||||
i.valsStack = append(i.valsStack, nextVal)
|
||||
i.autStatesStack = append(i.autStatesStack, autNext)
|
||||
continue
|
||||
}
|
||||
|
||||
if !i.statesStack[len(i.statesStack)-1].Final() || !i.aut.IsMatch(i.autStatesStack[len(i.autStatesStack)-1]) || bytes.Compare(i.keysStack, key) < 0 {
|
||||
if !i.statesStack[len(i.statesStack)-1].Final() ||
|
||||
!i.aut.IsMatch(i.autStatesStack[len(i.autStatesStack)-1]) ||
|
||||
bytes.Compare(i.keysStack, key) < 0 {
|
||||
return i.next(maxQ)
|
||||
}
|
||||
|
||||
|
@ -181,15 +186,12 @@ func (i *FSTIterator) Next() error {
|
|||
}
|
||||
|
||||
func (i *FSTIterator) next(lastOffset int) error {
|
||||
|
||||
// remember where we started
|
||||
if cap(i.nextStart) < len(i.keysStack) {
|
||||
i.nextStart = make([]byte, len(i.keysStack))
|
||||
} else {
|
||||
i.nextStart = i.nextStart[0:len(i.keysStack)]
|
||||
}
|
||||
copy(i.nextStart, i.keysStack)
|
||||
i.nextStart = append(i.nextStart[:0], i.keysStack...)
|
||||
|
||||
nextOffset := lastOffset + 1
|
||||
|
||||
OUTER:
|
||||
for true {
|
||||
curr := i.statesStack[len(i.statesStack)-1]
|
||||
autCurr := i.autStatesStack[len(i.autStatesStack)-1]
|
||||
|
@ -200,58 +202,62 @@ func (i *FSTIterator) next(lastOffset int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
nextOffset := lastOffset + 1
|
||||
if nextOffset < curr.NumTransitions() {
|
||||
numTrans := curr.NumTransitions()
|
||||
|
||||
INNER:
|
||||
for nextOffset < numTrans {
|
||||
t := curr.TransitionAt(nextOffset)
|
||||
autNext := i.aut.Accept(autCurr, t)
|
||||
if i.aut.CanMatch(autNext) {
|
||||
pos, nextAddr, v := curr.TransitionFor(t)
|
||||
|
||||
// the next slot in the statesStack might have an
|
||||
// fstState instance that we can reuse
|
||||
var nextPrealloc fstState
|
||||
if len(i.statesStack) < cap(i.statesStack) {
|
||||
nextPrealloc = i.statesStack[0:cap(i.statesStack)][len(i.statesStack)]
|
||||
}
|
||||
|
||||
// push onto stack
|
||||
next, err := i.f.decoder.stateAt(nextAddr, nextPrealloc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
i.statesStack = append(i.statesStack, next)
|
||||
i.keysStack = append(i.keysStack, t)
|
||||
i.keysPosStack = append(i.keysPosStack, pos)
|
||||
i.valsStack = append(i.valsStack, v)
|
||||
i.autStatesStack = append(i.autStatesStack, autNext)
|
||||
lastOffset = -1
|
||||
|
||||
// check to see if new keystack might have gone too far
|
||||
if i.endKeyExclusive != nil && bytes.Compare(i.keysStack, i.endKeyExclusive) >= 0 {
|
||||
return ErrIteratorDone
|
||||
}
|
||||
} else {
|
||||
lastOffset = nextOffset
|
||||
if !i.aut.CanMatch(autNext) {
|
||||
nextOffset += 1
|
||||
continue INNER
|
||||
}
|
||||
|
||||
continue
|
||||
pos, nextAddr, v := curr.TransitionFor(t)
|
||||
|
||||
// the next slot in the statesStack might have an
|
||||
// fstState instance that we can reuse
|
||||
var nextPrealloc fstState
|
||||
if len(i.statesStack) < cap(i.statesStack) {
|
||||
nextPrealloc = i.statesStack[0:cap(i.statesStack)][len(i.statesStack)]
|
||||
}
|
||||
|
||||
// push onto stack
|
||||
next, err := i.f.decoder.stateAt(nextAddr, nextPrealloc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i.statesStack = append(i.statesStack, next)
|
||||
i.keysStack = append(i.keysStack, t)
|
||||
i.keysPosStack = append(i.keysPosStack, pos)
|
||||
i.valsStack = append(i.valsStack, v)
|
||||
i.autStatesStack = append(i.autStatesStack, autNext)
|
||||
|
||||
// check to see if new keystack might have gone too far
|
||||
if i.endKeyExclusive != nil &&
|
||||
bytes.Compare(i.keysStack, i.endKeyExclusive) >= 0 {
|
||||
return ErrIteratorDone
|
||||
}
|
||||
|
||||
nextOffset = 0
|
||||
continue OUTER
|
||||
}
|
||||
|
||||
if len(i.statesStack) > 1 {
|
||||
// no transitions, and still room to pop
|
||||
i.statesStack = i.statesStack[:len(i.statesStack)-1]
|
||||
i.keysStack = i.keysStack[:len(i.keysStack)-1]
|
||||
lastOffset = i.keysPosStack[len(i.keysPosStack)-1]
|
||||
|
||||
i.keysPosStack = i.keysPosStack[:len(i.keysPosStack)-1]
|
||||
i.valsStack = i.valsStack[:len(i.valsStack)-1]
|
||||
i.autStatesStack = i.autStatesStack[:len(i.autStatesStack)-1]
|
||||
continue
|
||||
} else {
|
||||
if len(i.statesStack) <= 1 {
|
||||
// stack len is 1 (root), can't go back further, we're done
|
||||
break
|
||||
}
|
||||
|
||||
// no transitions, and still room to pop
|
||||
i.statesStack = i.statesStack[:len(i.statesStack)-1]
|
||||
i.keysStack = i.keysStack[:len(i.keysStack)-1]
|
||||
|
||||
nextOffset = i.keysPosStack[len(i.keysPosStack)-1] + 1
|
||||
|
||||
i.keysPosStack = i.keysPosStack[:len(i.keysPosStack)-1]
|
||||
i.valsStack = i.valsStack[:len(i.valsStack)-1]
|
||||
i.autStatesStack = i.autStatesStack[:len(i.autStatesStack)-1]
|
||||
}
|
||||
|
||||
return ErrIteratorDone
|
||||
|
@ -262,15 +268,12 @@ func (i *FSTIterator) next(lastOffset int) error {
|
|||
// seek operation would go past the last key, or outside the configured
|
||||
// startKeyInclusive/endKeyExclusive then ErrIteratorDone is returned.
|
||||
func (i *FSTIterator) Seek(key []byte) error {
|
||||
err := i.pointTo(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return i.pointTo(key)
|
||||
}
|
||||
|
||||
// Close will free any resources held by this iterator.
|
||||
func (i *FSTIterator) Close() error {
|
||||
// at the moment we don't do anything, but wanted this for API completeness
|
||||
// at the moment we don't do anything,
|
||||
// but wanted this for API completeness
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue