/** get an array of posting object of the specified size. These will be used to hold * the postings for a range of documents */ protected Posting[] getPostings(final int count) { Posting[] rtr = new Posting[count]; if (saveTagInformation) { for(int i=0;i<count;i++) rtr[i] = new FieldPosting(); } else { for(int i=0;i<count;i++) rtr[i] = new Posting(); } return rtr; }
/** * 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++; } }