HCatFieldSchema fs = null; try { fs = hcatTableSchema.get(be.getLhs().toString()); } catch (HCatException e) { return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatConstString((Const)be.getRhs(), fs.getType()) + ")"; return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatComparisonString(be.getRhs()) + ")";
ByteBuffer name = ByteBuffer.wrap(be.getLhs().toString().getBytes()); ByteBuffer value = ByteBuffer.wrap(be.getRhs().toString().getBytes()); switch (expression.getOpType()) break; case OP_AND: indexExpressions.addAll(filterToIndexExpressions(be.getLhs())); indexExpressions.addAll(filterToIndexExpressions(be.getRhs())); break;
/** * Return cql where clauses for the corresponding partition filter. Make sure the data format matches * Only support the following Pig data types: int, long, float, double, boolean and chararray * */ private String partitionFilterToWhereClauseString(Expression expression) throws IOException { Expression.BinaryExpression be = (Expression.BinaryExpression) expression; OpType op = expression.getOpType(); String opString = op.toString(); switch (op) { case OP_EQ: opString = " = "; case OP_GE: case OP_GT: case OP_LE: case OP_LT: String name = be.getLhs().toString(); String value = be.getRhs().toString(); return String.format("%s %s %s", name, opString, value); case OP_AND: return String.format("%s AND %s", partitionFilterToWhereClauseString(be.getLhs()), partitionFilterToWhereClauseString(be.getRhs())); default: throw new IOException("Unsupported expression type: " + opString); } }
private void buildSearchArgument(Expression expr, Builder builder) { if (expr instanceof BinaryExpression) { Expression lhs = ((BinaryExpression) expr).getLhs(); Expression rhs = ((BinaryExpression) expr).getRhs(); switch (expr.getOpType()) {
HCatFieldSchema fs = null; try { fs = hcatTableSchema.get(be.getLhs().toString()); } catch (HCatException e) { return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatConstString((Const)be.getRhs(), fs.getType()) + ")"; return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatComparisonString(be.getRhs()) + ")";
Expression lhs = ((BinaryExpression) e).getLhs(); Expression rhs = ((BinaryExpression) e).getRhs();
private String getHCatComparisonString(Expression expr) { if (expr instanceof BinaryExpression) { // call getHCatComparisonString on lhs and rhs, and and join the // results with OpType string // we can just use OpType.toString() on all Expression types except // Equal, NotEqualt since Equal has '==' in toString() and // we need '=' String opStr = null; switch (expr.getOpType()) { case OP_EQ: opStr = " = "; break; default: opStr = expr.getOpType().toString(); } BinaryExpression be = (BinaryExpression) expr; return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatComparisonString(be.getRhs()) + ")"; } else { // should be a constant or column return expr.toString(); } }
private String getHCatComparisonString(Expression expr) { if (expr instanceof BinaryExpression) { // call getHCatComparisonString on lhs and rhs, and and join the // results with OpType string // we can just use OpType.toString() on all Expression types except // Equal, NotEqualt since Equal has '==' in toString() and // we need '=' String opStr = null; switch (expr.getOpType()) { case OP_EQ: opStr = " = "; break; default: opStr = expr.getOpType().toString(); } BinaryExpression be = (BinaryExpression) expr; return "(" + getHCatComparisonString(be.getLhs()) + opStr + getHCatComparisonString(be.getRhs()) + ")"; } else { // should be a constant or column return expr.toString(); } }
protected void updateMappedColNames(Expression expr) { if(expr instanceof BinaryExpression) { updateMappedColNames(((BinaryExpression) expr).getLhs()); updateMappedColNames(((BinaryExpression) expr).getRhs()); } else if (expr instanceof Column) { Column col = (Column) expr; col.setName(reverseColNameMap.get(col.getName())); } }
protected void updateMappedColNames(Expression expr) { if(expr instanceof BinaryExpression) { updateMappedColNames(((BinaryExpression) expr).getLhs()); updateMappedColNames(((BinaryExpression) expr).getRhs()); } else if (expr instanceof Column) { Column col = (Column) expr; col.setName(reverseColNameMap.get(col.getName())); } }