github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/codec/postingsConsumer.go (about) 1 package codec 2 3 /* 4 Abstract API that consumes postings for an individual term. 5 6 The lifecycle is: 7 - PostingsConsumer is returned for each term by 8 TermsConsumer.startTerm(). 9 - startDoc() is called for each document where the term occurs, 10 specifying id and term frequency for that document. 11 - If positions are enabled for the field, then addPosition() will 12 be called for each occurrence in the document. 13 - finishDoc() is called when the producer is done adding positions 14 to the document. 15 */ 16 type PostingsConsumer interface { 17 // Adds a new doc in this term. freq will be -1 when term 18 // frequencies are omitted for the field. 19 StartDoc(docId, freq int) error 20 // Add a new position & payload, and start/end offset. A nil 21 // payload means no payload; a non-nil payload with zero length 22 // also means no payload. Caller may reuse the BytesRef for the 23 // payload between calls (method must fully consume the payload). 24 // startOffset and endOffset will be -1 when offsets are not indexed. 25 AddPosition(position int, payload []byte, startOffset, endOffset int) error 26 // Called when we are done adding positions & payloads for each doc. 27 FinishDoc() error 28 }