@Override public int next() throws IOException { return posting.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; }
/** {@inheritDoc} */ public int next() throws IOException { if (children[currentChild] != null) { int id = children[currentChild].next(); if (id != IterablePosting.EOL) return id + offsets[currentChild]; } currentChild++; if (currentChild == children.length) return IterablePosting.EOL; return 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; }
@Override public int next() throws IOException { while( (currentId = iterableParent.next()) != EOL) { final int fieldFreq = fieldParent.getFieldFrequencies()[fieldId]; if (fieldFreq > 0) { frequency = fieldFreq; return currentId; } } return EOL; }
@Override public int next() throws IOException { while( (currentId = iterableParent.next()) != EOL) { final int fieldFreq = fieldParent.getFieldFrequencies()[fieldId]; if (fieldFreq > 0) { frequency = fieldFreq; return currentId; } } return EOL; }
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(); }
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(); }
String getContentsNoBlocks(IterablePosting ip, Lexicon<String> lex, boolean expandFreq) throws Exception { StringBuilder rtr = new StringBuilder(); int termid; while( (termid = ip.next()) != IterablePosting.END_OF_LIST){ String term = lex.getLexiconEntry(termid).getKey(); for(int i=0;i< (expandFreq ? ip.getFrequency() : 1); i++) { rtr.append(term); rtr.append(' '); } } return rtr.toString(); }
/** Create a Basic ORIterablePosting from the specified postings */ public ORIterablePosting(IterablePosting[] ips) throws IOException { postingQueue = new PriorityQueue<IterablePosting>(ips.length, new IterablePostingIdComparator()); for(IterablePosting ip : ips) { if (ip.next() != IterablePosting.EOL) postingQueue.add(ip); } }
/** Create a Basic ORIterablePosting from the specified postings */ public ORIterablePosting(IterablePosting[] ips) throws IOException { postingQueue = new PriorityQueue<IterablePosting>(ips.length, new IterablePostingIdComparator()); for(IterablePosting ip : ips) { if (ip.next() != IterablePosting.EOL) postingQueue.add(ip); } }
/** 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; }
/** 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; }
/** Get an array of all the ids in a given IterablePosting stream */ public static int[] getIds(final IterablePosting ip) throws IOException { final TIntArrayList ids = new TIntArrayList(); while(ip.next() != IterablePosting.EOL) ids.add(ip.getId()); return ids.toNativeArray(); }
@Test public void testTwoOverlap() throws Exception { IterablePosting[] ips = new IterablePosting[]{ new ArrayOfBasicIterablePosting(new int[]{0,1}, new int[]{1,1}, new int[]{3}), new ArrayOfBasicIterablePosting(new int[]{1,2}, new int[]{2,1}, new int[]{4}), }; IterablePosting joined = new ANDIterablePosting(ips, new Pointer[]{new SimpleBitIndexPointer(0, (byte) 0, 2),new SimpleBitIndexPointer(0,(byte) 0, 2)}); assertEquals(1, joined.next()); assertEquals(IterablePosting.EOL, joined.next()); joined.close(); }
@Test public void testSingleOverlap() throws Exception { IterablePosting[] ips = new IterablePosting[]{ new ArrayOfBasicIterablePosting(new int[]{1}, new int[]{1}, new int[]{3}), new ArrayOfBasicIterablePosting(new int[]{1}, new int[]{2}, new int[]{4}), }; IterablePosting joined = new ANDIterablePosting(ips, new Pointer[]{new SimpleBitIndexPointer(0, (byte) 0, 1),new SimpleBitIndexPointer(0,(byte) 0, 1)}); assertEquals(1, joined.next()); assertEquals(IterablePosting.EOL, joined.next()); joined.close(); }
public static void comparePostings(List<Posting> inputPostings, IterablePosting outputPostings) throws Exception { for(Posting p : inputPostings) { assertEquals(p.getId(), outputPostings.next()); assertEquals(p.getId(), outputPostings.getId()); assertEquals(p.getFrequency(), outputPostings.getFrequency()); } assertTrue(outputPostings.next() == IterablePosting.EOL); assertTrue(outputPostings.getId() == IterablePosting.EOL); //TR-519 }
@Test public void testManySomeOverlapSkipPast() 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(IterablePosting.EOL, joined.next(3)); }
public static void compareBlockPostings(List<Posting> inputPostings, IterablePosting outputPostings) throws Exception { for(Posting p : inputPostings) { assertEquals(p.getId(), outputPostings.next()); assertEquals(p.getId(), outputPostings.getId()); assertEquals(p.getFrequency(), outputPostings.getFrequency()); assertArrayEquals(((BlockPosting) p).getPositions(), ((BlockPosting) p).getPositions()); } assertTrue(outputPostings.next() == IterablePosting.EOL); assertTrue(outputPostings.getId() == IterablePosting.EOL); //TR-519 }
public static void compareBlockFieldPostings(List<Posting> inputPostings, IterablePosting outputPostings) throws Exception { for(Posting p : inputPostings) { assertEquals(p.getId(), outputPostings.next()); assertEquals(p.getId(), outputPostings.getId()); assertEquals(p.getFrequency(), outputPostings.getFrequency()); assertArrayEquals(((FieldPosting) p).getFieldFrequencies(), ((FieldPosting) p).getFieldFrequencies()); assertArrayEquals(((BlockPosting) p).getPositions(), ((BlockPosting) p).getPositions()); } assertTrue(outputPostings.next() == IterablePosting.EOL); assertTrue(outputPostings.getId() == IterablePosting.EOL); //TR-519 }