/** * 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++; } }