On in expression.

@param expression
the expression
@param m
the m
@param idColumn
the id column
@param isIdColumn
the is id column
@return
@return the filter
768783
public static Map<String, Object> onInExpression(Expression expression, EntityMetadata m,
            KunderaMetadata kunderaMetadata, KunderaQuery kunderaQuery)
    {
        InExpression inExp = (InExpression) expression;
        Expression sfpExp = inExp.getExpression();
        Map<String, Object> map = KunderaQueryUtils.setFieldClazzAndColumnFamily(sfpExp, m, kunderaMetadata);
        kunderaQuery.addFilterClause(
              (String) map.get(Constants.COL_NAME), inExp.getIdentifier(), inExp.getInItems(),
              (String) map.get(Constants.FIELD_NAME), (Boolean) map.get(Constants.IGNORE_CASE));
        return map;
    }
234815
@SuppressWarnings("unchecked")
    public static <T> Expression<T> any(CollectionExpression<?, ? super T> col) {
        return new OperationImpl<T>((Class<T>) col.getParameter(0), Ops.QuantOps.ANY,
                ImmutableList.<Expression<?>>of(col));
    }
1052436
public Expression<Boolean> in(Boolean[] value) {
		String listBooleanString = "";
		Boolean firstNumber = true;
		for (Boolean v : value) {
			if (firstNumber) {
				listBooleanString = listBooleanString.concat("(").concat(v.toString());
				firstNumber = false;
			} else {
				listBooleanString = listBooleanString.concat(", ").concat(v.toString());
			}
		}
		listBooleanString = listBooleanString.concat(")");
		return new Expression<Boolean>(this, Operation.in, listBooleanString);
	}
40510
Map<Boolean, List<IndexClause>> prepareIndexClause(EntityMetadata m, boolean isQueryForInvertedIndex) {
        IndexClause indexClause =
            new IndexClause(new ArrayList<IndexExpression>(), ByteBufferUtil.EMPTY_BYTE_BUFFER, maxResult);

        List<IndexClause> clauses = new ArrayList<IndexClause>();
        List<IndexExpression> expr = new ArrayList<IndexExpression>();

        Map<Boolean, List<IndexClause>> idxClauses = new HashMap<Boolean, List<IndexClause>>(1);
        // check if id column are mixed with other columns or not?
        String idColumn = ((AbstractAttribute) m.getIdAttribute()).getJPAColumnName();
        boolean idPresent = false;

        if (log.isInfoEnabled()) {
            log.info("Preparing index clause for query {}", getJPAQuery());
        }

        for (Object o : getKunderaQuery().getFilterClauseQueue()) {
            if (o instanceof FilterClause) {
                FilterClause clause = ((FilterClause) o);
                String fieldName = clause.getProperty();
                // in case id column matches with field name, set it for first
                // time.
                if (!idPresent && idColumn.equalsIgnoreCase(fieldName)) {
                    idPresent = true;
                }

                String condition = clause.getCondition();
                List<Object> value = clause.getValue();
                if (value != null && value.size() > 1) {
                    log.error("IN clause is not enabled for thrift, use cql3.");
                    throw new QueryHandlerException("IN clause is not enabled for thrift, use cql3.");
                }
                IndexOperator operator = getOperator(condition, idPresent);

                IndexExpression expression = new IndexExpression(ByteBufferUtil.bytes(fieldName), operator,
                    getBytesValue(fieldName, m, value.get(0)));

                expr.add(expression);
            } else {
                // Case of AND and OR clause.
                String opr = o.toString();
                if (opr.equalsIgnoreCase("or")) {
                    log.error("Support for OR clause is not enabled within cassandra.");
                    throw new QueryHandlerException("Unsupported clause " + opr + " for cassandra.");
                }
            }
        }

        if (!StringUtils.isBlank(getKunderaQuery().getFilter())) {
            indexClause.setExpressions(expr);
            clauses.add(indexClause);
        }
        idxClauses.put(idPresent, clauses);

        return idxClauses;
    }
711714
public static void traverse(Expression expression, EntityMetadata m, KunderaMetadata kunderaMetadata,
            KunderaQuery kunderaQuery, boolean isSubExpression)
    {

        if (ComparisonExpression.class.isAssignableFrom(expression.getClass()))
        {
            onComparisonExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (NullComparisonExpression.class.isAssignableFrom(expression.getClass()))
        {
            onNullComparisonExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (LogicalExpression.class.isAssignableFrom(expression.getClass()))
        {
            onLogicalExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (InExpression.class.isAssignableFrom(expression.getClass()))
        {
            onInExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (LikeExpression.class.isAssignableFrom(expression.getClass()))
        {
            onLikeExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (RegexpExpression.class.isAssignableFrom(expression.getClass()))
        {
            onRegExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (BetweenExpression.class.isAssignableFrom(expression.getClass()))
        {
            onBetweenExpression(expression, m, kunderaMetadata, kunderaQuery);
        }
        else if (SubExpression.class.isAssignableFrom(expression.getClass()))
        {
            onSubExpression(expression, m, kunderaMetadata, kunderaQuery);
        }

    }
903282
public AbstractExpression getSimpleFilterExpression()
    {
        if (m_whereExpr != null) {
            if (m_joinExpr != null) {
                return ExpressionUtil.combine(m_whereExpr, m_joinExpr);
            }
            return m_whereExpr;
        }
        return m_joinExpr;
    }
419234
public static void isTrue(Boolean expression) {
		if(!validation) return;
		notNull(expression);
		if(!expression)
			throw new ParameterException(ErrorCode.CONSTRAINT);
	}
712875
public Query orderby(final Expression... orderbyColumns) {
        if (orderbyColumns == null) {
            return this;
        }

        return orderby(Arrays.asList(orderbyColumns));
    }
736785
public Where<T, ID> notIn(String columnName, QueryBuilder<?, ?> subQueryBuilder) throws SQLException {
		return in(false, columnName, subQueryBuilder);
	}
683292
private OrQueryBuilder getOrFilterBuilder(Expression logicalExp, EntityMetadata m)
    {
        OrExpression orExp = (OrExpression) logicalExp;
        Expression leftExpression = orExp.getLeftExpression();
        Expression rightExpression = orExp.getRightExpression();

        return new OrQueryBuilder(populateFilterBuilder(leftExpression, m), populateFilterBuilder(rightExpression, m));
    }
136954
private QueryBuilder populateBetweenFilter(BetweenExpression betweenExpression, EntityMetadata m)
    {
        String lowerBoundExpression = getBetweenBoundaryValues(betweenExpression.getLowerBoundExpression());
        String upperBoundExpression = getBetweenBoundaryValues(betweenExpression.getUpperBoundExpression());
        String field = getField(betweenExpression.getExpression().toParsedText());

        log.debug("Between clause for field " + field + "with lower bound " + lowerBoundExpression + "and upper bound "
                + upperBoundExpression);

        return new AndQueryBuilder(getFilter(kunderaQuery.new FilterClause(field, Expression.GREATER_THAN_OR_EQUAL,
                lowerBoundExpression, field), m), getFilter(kunderaQuery.new FilterClause(field,
                Expression.LOWER_THAN_OR_EQUAL, upperBoundExpression,field), m));
    }
723973
public static List<Map<String, Object>> readSelectClause(Expression selectExpression, EntityMetadata m,
            Boolean useLuceneOrES, KunderaMetadata kunderaMetadata)
    {
        List<Map<String, Object>> columnsToOutput = new ArrayList<Map<String, Object>>();
        if (StateFieldPathExpression.class.isAssignableFrom(selectExpression.getClass()))
        {
            Expression sfpExp = selectExpression;

            addToOutputColumns(selectExpression, m, columnsToOutput, kunderaMetadata);
        }
        else if (CollectionExpression.class.isAssignableFrom(selectExpression.getClass()))
        {
            CollectionExpression collExp = (CollectionExpression) selectExpression;
            ListIterator<Expression> itr = collExp.children().iterator();
            while (itr.hasNext())
            {
                Expression exp = itr.next();
                if (StateFieldPathExpression.class.isAssignableFrom(exp.getClass()))
                {
                    addToOutputColumns(exp, m, columnsToOutput, kunderaMetadata);
                }
            }
        }
        return columnsToOutput;
    }
645609
@SuppressWarnings("unchecked")
    public final BooleanExpression contains(Expression<K> key, Expression<V> value) {
        return get(key).eq((Expression) value);
    }
1182231
@SuppressWarnings("unchecked")
    protected List<Expression<?>> getIdentifierColumns(List<JoinExpression> joins, boolean alias) {
        if (joins.size() == 1) {
            JoinExpression join = joins.get(0);
            if (join.getTarget() instanceof RelationalPath) {
                return ((RelationalPath) join.getTarget()).getColumns();
            } else {
                return Collections.emptyList();
            }

        } else {
            List<Expression<?>> rv = Lists.newArrayList();
            int counter = 0;
            for (JoinExpression join : joins) {
                if (join.getTarget() instanceof RelationalPath) {
                    RelationalPath path = (RelationalPath) join.getTarget();
                    List<Expression<?>> columns;
                    if (path.getPrimaryKey() != null) {
                        columns = path.getPrimaryKey().getLocalColumns();
                    } else {
                        columns = path.getColumns();
                    }
                    if (alias) {
                        for (Expression<?> column : columns) {
                            rv.add(ExpressionUtils.as(column, "col" + (++counter)));
                        }
                    } else {
                        rv.addAll(columns);
                    }

                } else {
                    // not able to provide a distinct list of columns
                    return Collections.emptyList();
                }
            }
            return rv;
        }

    }
1048273
@Nullable
  public VirtualColumn getOrCreateVirtualColumnForExpression(
      PlannerContext plannerContext,
      DruidExpression expression,
      SqlTypeName typeName
  )
  {
    if (!isAggregateSignature && !virtualColumnsByExpression.containsKey(expression.getExpression())) {
      final String virtualColumnName = virtualColumnPrefix + virtualColumnCounter++;
      final VirtualColumn virtualColumn = expression.toVirtualColumn(
          virtualColumnName,
          Calcites.getValueTypeForSqlTypeName(typeName),
          plannerContext.getExprMacroTable()
      );
      virtualColumnsByExpression.put(
          expression.getExpression(),
          virtualColumn
      );
      virtualColumnsByName.put(
          virtualColumnName,
          virtualColumn
      );
    }

    return virtualColumnsByExpression.get(expression.getExpression());
  }
395402
private List onQuery(EntityMetadata m, Client client)
    {
        boolean useLuceneOrES = !MetadataUtils.useSecondryIndex(((ClientBase) client).getClientMetadata());
        QueryTranslator translator = new QueryTranslator();
        List<Map<String, Object>> columnsToOutput = translator.getColumnsToOutput(m, getKunderaQuery(), useLuceneOrES);
        translator.translate(getKunderaQuery(), m, useLuceneOrES);
        Filter filters = translator.getFilters();
        if (!translator.isWhereOrAggregationQuery() || !useLuceneOrES)
        {
            return ((HBaseClient) client).findData(m, null, translator.getStartRow(), translator.getEndRow(),
                    columnsToOutput, filters);
        }
        else
        {
            return populateUsingLucene(m, client, null, null);
        }
    }
1355808
public static void addExpressionToAnnotationMember(AnnotationNode annotationNode, String memberName, Expression expression) {
        Expression exclude = annotationNode.getMember(memberName);
        if(exclude instanceof ListExpression) {
            ((ListExpression)exclude).addExpression(expression);
        }
        else if(exclude != null) {
            ListExpression list = new ListExpression();
            list.addExpression(exclude);
            list.addExpression(expression);
            annotationNode.setMember(memberName, list);
        }
        else {
            annotationNode.setMember(memberName, expression);
        }
    }