@Override public boolean visit(FullTextAnd and) { Iterator<FullTextExpression> iterator = and.list.iterator(); int index = 0; Cursor c = flatten(iterator.next(), plan, filter, state, path + " and(" + index + ")"); while (iterator.hasNext()) { index++; FullTextExpression input = iterator.next(); Cursor newC = flatten(input, plan, filter, state, path + " and(" + index + ")"); c = Cursors.newIntersectionCursor(c, newC, filter.getQueryLimits()); } result.set(c); return true; }
@Override public boolean visit(FullTextAnd and) { Iterator<FullTextExpression> iterator = and.list.iterator(); int index = 0; Cursor c = flatten(iterator.next(), plan, filter, state, path + " and(" + index + ")"); while (iterator.hasNext()) { index++; FullTextExpression input = iterator.next(); Cursor newC = flatten(input, plan, filter, state, path + " and(" + index + ")"); c = Cursors.newIntersectionCursor(c, newC, filter.getQueryLimits()); } result.set(c); return true; }
@Override public boolean visit(FullTextAnd and) { Iterator<FullTextExpression> iterator = and.list.iterator(); int index = 0; Cursor c = flatten(iterator.next(), plan, filter, state, path + " and(" + index + ")"); while (iterator.hasNext()) { index++; FullTextExpression input = iterator.next(); Cursor newC = flatten(input, plan, filter, state, path + " and(" + index + ")"); c = Cursors.newIntersectionCursor(c, newC, filter.getQueryLimits()); } result.set(c); return true; }
@Test public void intersectionCursor() { QueryEngineSettings s = new QueryEngineSettings(); Cursor a = new SimpleCursor("1:", "/b", "/c", "/e", "/e", "/c"); Cursor b = new SimpleCursor("2:", "/a", "/c", "/d", "/b", "/c"); Cursor c = Cursors.newIntersectionCursor(a, b, s); assertEquals("1:/b, 1:/c", list(c)); assertFalse(c.hasNext()); }
@Test public void intersectionCursorExceptions() { QueryEngineSettings s = new QueryEngineSettings(); Cursor a = new SimpleCursor("1:", "/x", "/b", "/c", "/e", "/e", "/c"); Cursor b = new SimpleCursor("2:", "/a", "/c", "/d", "/b", "/c"); Cursor c = Cursors.newIntersectionCursor(a, b, s); c.next(); c.next(); try { c.remove(); fail(); } catch (UnsupportedOperationException e) { // expected } try { c.next(); fail(); } catch (IllegalStateException e) { // expected } }