@Override public boolean matches() { return !baseMatcher.matches(); }
@Override public boolean matches() { for (ValueMatcher matcher : baseMatchers) { if (!matcher.matches()) { return false; } } return true; }
@Override public boolean matches() { for (ValueMatcher matcher : baseMatchers) { if (matcher.matches()) { return true; } } return false; }
@Override public void aggregate() { if (matcher.matches()) { delegate.aggregate(); } }
@Override public void aggregate(ByteBuffer buf, int position) { if (matcher.matches()) { delegate.aggregate(buf, position); } }
@Override public void increment() { while (!Thread.currentThread().isInterrupted()) { baseOffset.increment(); if (!baseOffset.withinBounds() || filterMatcher.matches()) { return; } } }
/** * Transforms an input row, or returns null if the row should be filtered out. * * @param row the input row */ @Nullable public InputRow transform(@Nullable final InputRow row) { if (row == null) { return null; } final InputRow transformedRow; if (transforms.isEmpty()) { transformedRow = row; } else { transformedRow = new TransformedInputRow(row, transforms); } if (valueMatcher != null) { rowSupplierForValueMatcher.set(transformedRow); if (!valueMatcher.matches()) { return null; } } return transformedRow; }
@Override public void advanceUninterruptibly() { if (!baseIter.hasNext()) { done = true; return; } while (baseIter.hasNext()) { if (Thread.currentThread().isInterrupted()) { return; } IncrementalIndexRow entry = baseIter.next(); if (beyondMaxRowIndex(entry.getRowIndex())) { continue; } currEntry.set(entry); if (filterMatcher.matches()) { return; } } done = true; }
@Override public void advance() { if (!baseIter.hasNext()) { done = true; return; } while (baseIter.hasNext()) { BaseQuery.checkInterrupted(); IncrementalIndexRow entry = baseIter.next(); if (beyondMaxRowIndex(entry.getRowIndex())) { continue; } currEntry.set(entry); if (filterMatcher.matches()) { return; } } done = true; }
private void incrementIfNeededOnCreationOrReset() { if (baseOffset.withinBounds()) { if (!filterMatcher.matches()) { increment(); // increment() returns early if it detects the current Thread is interrupted. It will leave this // FilteredOffset in an illegal state, because it may point to an offset that should be filtered. So must to // call BaseQuery.checkInterrupted() and thereby throw a QueryInterruptedException. BaseQuery.checkInterrupted(); } } }
@Override public void reset() { baseIter = cursorIterable.iterator(); if (numAdvanced == -1) { numAdvanced = 0; } else { Iterators.advance(baseIter, numAdvanced); } BaseQuery.checkInterrupted(); boolean foundMatched = false; while (baseIter.hasNext()) { IncrementalIndexRow entry = baseIter.next(); if (beyondMaxRowIndex(entry.getRowIndex())) { numAdvanced++; continue; } currEntry.set(entry); if (filterMatcher.matches()) { foundMatched = true; break; } numAdvanced++; } done = !foundMatched && (emptyRange || !baseIter.hasNext()); }
Assert.assertEquals(true, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(false, nonNullMatcher.matches()); Assert.assertEquals(null, selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("4.0", selector.lookupName(selector.getRow().get(0))); } else { Assert.assertEquals(true, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(false, nonNullMatcher.matches()); Assert.assertEquals(null, selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("5.1", selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(true, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("5", selector.lookupName(selector.getRow().get(0)));
Assert.assertEquals(true, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(false, nonNullMatcher.matches()); Assert.assertEquals(null, selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("4", selector.lookupName(selector.getRow().get(0))); } else { Assert.assertEquals(true, nullMatcher.matches()); Assert.assertEquals(false, fiveMatcher.matches()); Assert.assertEquals(false, nonNullMatcher.matches()); Assert.assertEquals(null, selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(true, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("5", selector.lookupName(selector.getRow().get(0))); Assert.assertEquals(false, nullMatcher.matches()); Assert.assertEquals(true, fiveMatcher.matches()); Assert.assertEquals(true, nonNullMatcher.matches()); Assert.assertEquals("5", selector.lookupName(selector.getRow().get(0)));
private List<String> selectColumnValuesMatchingFilterUsingRowBasedColumnSelectorFactory( final DimFilter filter, final String selectColumn ) { // Generate rowType final Map<String, ValueType> rowSignature = new HashMap<>(); for (String columnName : Iterables.concat(adapter.getAvailableDimensions(), adapter.getAvailableMetrics())) { rowSignature.put(columnName, adapter.getColumnCapabilities(columnName).getType()); } // Perform test final SettableSupplier<InputRow> rowSupplier = new SettableSupplier<>(); final ValueMatcher matcher = makeFilter(filter).makeMatcher( VIRTUAL_COLUMNS.wrap(RowBasedColumnSelectorFactory.create(rowSupplier, rowSignature)) ); final List<String> values = new ArrayList<>(); for (InputRow row : rows) { rowSupplier.set(row); if (matcher.matches()) { values.add((String) row.getRaw(selectColumn)); } } return values; }
return filterMatcher.matches();
@Override public boolean matches() { for (ValueMatcher matcher : baseMatchers) { if (!matcher.matches()) { return false; } } return true; }
@Override public void aggregate(ByteBuffer buf, int position) { if (matcher.matches()) { delegate.aggregate(buf, position); } }
@Override public void aggregate() { if (matcher.matches()) { delegate.aggregate(); } }
@Override public void increment() { while (!Thread.currentThread().isInterrupted()) { baseOffset.increment(); if (!baseOffset.withinBounds() || filterMatcher.matches()) { return; } } }
private void incrementIfNeededOnCreationOrReset() { if (baseOffset.withinBounds()) { if (!filterMatcher.matches()) { increment(); // increment() returns early if it detects the current Thread is interrupted. It will leave this // FilteredOffset in an illegal state, because it may point to an offset that should be filtered. So must to // call BaseQuery.checkInterrupted() and thereby throw a QueryInterruptedException. BaseQuery.checkInterrupted(); } } }