private List < IndexExpression > filterToIndexExpressions ( Expression expression ) throws IOException { List < IndexExpression > indexExpressions = new ArrayList < IndexExpression > ( ) ; Expression . BinaryExpression be = ( Expression . BinaryExpression ) expression ; ByteBuffer name = ByteBuffer . wrap ( be . getLhs ( ) . toString ( ) . getBytes ( ) ) ; ByteBuffer value = ByteBuffer . wrap ( be . getRhs ( ) . toString ( ) . getBytes ( ) ) ; switch ( expression . getOpType ( ) ) { case OP_EQ : indexExpressions . add ( new IndexExpression ( name , IndexOperator . EQ , value ) ) ; break ; case OP_GE : indexExpressions . add ( new IndexExpression ( name , IndexOperator . GTE , value ) ) ; break ; case OP_GT : indexExpressions . add ( new IndexExpression ( name , IndexOperator . GT , value ) ) ; break ; case OP_LE : indexExpressions . add ( new IndexExpression ( name , IndexOperator . LTE , value ) ) ; break ; case OP_LT : indexExpressions . add ( new IndexExpression ( name , IndexOperator . LT , value ) ) ; break ; case OP_AND : indexExpressions . addAll ( filterToIndexExpressions ( be . getLhs ( ) ) ) ; indexExpressions . addAll ( filterToIndexExpressions ( be . getRhs ( ) ) ) ; break ; default : throw new IOException ( "Unsupported expression type: " + expression . getOpType ( ) . name ( ) ) ; } return indexExpressions ; }
get a list of Cassandra IndexExpression from Pig expression