Java Code Examples for org.apache.hadoop.hbase.filter.CompareFilter.CompareOp#NOT_EQUAL
The following examples show how to use
org.apache.hadoop.hbase.filter.CompareFilter.CompareOp#NOT_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: ParseNodeRewriter.java From phoenix with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public ParseNode visitLeave(final ComparisonParseNode node, List<ParseNode> nodes) throws SQLException { ParseNode normNode = leaveCompoundNode(node, nodes, new CompoundNodeFactory() { @Override public ParseNode createNode(List<ParseNode> children) { return NODE_FACTORY.comparison(node.getFilterOp(), children.get(0), children.get(1)); } }); CompareOp op = node.getFilterOp(); if (op == CompareOp.EQUAL || op == CompareOp.NOT_EQUAL) { // Rewrite row value constructor in = or != expression, as this is the same as if it was // used in an equality expression for each individual part. ParseNode lhs = normNode.getChildren().get(0); ParseNode rhs = normNode.getChildren().get(1); if (lhs instanceof RowValueConstructorParseNode || rhs instanceof RowValueConstructorParseNode) { List<ParseNode> andNodes = Lists.newArrayListWithExpectedSize(Math.max(lhs.getChildren().size(), rhs.getChildren().size())); rewriteRowValueConstuctorEqualityComparison(lhs,rhs,andNodes); normNode = NODE_FACTORY.and(andNodes); if (op == CompareOp.NOT_EQUAL) { normNode = NODE_FACTORY.not(normNode); } } } return normNode; }
Example 3
Source File: WhereOptimizer.java From phoenix with Apache License 2.0 | 6 votes |
@Override public SortOrder getSortOrder() { //See PHOENIX-4969: Clean up and unify code paths for RVCs with // respect to Optimizations for SortOrder //Handle the different paths for InList vs Normal Comparison //The code paths in InList assume the sortOrder is ASC for // their optimizations //The code paths for Comparisons on RVC rewrite equality, // for the non-equality cases return actual sort order //This work around should work // but a more general approach can be taken. if(rvcElementOp == CompareOp.EQUAL || rvcElementOp == CompareOp.NOT_EQUAL){ return SortOrder.ASC; } return childPart.getColumn().getSortOrder(); }
Example 4
Source File: HbaseServiceImpl.java From searchanalytics-bigdata with MIT License | 6 votes |
@Override public List<String> getSearchClicksRowKeysWithValidQueryString() { LOG.debug("Checking getSearchClicksRowKeys searchclicks table content!"); Scan scan = new Scan(); scan.addFamily(HbaseJsonEventSerializer.COLUMFAMILY_SEARCH_BYTES); SingleColumnValueFilter filter = new SingleColumnValueFilter(HbaseJsonEventSerializer.COLUMFAMILY_SEARCH_BYTES, Bytes.toBytes("querystring"), CompareOp.NOT_EQUAL, Bytes.toBytes("jaiblahblah")); filter.setFilterIfMissing(true); scan.setFilter(filter); List<String> rows = hbaseTemplate.find("searchclicks", scan, new RowMapper<String>() { @Override public String mapRow(Result result, int rowNum) throws Exception { return new String(result.getRow()); } }); for (String row : rows) { LOG.debug("searchclicks table content, Table returned row key: {}", row); } LOG.debug("Checking getSearchClicksRowKeys searchclicks table content done!"); return rows; }
Example 5
Source File: MetaDataEndpointImpl.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param tableName parent table's name * @return true if there exist a table that use this table as their base table. * TODO: should we pass a timestamp here? */ private boolean hasViews(HRegion region, byte[] tenantId, PTable table) throws IOException { byte[] schemaName = table.getSchemaName().getBytes(); byte[] tableName = table.getTableName().getBytes(); Scan scan = new Scan(); // If the table is multi-tenant, we need to check across all tenant_ids, // so we can't constrain the row key. Otherwise, any views would have // the same tenantId. if (!table.isMultiTenant()) { byte[] startRow = ByteUtil.concat(tenantId, QueryConstants.SEPARATOR_BYTE_ARRAY); byte[] stopRow = ByteUtil.nextKey(startRow); scan.setStartRow(startRow); scan.setStopRow(stopRow); } SingleColumnValueFilter filter1 = new SingleColumnValueFilter(TABLE_FAMILY_BYTES, BASE_SCHEMA_NAME_BYTES, EQUAL, schemaName); filter1.setFilterIfMissing(schemaName.length > 0); SingleColumnValueFilter filter2 = new SingleColumnValueFilter(TABLE_FAMILY_BYTES, BASE_TABLE_NAME_BYTES, EQUAL, tableName); filter2.setFilterIfMissing(true); BinaryComparator comparator = new BinaryComparator(ByteUtil.concat(tenantId, QueryConstants.SEPARATOR_BYTE_ARRAY, schemaName, QueryConstants.SEPARATOR_BYTE_ARRAY, tableName)); RowFilter filter3 = new RowFilter(CompareOp.NOT_EQUAL,comparator); Filter filter = new FilterList(filter1,filter2,filter3); scan.setFilter(filter); RegionScanner scanner = region.getScanner(scan); try { List<KeyValue> results = newArrayList(); scanner.next(results); return results.size() > 0; } finally { scanner.close(); } }
Example 6
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 7
Source File: WhereOptimizer.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Iterator<Expression> visitEnter(ComparisonExpression node) { Expression rhs = node.getChildren().get(1); if (!rhs.isStateless() || node.getFilterOp() == CompareOp.NOT_EQUAL) { return Iterators.emptyIterator(); } return Iterators.singletonIterator(node.getChildren().get(0)); }
Example 8
Source File: WhereOptimizer.java From phoenix with Apache License 2.0 | 5 votes |
@Override public Iterator<Expression> visitEnter(ComparisonExpression node) { Expression rhs = node.getChildren().get(1); if (!rhs.isStateless() || node.getFilterOp() == CompareOp.NOT_EQUAL) { return Collections.emptyIterator(); } return Iterators.singletonIterator(node.getChildren().get(0)); }
Example 9
Source File: PrepareClusterJob.java From recsys-offline with Apache License 2.0 | 5 votes |
public void run() { try { Job job = Job.getInstance(HBaseContext.config, "ClusterPrepareJob"); job.setJarByClass(PrepareClusterJob.class); Scan scan = new Scan(); scan.setCaching(500); scan.setCacheBlocks(false); scan.addColumn(Constants.hbase_column_family.getBytes(), Constants.hbase_column_yearrate.getBytes()); scan.addColumn(Constants.hbase_column_family.getBytes(), Constants.hbase_column_repaylimittime.getBytes()); scan.addColumn(Constants.hbase_column_family.getBytes(), Constants.hbase_column_progress.getBytes()); Filter filter = new SingleColumnValueFilter(Bytes.toBytes(Constants.hbase_column_family), Bytes.toBytes(Constants.hbase_column_progress), CompareOp.NOT_EQUAL, Bytes.toBytes("100")); scan.setFilter(filter); TableMapReduceUtil.initTableMapperJob(Constants.hbase_p2p_table, scan, HBaseReadMapper.class, Text.class, Text.class, job); TableMapReduceUtil.initTableReducerJob( Constants.hbase_cluster_model_table, HBaseWriteReducer.class, job); job.setNumReduceTasks(1); boolean b = job.waitForCompletion(true); if (!b) { throw new IOException("error with job!"); } } catch (Exception e) { e.printStackTrace(); } }
Example 10
Source File: WhereOptimizer.java From phoenix with Apache License 2.0 | 5 votes |
@Override public Iterator<Expression> visitEnter(ComparisonExpression node) { Expression rhs = node.getChildren().get(1); if (!rhs.isStateless() || node.getFilterOp() == CompareOp.NOT_EQUAL) { return Iterators.emptyIterator(); } return Iterators.singletonIterator(node.getChildren().get(0)); }
Example 11
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 12
Source File: NotEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.NOT_EQUAL; }
Example 13
Source File: NotEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getFilterOp() { return CompareOp.NOT_EQUAL; }
Example 14
Source File: NotEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.NOT_EQUAL; }
Example 15
Source File: ExpressionCompiler.java From phoenix with BSD 3-Clause "New" or "Revised" License | 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, rhs.isDeterministic()); } // 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 lhsByteSize = lhs.getByteSize(); if (lhsByteSize != null && lhsByteSize < index) { return LiteralExpression.newConstant(false, rhs.isDeterministic()); } if (index == -1) { String rhsLiteral = LikeExpression.unescapeLike(pattern); if (lhsByteSize != null && lhsByteSize != rhsLiteral.length()) { return LiteralExpression.newConstant(false, rhs.isDeterministic()); } CompareOp op = node.isNegate() ? CompareOp.NOT_EQUAL : CompareOp.EQUAL; if (pattern.equals(rhsLiteral)) { return new ComparisonExpression(op, children); } else { rhs = LiteralExpression.newConstant(rhsLiteral, PDataType.CHAR, rhs.isDeterministic()); return new ComparisonExpression(op, Arrays.asList(lhs,rhs)); } } } Expression expression = new LikeExpression(children); if (node.isStateless()) { ImmutableBytesWritable ptr = context.getTempPtr(); if (!expression.evaluate(null, ptr)) { return LiteralExpression.newConstant(null, expression.isDeterministic()); } else { return LiteralExpression.newConstant(Boolean.TRUE.equals(PDataType.BOOLEAN.toObject(ptr)) ^ node.isNegate(), expression.isDeterministic()); } } if (node.isNegate()) { expression = new NotExpression(expression); } return expression; }
Example 16
Source File: NotEqualParseNode.java From phoenix with Apache License 2.0 | 4 votes |
@Override public CompareOp getFilterOp() { return CompareOp.NOT_EQUAL; }
Example 17
Source File: NotEqualParseNode.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public CompareOp getFilterOp() { return CompareOp.NOT_EQUAL; }
Example 18
Source File: NotEqualParseNode.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public CompareOp getInvertFilterOp() { return CompareOp.NOT_EQUAL; }
Example 19
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, 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 (lhsMaxLength != null && lhsMaxLength != rhsLiteral.length()) { return LiteralExpression.newConstant(false, rhs.getDeterminism()); } 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); } } } } Expression expression = LikeExpression.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); }