public static BoundDimFilter BOUND( final String fieldName, final String lower, final String upper, final boolean lowerStrict, final boolean upperStrict, final ExtractionFn extractionFn, final StringComparator comparator ) { return new BoundDimFilter(fieldName, lower, upper, lowerStrict, upperStrict, null, extractionFn, comparator); }
public static BoundDimFilter greaterThanOrEqualTo(final BoundRefKey boundRefKey, final String value) { return new BoundDimFilter( boundRefKey.getDimension(), value, null, false, false, null, boundRefKey.getExtractionFn(), boundRefKey.getComparator() ); }
public static BoundDimFilter lessThanOrEqualTo(final BoundRefKey boundRefKey, final String value) { return new BoundDimFilter( boundRefKey.getDimension(), null, value, false, false, null, boundRefKey.getExtractionFn(), boundRefKey.getComparator() ); }
@Test public void testAlphaNumericMatchWithNegatives() { assertFilterMatches( new BoundDimFilter("dim1", "-2000", "3", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of() ); assertFilterMatches( new BoundDimFilter("dim1", "3", "-2000", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "6", "7") ); }
@Test public void testNumericMatchExactlySingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "2", "2", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("2") ); assertFilterMatches( new BoundDimFilter("dim1", "-10.012", "-10.012", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("7") ); }
@Test public void testAlphaNumericMatchNoUpperLimit() { assertFilterMatches( new BoundDimFilter("dim1", "1", null, true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "2", "4", "5", "6", "7") ); assertFilterMatches( new BoundDimFilter("dim1", "-1", null, true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("4", "5", "6", "7") ); }
@Test public void testAlphaNumericMatchNoLowerLimit() { assertFilterMatches( new BoundDimFilter("dim1", null, "2", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "3") ); assertFilterMatches( new BoundDimFilter("dim1", null, "ZZZZZ", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7") ); }
@Test public void testNumericMatchVirtualColumn() { assertFilterMatches( new BoundDimFilter("expr", "1", "2", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7") ); assertFilterMatches( new BoundDimFilter("expr", "2", "3", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of() ); }
@Test public void testNumericMatchSurroundingSingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "1", "3", true, true, false, null, StringComparators.NUMERIC), ImmutableList.of("2") ); assertFilterMatches( new BoundDimFilter("dim1", "-11", "-10", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("7") ); }
@Test public void testLexicographicMatchExactlySingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "abc", "abc", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("5") ); }
@Test public void testLexicographicMatchSurroundingSingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "ab", "abd", true, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("5") ); }
@Test public void testLexicographicMatchNoLowerLimit() { assertFilterMatches( new BoundDimFilter("dim1", null, "abd", true, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "5", "6", "7") ); }
@Test public void testLexicographicMatchNoUpperLimit() { assertFilterMatches( new BoundDimFilter("dim1", "ab", null, true, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("4", "5") ); }
@Test public void testAlphaNumericMatchSurroundingSingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "1", "3", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("2") ); }
@Test public void testNumericMatchNoLowerLimit() { assertFilterMatches( new BoundDimFilter("dim1", null, "2", true, true, false, null, StringComparators.NUMERIC), ImmutableList.of("0", "3", "4", "5", "6", "7") ); }
@Test public void testAlphaNumericMatchExactlySingleValue() { assertFilterMatches( new BoundDimFilter("dim1", "2", "2", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("2") ); }
@Test public void testNumericMatchNoUpperLimit() { assertFilterMatches( new BoundDimFilter("dim1", "1", null, true, true, false, null, StringComparators.NUMERIC), ImmutableList.of("1", "2") ); }
@Test public void testNumericMatchWithNegatives() { assertFilterMatches( new BoundDimFilter("dim1", "-2000", "3", true, true, false, null, StringComparators.NUMERIC), ImmutableList.of("2", "3", "6", "7") ); }
@Test public void testHashCode() { BoundDimFilter boundDimFilter = new BoundDimFilter("dimension", "12", "15", null, null, true, null, StringComparators.ALPHANUMERIC); BoundDimFilter boundDimFilterWithExtract = new BoundDimFilter("dimension", "12", "15", null, null, true, extractionFn, StringComparators.ALPHANUMERIC); Assert.assertNotEquals(boundDimFilter.hashCode(), boundDimFilterWithExtract.hashCode()); }
@Test public void testGetRequiredColumns() { BoundDimFilter boundDimFilter = new BoundDimFilter("dimension", "12", "15", null, null, true, null, StringComparators.ALPHANUMERIC); Assert.assertEquals(boundDimFilter.getRequiredColumns(), Sets.newHashSet("dimension")); } }