本文整理匯總了Golang中github.com/richardlehane/siegfried/pkg/core/siegreader.Buffer.Size方法的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer.Size方法的具體用法?Golang Buffer.Size怎麽用?Golang Buffer.Size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/richardlehane/siegfried/pkg/core/siegreader.Buffer
的用法示例。
在下文中一共展示了Buffer.Size方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: scorer
func (b *Matcher) scorer(buf *siegreader.Buffer, q chan struct{}, r chan<- core.Result) chan<- strike {
incoming := make(chan strike)
waitSet := b.priorities.WaitSet()
hits := make(map[int]*hitItem)
strikes := make(map[int]*strikeItem)
var bof int64
var eof int64
var quitting bool
quit := func() {
close(q)
quitting = true
}
newHit := func(i int) *hitItem {
l := len(b.keyFrames[i])
hit := &hitItem{
potentialIdxs: make([]int, l),
partials: make([][][2]int64, l),
}
hits[i] = hit
return hit
}
// given the current bof and eof, is there anything worth waiting for?
continueWaiting := func(w []int) bool {
var keepScanning bool
// now for each of the possible signatures we are either waiting on or have partial/potential matches for, check whether there are live contenders
for _, v := range w {
kf := b.keyFrames[v]
for i, f := range kf {
off := bof
if f.typ > frames.PREV {
off = eof
}
var waitfor, excludable bool
if f.key.pMax == -1 || f.key.pMax+int64(f.key.lMax) > off {
waitfor = true
} else if hit, ok := hits[v]; ok {
if hit.partials[i] != nil {
waitfor = true
} else if hit.potentialIdxs[i] > 0 && strikes[hit.potentialIdxs[i]-1].hasPotential() {
waitfor, excludable = true, true
}
}
// if we've got to the end of the signature, and have determined this is a live one - return immediately & continue scan
if waitfor {
if i == len(kf)-1 {
if !config.Slow() || !config.Checkpoint(bof) {
return true
}
keepScanning = true
fmt.Fprintf(config.Out(), "waiting on: %d, potentially excludable: %t\n", v, excludable)
}
continue
}
break
}
}
return keepScanning
}
testStrike := func(st strike) []kfHit {
// the offsets we *record* are always BOF offsets - these can be interpreted as EOF offsets when necessary
off := st.offset
if st.reverse {
off = buf.Size() - st.offset - int64(st.length)
}
// grab the relevant testTree
t := b.tests[st.idxa+st.idxb]
res := make([]kfHit, 0, 10)
// immediately apply key frames for the completes
for _, kf := range t.complete {
if b.keyFrames[kf[0]][kf[1]].check(st.offset) && waitSet.Check(kf[0]) {
res = append(res, kfHit{kf, off, st.length})
}
}
// if there are no incompletes, we are done
if len(t.incomplete) < 1 {
return res
}
// see what incompletes are worth pursuing
var checkl, checkr bool
for _, v := range t.incomplete {
if checkl && checkr {
break
}
if b.keyFrames[v.kf[0]][v.kf[1]].check(st.offset) && waitSet.Check(v.kf[0]) {
if v.l {
checkl = true
}
if v.r {
checkr = true
}
}
}
if !checkl && !checkr {
return res
}
//.........這裏部分代碼省略.........