Skip to content

Commit

Permalink
fix skip error
Browse files Browse the repository at this point in the history
  • Loading branch information
echoface committed Apr 14, 2021
1 parent 30ef0c0 commit 49105ac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
5 changes: 2 additions & 3 deletions be_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ func (bi *BEIndex) initPostingList(k int, queries Assignments) FieldPostingListG
}
fieldID := bi.FieldID(field)

Logger.Infof("field:%s query ids:%v\n", field, ids)

pls := PostingLists{}
for _, id := range ids {
key := NewKey(fieldID, id)
Expand Down Expand Up @@ -216,7 +214,7 @@ func (bi *BEIndex) retrieveK(plgList FieldPostingListGroups, k int) (result []in
if plgList[i].GetCurConjID() != eid.GetConjID() {
break
}
plgList[i].SkipTo(nextID)
plgList[i].Skip(nextID)
}
}
}
Expand Down Expand Up @@ -244,6 +242,7 @@ func (bi *BEIndex) Retrieve(queries Assignments) (result []int32, err error) {
}
res := bi.retrieveK(plgList, tempK)
result = append(result, res...)
Logger.Debugf("k:%d,res:%+v,entries:%s", k, res, plgList.Dump())
}
return result, nil
}
Expand Down
32 changes: 31 additions & 1 deletion be_indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func EntriesToDocs(entries Entries) (res []int32) {
}

func TestBEIndex_Retrieve(t *testing.T) {
LogLevel = infoLevel
LogLevel = InfoLevel

builder := IndexerBuilder{
Documents: make(map[int32]*Document),
Expand Down Expand Up @@ -246,3 +246,33 @@ func TestBEIndex_Retrieve3(t *testing.T) {
index := &BEIndex{}
fmt.Println(index.retrieveK(plgs, 2))
}

func TestBEIndex_Retrieve4(t *testing.T) {
LogLevel = ErrorLevel
builder := NewIndexerBuilder()

doc := NewDocument(12)
conj := NewConjunction()
conj.In("tag", NewInt32Values(1))
conj.NotIn("age", NewInt32Values(40, 50, 60, 70))

doc.AddConjunction(conj)

builder.AddDocument(doc)

indexer := builder.BuildIndex()

fmt.Println(indexer.Retrieve(Assignments{
"age": NewInt32Values(1),
}))

fmt.Println(indexer.Retrieve(Assignments{
"age": NewInt32Values(25),
"tag": NewInt32Values(1),
}))

fmt.Println(indexer.Retrieve(Assignments{
"age": NewIntValues(40),
"tag": NewInt32Values(1),
}))
}
14 changes: 7 additions & 7 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package be_indexer
import "fmt"

const (
debugLevel = iota
infoLevel
errorLevel
DebugLevel = iota
InfoLevel
ErrorLevel
)

var (
LogLevel int = debugLevel // control defaultLogger log level
LogLevel int = DebugLevel // control defaultLogger log level
Logger BEIndexLogger = &DefaultLogger{}
)

Expand All @@ -24,21 +24,21 @@ type (
)

func (l *DefaultLogger) Debugf(format string, v ...interface{}) {
if LogLevel > debugLevel {
if LogLevel > DebugLevel {
return
}
fmt.Printf(format, v...)
}

func (l *DefaultLogger) Infof(format string, v ...interface{}) {
if LogLevel > infoLevel {
if LogLevel > InfoLevel {
return
}
fmt.Printf(format, v...)
}

func (l *DefaultLogger) Errorf(format string, v ...interface{}) {
if LogLevel > errorLevel {
if LogLevel > ErrorLevel {
return
}
fmt.Printf(format, v...)
Expand Down

0 comments on commit 49105ac

Please sign in to comment.