func FromBytes(raw []byte) *PostingList { maxId := readUInt64(raw) raw = raw[8:] n, rawLen := varint.Read(raw) raw = raw[n:] raw = raw[:rawLen] return &PostingList{raw, match.DocId(maxId)} }
func (pl PostingList) readBlock(idx uint, lastDoc match.DocId) (uint, Block) { bytes := pl.Raw[idx:] if bytes[0]&blockTypeDoc == blockTypeDoc { docSize, docOffset := varint.Read(bytes) doc := match.DocId(docOffset) + lastDoc data := Block{idx, false, 1, doc, 0} return docSize, data } nextBlockOffset := readUInt(bytes[1:]) nextDocOffset := readUInt64(bytes[5:]) data := Block{idx, true, nextBlockOffset, lastDoc, match.DocId(uint64(lastDoc) + nextDocOffset)} return 1 + SKIP_PAYLOAD, data }