@Test public void testFilterWithIncompatiblePredicate() throws Exception { Filter filter = helper("a1c25s4drow1o7a2c23s3d999o1l0a1c25s3dseqo5l0", tupleDescription); assertNotNull(filter); assertTrue(filter instanceof FilterList); FilterList filterList = (FilterList) filter; assertEquals(FilterList.Operator.MUST_PASS_ALL, filterList.getOperator()); assertNotNull(filterList.getFilters()); assertEquals(2, filterList.getFilters().size()); Filter left = filterList.getFilters().get(0); Filter right = filterList.getFilters().get(1); assertTrue(left instanceof SingleColumnValueFilter); assertTrue(right instanceof SingleColumnValueFilter); SingleColumnValueFilter scvFilterLeft = (SingleColumnValueFilter) left; SingleColumnValueFilter scvFilterRight = (SingleColumnValueFilter) right; assertEquals(families[2], scvFilterLeft.getFamily()); assertEquals(qualifiers[2], scvFilterLeft.getQualifier()); assertEquals(CompareFilter.CompareOp.LESS, scvFilterLeft.getOperator()); assertEquals(0, scvFilterLeft.getComparator().compareTo("999".getBytes())); assertEquals(families[1], scvFilterRight.getFamily()); assertEquals(qualifiers[1], scvFilterRight.getQualifier()); assertEquals(CompareFilter.CompareOp.EQUAL, scvFilterRight.getOperator()); assertEquals(0, scvFilterRight.getComparator().compareTo("seq".getBytes())); }
private ByteArrayComparable getComparator(int type, OperandNode data) { ByteArrayComparable result; switch (DataType.get(type)) { case TEXT: result = new BinaryComparator(Bytes.toBytes(data.toString())); break; case SMALLINT: case INTEGER: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case BIGINT: case REAL: switch (data.getDataType()) { case BIGINT: case INTEGER: case SMALLINT: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case REAL: result = new HBaseFloatComparator(Float.parseFloat(data.toString())); break; case NUMERIC: case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: result = null; break; } break; case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: throw new IllegalArgumentException(String.format("unsupported column type for filtering %d", type)); } return result; }
HBaseFilterBuilder implements TreeVisitor { private ByteArrayComparable getComparator(int type, OperandNode data) { ByteArrayComparable result; switch (DataType.get(type)) { case TEXT: result = new BinaryComparator(Bytes.toBytes(data.toString())); break; case SMALLINT: case INTEGER: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case BIGINT: case REAL: switch (data.getDataType()) { case BIGINT: case INTEGER: case SMALLINT: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case REAL: result = new HBaseFloatComparator(Float.parseFloat(data.toString())); break; case NUMERIC: case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: result = null; break; } break; case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: throw new IllegalArgumentException(String.format("unsupported column type for filtering %d", type)); } return result; } }
HBaseFilterBuilder implements TreeVisitor { private ByteArrayComparable getComparator(int type, OperandNode data) { ByteArrayComparable result; switch (DataType.get(type)) { case TEXT: result = new BinaryComparator(Bytes.toBytes(data.toString())); break; case SMALLINT: case INTEGER: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case BIGINT: case REAL: switch (data.getDataType()) { case BIGINT: case INTEGER: case SMALLINT: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case REAL: result = new HBaseFloatComparator(Float.parseFloat(data.toString())); break; case NUMERIC: case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: result = null; break; } break; case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: throw new IllegalArgumentException(String.format("unsupported column type for filtering %d", type)); } return result; } HBaseFilterBuilder(HBaseTupleDescription tupleDescription); }
HBaseFilterBuilder implements TreeVisitor { private ByteArrayComparable getComparator(int type, OperandNode data) { ByteArrayComparable result; switch (DataType.get(type)) { case TEXT: result = new BinaryComparator(Bytes.toBytes(data.toString())); break; case SMALLINT: case INTEGER: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case BIGINT: case REAL: switch (data.getDataType()) { case BIGINT: case INTEGER: case SMALLINT: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case REAL: result = new HBaseFloatComparator(Float.parseFloat(data.toString())); break; case NUMERIC: case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: result = null; break; } break; case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: throw new IllegalArgumentException(String.format("unsupported column type for filtering %d", type)); } return result; } HBaseFilterBuilder(HBaseTupleDescription tupleDescription); @Override Node before(Node node, final int level); @Override Node visit(Node node, final int level); @Override Node after(Node node, final int level); Filter build(); byte[] getStartKey(); byte[] getEndKey(); }
HBaseFilterBuilder implements TreeVisitor { private ByteArrayComparable getComparator(int type, OperandNode data) { ByteArrayComparable result; switch (DataType.get(type)) { case TEXT: result = new BinaryComparator(Bytes.toBytes(data.toString())); break; case SMALLINT: case INTEGER: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case BIGINT: case REAL: switch (data.getDataType()) { case BIGINT: case INTEGER: case SMALLINT: result = new HBaseIntegerComparator(Long.parseLong(data.toString())); break; case REAL: result = new HBaseFloatComparator(Float.parseFloat(data.toString())); break; case NUMERIC: case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: result = null; break; } break; case FLOAT8: result = new HBaseDoubleComparator(Double.parseDouble(data.toString())); break; default: throw new IllegalArgumentException(String.format("unsupported column type for filtering %d", type)); } return result; } HBaseFilterBuilder(HBaseTupleDescription tupleDescription); @Override Node before(Node node, final int level); @Override Node visit(Node node, final int level); @Override Node after(Node node, final int level); Filter build(); byte[] getStartKey(); byte[] getEndKey();  }