.postAggregationFilter(new ElementFilter.Builder() .select(TestPropertyNames.COUNT) .execute(new IsLessThan(10)) .build()) .transformer(new ElementTransformer.Builder() assertEquals(1, postFilterComponents.size()); assertArrayEquals(new String[]{TestPropertyNames.COUNT}, postFilterComponents.get(0).getSelection()); assertEquals(new IsLessThan(10), postFilterComponents.get(0).getPredicate());
private Pair<FilterPredicate, Set<Path>> addPrimitiveFilter(final Predicate filterFunction, final String selection, final String group) throws SerialisationException { // All supported filters will be in the if else statement below if (filterFunction instanceof IsEqual) { return addIsEqualFilter(selection, schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, ((IsEqual) filterFunction).getControlValue()), group, false); } else if (filterFunction instanceof IsLessThan) { if (((IsLessThan) filterFunction).getOrEqualTo()) { return addIsLessThanOrEqualToFilter(selection, schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, ((IsLessThan) filterFunction).getControlValue()), group); } else { return addIsLessThanFilter(selection, schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, ((IsLessThan) filterFunction).getControlValue()), group); } } else if (filterFunction instanceof IsMoreThan) { if (((IsMoreThan) filterFunction).getOrEqualTo()) { return addIsMoreThanOrEqualToFilter(selection, schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, ((IsMoreThan) filterFunction).getControlValue()), group); } else { return addIsMoreThanFilter(selection, schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, ((IsMoreThan) filterFunction).getControlValue()), group); } } else if (filterFunction instanceof IsTrue) { return new Pair<>(eq(booleanColumn(selection), Boolean.TRUE), getAllPathsForColumn(group)); } else if (filterFunction instanceof IsFalse) { return new Pair<>(eq(booleanColumn(selection), Boolean.FALSE), getAllPathsForColumn(group)); } else { LOGGER.warn(filterFunction.getClass().getCanonicalName() + " is not a natively supported filter by the Parquet store, therefore execution will take longer to perform this filter."); return null; } }
public void isLessThanAString() { // --------------------------------------------------------- final IsLessThan function = new IsLessThan("B"); // --------------------------------------------------------- runExample(function, null, 1, "A", "B", "C"); } }
public void isLessThanOrEqualTo5() { // --------------------------------------------------------- final IsLessThan function = new IsLessThan(5, true); // --------------------------------------------------------- runExample(function, null, 1, 1L, 5, 5L, 10, 10L, "1"); }
public void isLessThan5() { // --------------------------------------------------------- final IsLessThan function = new IsLessThan(5); // --------------------------------------------------------- runExample(function, null, 1, 1L, 5, 5L, 10, 10L, "1"); }
public void isLessThanALong5() { // --------------------------------------------------------- final IsLessThan function = new IsLessThan(5L); // --------------------------------------------------------- runExample(function, null, 1, 1L, 5, 5L, 10, 10L, "1"); }
public void isLessThan3AndIsMoreThan0() { // --------------------------------------------------------- final And function = new And<>( new IsLessThan(3), new IsMoreThan(0) ); // --------------------------------------------------------- runExample(function, null, 0, 1, 2, 3, 1L, 2L); }
public void isLessThan2EqualTo5OrIsMoreThan10() { // --------------------------------------------------------- final Or function = new Or<>( new IsLessThan(2), new IsEqual(5), new IsMoreThan(10) ); // --------------------------------------------------------- runExample(function, "When using an Or predicate with a single selected value you can just use the constructor new Or(predicates))'", 1, 2, 3, 5, 15, 1L, 3L, 5L); }
} else if (filter instanceof LessThan) { final LessThan lessThan = (LessThan) filter; final Predicate<?> isLessThan = new IsLessThan((Comparable<?>) lessThan.value(), false); final Set<String> relevantGroups = getGroupsFromFilter(filter); if (null != relevantGroups) { } else if (filter instanceof LessThanOrEqual) { final LessThanOrEqual lessThan = (LessThanOrEqual) filter; final Predicate<?> isLessThan = new IsLessThan((Comparable<?>) lessThan.value(), true); final Set<String> relevantGroups = getGroupsFromFilter(filter); if (null != relevantGroups) {
public CloseableIterable<? extends Element> getEntitiesRelatedTo2WithCountLessThan2OrMoreThan5() { // --------------------------------------------------------- final GetElements operation = new GetElements.Builder() .input(new EntitySeed(2), new EdgeSeed(2, 3, DirectedType.EITHER)) .view(new View.Builder() .entity("entity", new ViewElementDefinition.Builder() .preAggregationFilter( new ElementFilter.Builder() .select("count") .execute(new Or<>(new IsLessThan(2), new IsMoreThan(5))) .build()) .build()) .build()) .build(); // --------------------------------------------------------- return runExample(operation, "When using an Or predicate with a single selected value you can just do 'select(propertyName)' then 'execute(new Or(predicates))'"); }
public void firstItemIsLessThan2AndSecondItemIsMoreThan5() { // --------------------------------------------------------- final And function = new And.Builder() .select(0) .execute(new IsLessThan(2)) .select(1) .execute(new IsMoreThan(5)) .build(); // --------------------------------------------------------- runExample(function, null, new Tuple2<>(1, 10), new Tuple2<>(1, 1), new Tuple2<>(10, 10), new Tuple2<>(10, 1), new Tuple2<>(1L, 10L), new Tuple1<>(1)); } }
public void firstItemIsLessThan2OrSecondItemIsMoreThan10() { // --------------------------------------------------------- final Or function = new Or.Builder() .select(0) .execute(new IsLessThan(2)) .select(1) .execute(new IsMoreThan(10)) .build(); // --------------------------------------------------------- runExample(function, "When using an Or predicate with multiple selected values, you need to use the Or.Builder to build your Or predicate, using .select() then .execute(). " + "When selecting values in the Or.Builder you need to refer to the position in the input array. I.e to use the first value use position 0 - select(0)." + "You can select multiple values to give to a predicate like isXLessThanY, this is achieved by passing 2 positions to the selec method - select(0, 1)", new Tuple2<>(1, 15), new Tuple2<>(1, 1), new Tuple2<>(15, 15), new Tuple2<>(15, 1), new Tuple2<>(1L, 15L), new Tuple1<>(1)); } }
public CloseableIterable<? extends Element> getEdgesRelatedTo2WhenSourceIsLessThan2OrDestinationIsMoreThan3() { // --------------------------------------------------------- final GetElements operation = new GetElements.Builder() .input(new EntitySeed(2)) .view(new View.Builder() .edge("edge", new ViewElementDefinition.Builder() .preAggregationFilter( new ElementFilter.Builder() .select(IdentifierType.SOURCE.name(), IdentifierType.DESTINATION.name()) .execute(new Or.Builder<>() .select(0) .execute(new IsLessThan(2)) .select(1) .execute(new IsMoreThan(3)) .build()) .build()) .build()) .build()) .build(); // --------------------------------------------------------- return runExample(operation, "When using an Or predicate with a multiple selected values, it is more complicated. " + "First, you need to select all the values you want: 'select(a, b, c)'. This will create an array of the selected values, [a, b, c]. " + "You then need to use the Or.Builder to build your Or predicate, using .select() then .execute(). " + "When selecting values in the Or.Builder you need to refer to the position in the [a,b,c] array. So to use property 'a', use position 0 - select(0)."); } }
.execute(new IsMoreThan(MAY_01_2000, true)) .select("endDate") .execute(new IsLessThan(MAY_02_2000, false)) .build() .execute(new IsMoreThan(MAY_01_2000, true)) .select("endDate") .execute(new IsLessThan(MAY_03_2000, false)) .build()
.execute(new IsMoreThan(JAN_01_2000, true)) .select("endDate") .execute(new IsLessThan(JAN_01_2001, false)) .build()) .postAggregationFilter(new ElementFilter.Builder()