本文整理匯總了Golang中github.com/richardlehane/siegfried/pkg/core/siegreader.Buffer.Stream方法的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer.Stream方法的具體用法?Golang Buffer.Stream怎麽用?Golang Buffer.Stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/richardlehane/siegfried/pkg/core/siegreader.Buffer
的用法示例。
在下文中一共展示了Buffer.Stream方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: identify
// Identify function - brings a new matcher into existence
func (b *Matcher) identify(buf siegreader.Buffer, quit chan struct{}, r chan core.Result) {
buf.SetQuit(quit)
incoming := b.scorer(buf, quit, r)
rdr := siegreader.LimitReaderFrom(buf, b.maxBOF)
// First test BOF frameset
bfchan := b.bofFrames.index(buf, false, quit)
for bf := range bfchan {
if config.Debug() {
fmt.Println(strike{b.bofFrames.testTreeIndex[bf.idx], 0, bf.off, bf.length, false, true})
}
incoming <- strike{b.bofFrames.testTreeIndex[bf.idx], 0, bf.off, bf.length, false, true}
}
select {
case <-quit: // the matcher has called quit
for _ = range bfchan {
} // drain first
close(incoming)
return
default:
}
// Do an initial check of BOF sequences
b.start(true) // start bof matcher if not yet started
var bchan chan wac.Result
bchan = b.bAho.Index(rdr)
for br := range bchan {
if br.Index[0] == -1 {
incoming <- progressStrike(br.Offset, false)
if !buf.Stream() && br.Offset > 131072 && (b.maxBOF < 0 || b.maxBOF > b.maxEOF*5) {
break
}
} else {
if config.Debug() {
fmt.Println(strike{b.bofSeq.testTreeIndex[br.Index[0]], br.Index[1], br.Offset, br.Length, false, false})
}
incoming <- strike{b.bofSeq.testTreeIndex[br.Index[0]], br.Index[1], br.Offset, br.Length, false, false}
}
}
select {
case <-quit: // the matcher has called quit
for _ = range bchan {
} // drain first
close(incoming)
return
default:
}
// Setup EOF tests
efchan := b.eofFrames.index(buf, true, quit)
b.start(false)
rrdr := siegreader.LimitReverseReaderFrom(buf, b.maxEOF)
echan := b.eAho.Index(rrdr)
// if we have a maximum value on EOF do a sequential search
if b.maxEOF >= 0 {
for ef := range efchan {
if config.Debug() {
fmt.Println(strike{b.eofFrames.testTreeIndex[ef.idx], 0, ef.off, ef.length, true, true})
}
incoming <- strike{b.eofFrames.testTreeIndex[ef.idx], 0, ef.off, ef.length, true, true}
}
// Scan complete EOF
for er := range echan {
if er.Index[0] == -1 {
incoming <- progressStrike(er.Offset, true)
} else {
if config.Debug() {
fmt.Println(strike{b.eofSeq.testTreeIndex[er.Index[0]], er.Index[1], er.Offset, er.Length, true, false})
}
incoming <- strike{b.eofSeq.testTreeIndex[er.Index[0]], er.Index[1], er.Offset, er.Length, true, false}
}
}
// let the scorer known we have reached the end of the EOF scan
incoming <- progressStrike(-1, true)
// Finally, finish BOF scan
for br := range bchan {
if br.Index[0] == -1 {
incoming <- progressStrike(br.Offset, false)
} else {
if config.Debug() {
fmt.Println(strike{b.bofSeq.testTreeIndex[br.Index[0]], br.Index[1], br.Offset, br.Length, false, false})
}
incoming <- strike{b.bofSeq.testTreeIndex[br.Index[0]], br.Index[1], br.Offset, br.Length, false, false}
}
}
close(incoming)
return
}
// If no maximum on EOF do a parallel search
for {
select {
case br, ok := <-bchan:
if !ok {
bchan = nil
} else {
if br.Index[0] == -1 {
incoming <- progressStrike(br.Offset, false)
} else {
//.........這裏部分代碼省略.........