/** Get an array of all the ids and frequencies in a given IterablePosting stream, * where the length of the stream is unknown */ public static int[][] getAllPostings(final IterablePosting ip, final int numPointers) throws IOException { final int[][] rtr = new int[2][numPointers]; for(int i=0;ip.next() != IterablePosting.EOL;i++) { rtr[0][i] = ip.getId(); rtr[1][i] = ip.getFrequency(); } return rtr; }
@Override public WritablePosting asWritablePosting() { return posting.asWritablePosting(); }
@Override /** Closes all postings that are open */ public void close() throws IOException { for (IterablePosting ip: termPostings) ip.close(); }
/** Returns the minimum docid of the current postings in the array of IterablePostings * @return minimum docid, or -1 if all postings have ended. */ public static int selectMinimumDocId(final IterablePosting postingListArray[]) { int docid = Integer.MAX_VALUE; for (IterablePosting postingList: postingListArray) if (!postingList.endOfPostings() && docid > postingList.getId()) docid = postingList.getId(); if (docid == Integer.MAX_VALUE) docid = -1; return docid; }
/** Get an array of all the ids in a given IterablePosting stream, * where the length of the stream is known */ public static int[] getIds(final IterablePosting ip, final int numPointers) throws IOException { final int[] ids = new int[numPointers]; for(int i=0;ip.next() != IterablePosting.EOL;i++) ids[i] = ip.getId(); return ids; }
@Test public void doTest() throws Exception { ArrayOfFieldIterablePosting fips = getFips(); IterablePosting ip1 = new FieldOnlyIterablePosting(fips, 0); assertEquals(1, ip1.next()); assertEquals(1, ip1.getFrequency()); assertEquals(2, ip1.getDocumentLength()); assertEquals(2, ip1.next()); assertEquals(8, ip1.getFrequency()); assertEquals(3, ip1.getDocumentLength()); assertEquals(IterablePosting.EOL, ip1.next()); assertEquals(IterablePosting.EOL, ip1.getId()); ip1.close(); }
while (!postings.endOfPostings()) { for (; i < chunkSize && !postings.endOfPostings(); i++) {//for each chunk postings.next(); lastDocid = ids[i] = postings.getId(); tfs[i] = postings.getFrequency(); if (fieldsCount > 0) {
String getContentsNoBlocksFreq(IterablePosting ip, Lexicon<String> lex) throws Exception { StringBuilder rtr = new StringBuilder(); int termid; while( (termid = ip.next()) != IterablePosting.END_OF_LIST){ String term = lex.getLexiconEntry(termid).getKey(); rtr.append(term); rtr.append(':'); rtr.append(ip.getFrequency()); rtr.append(' '); } return rtr.toString(); }
LexiconEntry le = lex.getLexiconEntry(args[1]); IterablePosting ip = inv.getPostings(le); while(ip.next() != IterablePosting.EOL) ip.close(); lex.close(); close(inv); IterablePosting ip = inv.getPostings(le); int targetId = Integer.parseInt(args[2]); int foundId = ip.next(targetId); if (foundId == targetId) ip.close(); lex.close(); close(inv); System.out.print(args[argC] + " "); IterablePosting ip = bpi.getPostings(pointer); while(ip.next() != IterablePosting.EOL)
@Override public int next() throws IOException { return posting.next(); }
while(postings.next() != IterablePosting.EOL) final Posting p = postings.asWritablePosting(); p.setId(termcodeHashmap.get(postings.getId())); postingList.add(p);
while(ip.next() != IterablePosting.EOL) postingList.add(ip.asWritablePosting());
@Override public int getFrequency() { return posting.getFrequency(); }
@Override public int getDocumentLength() { return ips[0].getDocumentLength(); }
@Override public boolean endOfPostings() { return posting.endOfPostings(); }
@Test public void testManySomeOverlapSkipOver() throws Exception { IterablePosting[] ips = new IterablePosting[]{ new ArrayOfBasicIterablePosting(new int[]{0,1}, new int[]{1,1}, new int[]{4,5}), new ArrayOfBasicIterablePosting(new int[]{1,2}, new int[]{2,2}, new int[]{5,6}), }; IterablePosting joined = joinPostings(ips); assertEquals(0, joined.next(0)); assertEquals(0, joined.getId()); assertEquals(1, joined.getFrequency()); assertEquals(4, joined.getDocumentLength()); assertEquals(2, joined.next(2)); assertEquals(2, joined.getId()); assertEquals(2, joined.getFrequency()); assertEquals(6, joined.getDocumentLength()); assertEquals(IterablePosting.EOL, joined.next()); }
/** Get an array of all the ids in a given IterablePosting stream, * where the length of the stream is known */ public static int[] getIds(final IterablePosting ip, final int numPointers) throws IOException { final int[] ids = new int[numPointers]; for(int i=0;ip.next() != IterablePosting.EOL;i++) ids[i] = ip.getId(); return ids; }
while (!postings.endOfPostings()) { for (; i < chunkSize && !postings.endOfPostings(); i++) {//for each chunk postings.next(); lastDocid = ids[i] = postings.getId(); tfs[i] = postings.getFrequency(); if (fieldsCount > 0) {