-
Notifications
You must be signed in to change notification settings - Fork 3
/
payload_term.go
58 lines (45 loc) · 1.12 KB
/
payload_term.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package query
import (
"fmt"
)
type PayloadTermQuery struct {
term *TermQuery
payload []byte
}
func PayloadTerm(totalDocumentsInIndex int, t string, postings []int32, payload []byte) *PayloadTermQuery {
term := Term(totalDocumentsInIndex, t, postings)
return &PayloadTermQuery{
term: term,
payload: payload,
}
}
func (t *PayloadTermQuery) GetDocId() int32 {
return t.term.docId
}
func (t *PayloadTermQuery) Cost() int {
return len(t.term.postings) - t.term.cursor
}
func (t *PayloadTermQuery) String() string {
return fmt.Sprintf("p_%s(%d)/%.2f", t.term.term, len(t.term.postings), t.term.idf)
}
func (t *PayloadTermQuery) Score() float32 {
return t.term.Score()
}
func (t *PayloadTermQuery) Advance(target int32) int32 {
return t.term.Advance(target)
}
func (t *PayloadTermQuery) Next() int32 {
return t.term.Next()
}
func (t *PayloadTermQuery) SetBoost(b float32) Query {
t.term.SetBoost(b)
return t
}
func (t *PayloadTermQuery) PayloadDecode(p Payload) {
p.Push()
defer p.Pop()
p.Consume(t.term.docId, t.term.cursor, t.payload)
}
func (t *PayloadTermQuery) AddSubQuery(Query) Query {
panic("unsupported")
}