Java Code Examples for org.apache.hadoop.hive.ql.io.sarg.SearchArgument#Builder

The following examples show how to use org.apache.hadoop.hive.ql.io.sarg.SearchArgument#Builder . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	SearchArgument.Builder withOr = builder.startOr();
	for (Predicate p : preds) {
		withOr = p.add(withOr);
	}
	return withOr.end();
}
 
Example 2
Source File: HiveORCSearchArgumentBuilderTest.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDateOrAmtFilter() throws Exception {
    // cdate > '2008-02-01' or amt > 1200
    String filterString = "a1c25s10d2008-02-01o2a2c20s4d1200o2l1";

    SearchArgument.Builder filterBuilder = helper(filterString, columnDescriptors);
    assertNotNull(filterBuilder);
    assertEquals("leaf-0 = (LESS_THAN_EQUALS cdate 2008-02-01), leaf-1 = (LESS_THAN_EQUALS amt 1200), expr = (or (not leaf-0) (not leaf-1))", filterBuilder.build().toString());
}
 
Example 3
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	SearchArgument.Builder withOr = builder.startOr();
	for (Predicate p : preds) {
		withOr = p.add(withOr);
	}
	return withOr.end();
}
 
Example 4
Source File: OrcSplitReader.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public SearchArgument.Builder add(SearchArgument.Builder builder) {
	Object[] castedLiterals = new Object[literals.length];
	for (int i = 0; i < literals.length; i++) {
		castedLiterals[i] = castLiteral(literals[i]);
	}
	return builder.in(columnName, literalType, (Object[]) castedLiterals);
}
 
Example 5
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	Object[] castedLiterals = new Object[literals.length];
	for (int i = 0; i < literals.length; i++) {
		castedLiterals[i] = castLiteral(literals[i]);
	}
	return builder.in(columnName, literalType, (Object[]) castedLiterals);
}
 
Example 6
Source File: HiveORCSearchArgumentBuilderTest.java    From pxf with Apache License 2.0 5 votes vote down vote up
private SearchArgument.Builder helper(String filterString, List<ColumnDescriptor> columnDescriptors) throws Exception {
    HiveORCSearchArgumentBuilder treeVisitor =
            new HiveORCSearchArgumentBuilder(columnDescriptors, new Configuration());
    // Parse the filter string into a expression tree Node
    Node root = new FilterParser().parse(filterString);
    TRAVERSER.traverse(root, PRUNER, treeVisitor);
    return treeVisitor.getFilterBuilder();
}
 
Example 7
Source File: HiveORCSearchArgumentBuilderTest.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDateAndAmtFilter() throws Exception {
    // cdate > '2008-02-01' and cdate < '2008-12-01' and amt > 1200
    String filterString = "a1c25s10d2008-02-01o2a1c25s10d2008-12-01o1l0a2c20s4d1200o2l0";

    SearchArgument.Builder filterBuilder = helper(filterString, columnDescriptors);
    assertNotNull(filterBuilder);
    assertEquals("leaf-0 = (LESS_THAN_EQUALS cdate 2008-02-01), leaf-1 = (LESS_THAN cdate 2008-12-01), leaf-2 = (LESS_THAN_EQUALS amt 1200), expr = (and (not leaf-0) leaf-1 (not leaf-2))", filterBuilder.build().toString());
}
 
Example 8
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.lessThan(columnName, literalType, castLiteral(literal));
}
 
Example 9
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.isNull(columnName, literalType);
}
 
Example 10
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.lessThan(columnName, literalType, castLiteral(literal));
}
 
Example 11
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.equals(columnName, literalType, castLiteral(literal));
}
 
Example 12
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return pred.add(builder.startNot()).end();
}
 
Example 13
Source File: HiveORCSearchArgumentBuilder.java    From pxf with Apache License 2.0 4 votes vote down vote up
public SearchArgument.Builder getFilterBuilder() {
    return filterBuilder;
}
 
Example 14
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.equals(columnName, literalType, castLiteral(literal));
}
 
Example 15
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.nullSafeEquals(columnName, literalType, castLiteral(literal));
}
 
Example 16
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.between(columnName, literalType, castLiteral(lowerBound), castLiteral(upperBound));
}
 
Example 17
Source File: OrcSplitReader.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.equals(columnName, literalType, castLiteral(literal));
}
 
Example 18
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.isNull(columnName, literalType);
}
 
Example 19
Source File: OrcRowInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected SearchArgument.Builder add(SearchArgument.Builder builder) {
	return builder.between(columnName, literalType, castLiteral(lowerBound), castLiteral(upperBound));
}
 
Example 20
Source File: OrcRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 votes vote down vote up
protected abstract SearchArgument.Builder add(SearchArgument.Builder builder);