@Override protected IterablePosting createFinalPostingIterator( List<IterablePosting> postings, List<EntryStatistics> pointers) throws IOException { return new ANDIterablePosting( postings.toArray(new IterablePosting[0]), pointers.toArray(new Pointer[0])); }
@Override public int next() throws IOException { ITERATION: do { int targetID = ips[0].next(); if (targetID == EOL) return currentId = EOL; for(int i=1;i<ips.length;i++) { int foundID = ips[i].getId(); if (foundID < targetID) foundID = ips[i].next(targetID); if (foundID > targetID) continue ITERATION; assert foundID == targetID; } if (calculateFrequency()) { currentId = targetID; return targetID; } }while(true); }
@Override public int next(int targetID) throws IOException { ITERATION: do { targetID = ips[0].next(targetID); if (targetID == EOL) return currentId = EOL; for(int i=1;i<ips.length;i++) { int foundID = ips[i].getId(); if (foundID < targetID) foundID = ips[i].next(targetID); if (foundID > targetID) continue ITERATION; assert foundID == targetID; } if (calculateFrequency()) { currentId = targetID; return targetID; } }while(true); }
@Override protected IterablePosting createFinalPostingIterator( List<IterablePosting> postings, List<EntryStatistics> pointers) throws IOException { return new ANDIterablePosting( postings.toArray(new IterablePosting[0]), pointers.toArray(new Pointer[0])); }
@Override public int next() throws IOException { ITERATION: do { int targetID = ips[0].next(); if (targetID == EOL) return currentId = EOL; for(int i=1;i<ips.length;i++) { int foundID = ips[i].getId(); if (foundID < targetID) foundID = ips[i].next(targetID); if (foundID > targetID) continue ITERATION; assert foundID == targetID; } if (calculateFrequency()) { currentId = targetID; return targetID; } }while(true); }
@Test public void testSingleDisjoint() throws Exception { IterablePosting[] ips = new IterablePosting[]{ new ArrayOfBasicIterablePosting(new int[]{0}, 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(IterablePosting.EOL, joined.next()); joined.close(); }
@Override public int next(int targetID) throws IOException { ITERATION: do { targetID = ips[0].next(targetID); if (targetID == EOL) return currentId = EOL; for(int i=1;i<ips.length;i++) { int foundID = ips[i].getId(); if (foundID < targetID) foundID = ips[i].next(targetID); if (foundID > targetID) continue ITERATION; assert foundID == targetID; } if (calculateFrequency()) { currentId = targetID; return targetID; } }while(true); }
@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(); }
@Test public void testTwoOverlapSkip() throws Exception { ArrayOfBasicIterablePosting[] ips = new ArrayOfBasicIterablePosting[]{ 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; joined = new ANDIterablePosting(ips, new Pointer[]{new SimpleBitIndexPointer(0, (byte) 0, 2),new SimpleBitIndexPointer(0,(byte) 0, 2)}); assertEquals(1, joined.next(1)); assertEquals(IterablePosting.EOL, joined.next()); joined.close(); ips[0].reset(); ips[1].reset(); joined = new ANDIterablePosting(ips, new Pointer[]{new SimpleBitIndexPointer(0, (byte) 0, 2),new SimpleBitIndexPointer(0,(byte) 0, 2)}); assertEquals(1, joined.next(0)); assertEquals(IterablePosting.EOL, joined.next()); joined.close(); } }