/** Add the specified to the term posting to the memory postings. * @param term The String form of the term * @param doc the document id of the doc * @param frequency the frequency of the specified term in the document * @param blocks the blockids at which this term occurs */ public void add(String term, int doc, int frequency, int[] blocks) throws IOException{ BlockPosting post; if((post =(BlockPosting) postings.get(term)) != null) { valueBytes += post.insert(doc, frequency, blocks); int tf = post.getTF(); // Update the max size if(maxSize < tf) maxSize = tf; } else{ post = new BlockPosting(); valueBytes += post.writeFirstDoc(doc, frequency, blocks); postings.put(term,post); keyBytes += (long)(12 + 2*term.length()); } numPointers++; } }
((BlockPosting)directPostings[writerOffset]).insert(termId, ip.getFrequency(), blocks); ((BlockPosting)directPostings[writerOffset]).writeFirstDoc(termId, ip.getFrequency(), blocks);
/** 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 BlockFieldPosting(); } else { for(int i=0;i<count;i++) rtr[i] = new BlockPosting(); } return rtr; }
/** * Inserts a new document in the posting list. Document insertions must be done * in order. * @param doc the document identifier. * @param freq the frequency of the term in the document. * @param blockids the blockids for all the term * @return the updated term frequency. * @throws IOException if and I/O error occurs. */ public int insert(final int doc, final int freq, final int[] blockids) throws IOException{ final int c = insert(doc, freq); final int blockCount = blockids.length; docIds.writeUnary(blockCount+1); if (blockCount > 0) { docIds.writeGamma(blockids[0]+1); for (int i=1; i<blockCount; i++) { docIds.writeGamma(blockids[i] - blockids[i-1]); } } return c; }
/** * Writes out the first document to the MemorySBOS. */ public int writeFirstDoc(final int doc, final int frequency, int[] fieldFreqs, int[] blockids) throws IOException{ super.writeFirstDoc(doc, frequency); for(int tff : fieldFreqs) docIds.writeUnary(tff+1); final int blockCount = blockids.length; docIds.writeUnary(blockCount+1); if (blockCount > 0) { docIds.writeGamma(blockids[0]+1); for (int i=1; i<blockCount; i++) { docIds.writeGamma(blockids[i] - blockids[i-1]); } } return docIds.getSize(); } /**