use of uk.gov.gchq.koryphe.impl.predicate.IsFalse in project Gaffer by gchq.
the class WhileHandlerTest method shouldThrowExceptionWhenPredicateCannotAcceptInputType.
@Test
public void shouldThrowExceptionWhenPredicateCannotAcceptInputType() throws OperationException {
// Given
final Predicate predicate = new IsFalse();
final Object input = new EntitySeed();
final Conditional conditional = new Conditional(predicate);
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final While operation = new While.Builder<>().input(input).conditional(conditional).operation(new GetElements()).build();
final WhileHandler handler = new WhileHandler();
// When / Then
try {
handler.doOperation(operation, context, store);
fail("Exception expected");
} catch (final OperationException e) {
assertTrue(e.getMessage().contains("The predicate '" + predicate.getClass().getSimpleName() + "' cannot accept an input of type '" + input.getClass().getSimpleName() + "'"));
}
}
use of uk.gov.gchq.koryphe.impl.predicate.IsFalse in project gaffer-doc by gchq.
the class IsFalseExample method isFalse.
public void isFalse() {
// ---------------------------------------------------------
final IsFalse function = new IsFalse();
// ---------------------------------------------------------
runExample(function, null, true, false, null, "true");
}
use of uk.gov.gchq.koryphe.impl.predicate.IsFalse in project Gaffer by gchq.
the class JavaPredicateToParquetPredicate method getPrimitiveFilter.
public FilterPredicate getPrimitiveFilter(final Predicate filterFunction, final String selection, final String group, final SchemaUtils schemaUtils) throws SerialisationException {
// All supported filters will be in the if else statement below
if (filterFunction instanceof IsEqual) {
final IsEqual isEqual = (IsEqual) filterFunction;
final Object[] parquetObjects = schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, isEqual.getControlValue());
return getIsEqualFilter(selection, parquetObjects, group, schemaUtils);
} else if (filterFunction instanceof IsLessThan) {
final IsLessThan isLessThan = (IsLessThan) filterFunction;
final Object[] parquetObjects = schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, isLessThan.getControlValue());
if (isLessThan.getOrEqualTo()) {
return getIsLessThanOrEqualToFilter(selection, parquetObjects, group, schemaUtils);
}
return getIsLessThanFilter(selection, parquetObjects, group, schemaUtils);
} else if (filterFunction instanceof IsMoreThan) {
final IsMoreThan isMoreThan = (IsMoreThan) filterFunction;
final Object[] parquetObjects = schemaUtils.getConverter(group).gafferObjectToParquetObjects(selection, isMoreThan.getControlValue());
if (isMoreThan.getOrEqualTo()) {
return getIsMoreThanOrEqualToFilter(selection, parquetObjects, group, schemaUtils);
}
return getIsMoreThanFilter(selection, parquetObjects, group, schemaUtils);
} else if (filterFunction instanceof IsTrue) {
return eq(booleanColumn(selection), true);
} else if (filterFunction instanceof IsFalse) {
return eq(booleanColumn(selection), false);
} else {
fullyApplied = false;
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;
}
}
Aggregations