void PostingStream::write(const Posting &posting, double score) { assert (score == 0); posting.writeTo(out, baseDocID); baseDocID = posting.getDocID(); end = out.tellp(); df ++; }
void TmpPostingStream::write(const Posting &posting, double score) { // cout << "tmp: " << baseDocID << endl; posting.writeTo(fp, score, baseDocID); baseDocID = posting.getDocID(); end = ftell(fp); df ++; }
string PostingStream::info() { size_t current = this->current; size_t baseDocID = this->baseDocID; this->current = begin; this->baseDocID = 0; string res = "["; while ( hasNext() ) { Posting posting = next(); res += to_string(posting.getDocID()); res += ":"; res += to_string(posting.size() - sizeof(posting.getDocID())); res += ";"; } this->current = current; this->baseDocID = baseDocID; if ( res[res.length() - 1] == ';' ) res.erase(res.length() - 1); res += "]"; return res; }