Java Code Examples for org.apache.hadoop.hbase.filter.CompareFilter.CompareOp#GREATER_OR_EQUAL
The following examples show how to use
org.apache.hadoop.hbase.filter.CompareFilter.CompareOp#GREATER_OR_EQUAL .
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: HBaseFilterBuilder.java From eagle with Apache License 2.0 | 6 votes |
/** * Convert ComparisonOperator to native HBase CompareOp Support: =, =~,CONTAINS,<,<=,>,>=,!=,!=~ * * @param comp * @return */ protected static CompareOp convertToHBaseCompareOp(ComparisonOperator comp) { if (comp == ComparisonOperator.EQUAL || comp == ComparisonOperator.LIKE || comp == ComparisonOperator.CONTAINS || comp == ComparisonOperator.IN || comp == ComparisonOperator.IS) { return CompareOp.EQUAL; } else if (comp == ComparisonOperator.LESS) { return CompareOp.LESS; } else if (comp == ComparisonOperator.LESS_OR_EQUAL) { return CompareOp.LESS_OR_EQUAL; } else if (comp == ComparisonOperator.GREATER) { return CompareOp.GREATER; } else if (comp == ComparisonOperator.GREATER_OR_EQUAL) { return CompareOp.GREATER_OR_EQUAL; } else if (comp == ComparisonOperator.NOT_EQUAL || comp == ComparisonOperator.NOT_LIKE || comp == ComparisonOperator.NOT_CONTAINS || comp == ComparisonOperator.IS_NOT || comp == ComparisonOperator.NOT_IN) { return CompareOp.NOT_EQUAL; } else { LOG.error("{} operation is not supported now\n", comp); throw new IllegalArgumentException("Illegal operation: " + comp + ", avaliable options: " + Arrays.toString(ComparisonOperator.values())); } }
Example 2
Source File: HBaseFilterBuilder.java From Eagle with Apache License 2.0 | 5 votes |
/** * Convert ComparisonOperator to native HBase CompareOp * * Support: * =, =~,CONTAINS,<,<=,>,>=,!=,!=~ * * @param comp * @return */ protected static CompareOp convertToHBaseCompareOp(ComparisonOperator comp) { if(comp == ComparisonOperator.EQUAL || comp == ComparisonOperator.LIKE || comp == ComparisonOperator.CONTAINS || comp == ComparisonOperator.IN || comp == ComparisonOperator.IS ) { return CompareOp.EQUAL; }else if(comp == ComparisonOperator.LESS) { return CompareOp.LESS; } else if(comp == ComparisonOperator.LESS_OR_EQUAL){ return CompareOp.LESS_OR_EQUAL; }else if(comp == ComparisonOperator.GREATER) { return CompareOp.GREATER; } else if(comp == ComparisonOperator.GREATER_OR_EQUAL){ return CompareOp.GREATER_OR_EQUAL; } else if(comp == ComparisonOperator.NOT_EQUAL || comp == ComparisonOperator.NOT_LIKE || comp == ComparisonOperator.NOT_CONTAINS || comp == ComparisonOperator.IS_NOT || comp == ComparisonOperator.NOT_IN) { return CompareOp.NOT_EQUAL; } else { LOG.error("{} operation is not supported now\n", comp); throw new IllegalArgumentException("Illegal operation: "+comp+ ", avaliable options: "+ Arrays.toString(ComparisonOperator.values())); } }
Example 3
Source File: LessThanOrEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.GREATER_OR_EQUAL; }
Example 4
Source File: ExpressionCompiler.java From phoenix with Apache License 2.0 | 4 votes |
@Override public Expression visitLeave(LikeParseNode node, List<Expression> children) throws SQLException { ParseNode lhsNode = node.getChildren().get(0); ParseNode rhsNode = node.getChildren().get(1); Expression lhs = children.get(0); Expression rhs = children.get(1); if ( rhs.getDataType() != null && lhs.getDataType() != null && !lhs.getDataType().isCoercibleTo(rhs.getDataType()) && !rhs.getDataType().isCoercibleTo(lhs.getDataType())) { throw TypeMismatchException.newException(lhs.getDataType(), rhs.getDataType(), node.toString()); } if (lhsNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)lhsNode, rhs); } if (rhsNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)rhsNode, lhs); } if (rhs instanceof LiteralExpression) { String pattern = (String)((LiteralExpression)rhs).getValue(); if (pattern == null || pattern.length() == 0) { return LiteralExpression.newConstant(null, PBoolean.INSTANCE, rhs.getDeterminism()); } // TODO: for pattern of '%' optimize to strlength(lhs) > 0 // We can't use lhs IS NOT NULL b/c if lhs is NULL we need // to return NULL. int index = LikeExpression.indexOfWildcard(pattern); // Can't possibly be as long as the constant, then FALSE Integer lhsMaxLength = lhs.getMaxLength(); if (lhsMaxLength != null && lhsMaxLength < index) { return LiteralExpression.newConstant(false, rhs.getDeterminism()); } if (index == -1) { String rhsLiteral = LikeExpression.unescapeLike(pattern); if (node.getLikeType() == LikeType.CASE_SENSITIVE) { CompareOp op = node.isNegate() ? CompareOp.NOT_EQUAL : CompareOp.EQUAL; if (pattern.equals(rhsLiteral)) { return new ComparisonExpression(children, op); } else { rhs = LiteralExpression.newConstant(rhsLiteral, PChar.INSTANCE, rhs.getDeterminism()); return new ComparisonExpression(Arrays.asList(lhs,rhs), op); } } } else { byte[] wildcardString = new byte[pattern.length()]; byte[] wildcard = {StringUtil.MULTI_CHAR_LIKE}; StringUtil.fill(wildcardString, 0, pattern.length(), wildcard, 0, 1, false); if (pattern.equals(new String (wildcardString))) { List<Expression> compareChildren = Arrays.asList(lhs, NOT_NULL_STRING); return new ComparisonExpression(compareChildren, node.isNegate() ? CompareOp.LESS : CompareOp.GREATER_OR_EQUAL); } } } QueryServices services = context.getConnection().getQueryServices(); boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX); Expression expression; if (useByteBasedRegex) { expression = ByteBasedLikeExpression.create(children, node.getLikeType()); } else { expression = StringBasedLikeExpression.create(children, node.getLikeType()); } if (ExpressionUtil.isConstant(expression)) { ImmutableBytesWritable ptr = context.getTempPtr(); if (!expression.evaluate(null, ptr)) { return LiteralExpression.newConstant(null, expression.getDeterminism()); } else { return LiteralExpression.newConstant(Boolean.TRUE.equals(PBoolean.INSTANCE.toObject(ptr)) ^ node.isNegate(), expression.getDeterminism()); } } if (node.isNegate()) { expression = new NotExpression(expression); } return wrapGroupByExpression(expression); }
Example 5
Source File: LessThanOrEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.GREATER_OR_EQUAL; }
Example 6
Source File: LessThanOrEqualParseNode.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.GREATER_OR_EQUAL; }