@Test public void testSimpleColumnOperator() throws Exception { Filter filter = helper("a0c20s1d5o2", tupleDescription); assertNotNull(filter); assertTrue(filter instanceof SingleColumnValueFilter); SingleColumnValueFilter scvFilter = (SingleColumnValueFilter) filter; assertSame(families[0], scvFilter.getFamily()); assertSame(qualifiers[0], scvFilter.getQualifier()); assertEquals(CompareFilter.CompareOp.GREATER, scvFilter.getOperator()); assertTrue(scvFilter.getComparator() instanceof HBaseIntegerComparator); assertEquals(0, scvFilter.getComparator().compareTo("5".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();  }