/** * Writes the first document in the posting list. * @param doc the document identifier. * @param frequency the frequency of the term in the document. * @param fieldFrequencies tf in each field for the term in the document. * @throws IOException if an I/O error ocurrs. */ public int writeFirstDoc(final int doc, final int frequency, final int[] fieldFrequencies) throws IOException{ writeFirstDoc(doc, frequency); for(int field_f : fieldFrequencies) { //System.err.println("f" + "=" + field_f); docIds.writeUnary(field_f+1); } return docIds.getSize(); }
/** * Adds an occurrence of a term in a document to the posting in memory. * @param term String representing the term. * @param doc int containing the document identifier. * @param frequency int containing the frequency of the term in the document. * @param fieldFrequencies int[] contains the frequencies of the term in each field * @throws IOException if an I/O error occurs. */ public void add(String term, int doc, int frequency, int[] fieldFrequencies) throws IOException{ FieldPosting post; if((post = (FieldPosting) postings.get(term)) != null) { valueBytes += post.insert(doc, frequency, fieldFrequencies); int tf = post.getTF(); // Update the max size if(maxSize < tf) maxSize = tf; } else{ post = new FieldPosting(); valueBytes += post.writeFirstDoc(doc, frequency, fieldFrequencies); postings.put(term,post); keyBytes += (long)(12 + 2*term.length()); } numPointers++; } }
((FieldPosting)directPostings[writerOffset]).writeFirstDoc(termId, ip.getFrequency(), fieldFs);