Search in sources :

Example 16 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testLessThanEquals.

@Test
public void testLessThanEquals() {
    FilterClause clause = getFieldFilter("timestamp", LESS_EQUALS, "3");
    // "NULL" is not <= 3
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "2").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("timestamp", "3").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("timestamp", "4").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 17 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testRegexLikeNull.

@Test
public void testRegexLikeNull() {
    FilterClause clause = getFieldFilter("id", REGEX_LIKE, "nu.*");
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("id", "nu").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 18 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperations method performRelational.

private static boolean performRelational(BulletRecord record, FilterClause clause) {
    Clause.Operation operator = clause.getOperation();
    if (isEmpty(clause.getValues())) {
        return true;
    }
    TypedObject object = extractTypedObject(clause.getField(), record);
    if (operator == Clause.Operation.REGEX_LIKE) {
        return REGEX_LIKE.compare(object, clause.getPatterns().stream());
    }
    return COMPARATORS.get(operator).compare(object, cast(object, clause.getValues()));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Utilities.extractTypedObject(com.yahoo.bullet.common.Utilities.extractTypedObject) FilterClause(com.yahoo.bullet.parsing.FilterClause) LogicalClause(com.yahoo.bullet.parsing.LogicalClause) Clause(com.yahoo.bullet.parsing.Clause)

Aggregations

FilterClause (com.yahoo.bullet.parsing.FilterClause)18 Test (org.testng.annotations.Test)17 RecordBox (com.yahoo.bullet.result.RecordBox)3 Utilities.extractTypedObject (com.yahoo.bullet.common.Utilities.extractTypedObject)1 Clause (com.yahoo.bullet.parsing.Clause)1 LogicalClause (com.yahoo.bullet.parsing.LogicalClause)1 TypedObject (com.yahoo.bullet.typesystem.TypedObject)1