Package org.voltdb.expressions

Examples of org.voltdb.expressions.ComparisonExpression


        int num_of_subtrees = 5;
        final List<AbstractExpression> combine_exps = new ArrayList<AbstractExpression>();
        final Map<AbstractExpression, AbstractExpression> combine_exps_left = new HashMap<AbstractExpression, AbstractExpression>();
        final Map<AbstractExpression, AbstractExpression> combine_exps_right = new HashMap<AbstractExpression, AbstractExpression>();
        for (int ctr = 0; ctr < num_of_subtrees; ctr++) {
            AbstractExpression exps[] = { new ComparisonExpression(ExpressionType.COMPARE_EQUAL),
                                          new ParameterValueExpression(),
                                          new TupleValueExpression()
            };
            exps[0].setLeft(exps[1]);
            exps[0].setRight(exps[2]);
View Full Code Here


        tuple_exp.setTableName(catalog_tbl.getName());
        tuple_exp.setColumnIndex(catalog_col.getIndex());
        tuple_exp.setColumnAlias(catalog_col.getName());
        tuple_exp.setColumnName(catalog_col.getName());

        return (new ComparisonExpression(ExpressionType.COMPARE_EQUAL, tuple_exp, exp));
    }
View Full Code Here

        }

        List<AbstractExpression> exprs = new ArrayList<AbstractExpression>();
        for (int i = 0; i < nextKeyIndex; i++) {
            AbstractExpression idxExpr = indexedExprs.get(i);
            AbstractExpression expr = new ComparisonExpression(ExpressionType.COMPARE_EQUAL,
                    idxExpr, (AbstractExpression) m_searchkeyExpressions.get(i).clone());
            exprs.add(expr);
        }
        AbstractExpression nullExpr = indexedExprs.get(nextKeyIndex);
        AbstractExpression expr = new OperatorExpression(ExpressionType.OPERATOR_IS_NULL, nullExpr, null);
View Full Code Here

        }
        AbstractExpression expr;
        for (int i = 0; i < nextKeyIndex; i++) {
            AbstractExpression idxExpr = indexedExprs.get(i);
            expr = new ComparisonExpression(ExpressionType.COMPARE_EQUAL,
                    idxExpr, (AbstractExpression) m_searchkeyExpressions.get(i).clone());
            exprs.add(expr);
        }
        AbstractExpression nullExpr = indexedExprs.get(nextKeyIndex);
        expr = new OperatorExpression(ExpressionType.OPERATOR_IS_NULL, nullExpr, null);
View Full Code Here

            // For now, we take the second approach.
            if (sortDirection == SortDirectionType.DESC &&
                    !ispn.getSearchKeyExpressions().isEmpty() &&
                    exprs.isEmpty() &&
                    ExpressionUtil.uncombine(ispn.getInitialExpression()).isEmpty()) {
                AbstractExpression newPredicate = new ComparisonExpression();
                if (ispn.getLookupType() == IndexLookupType.GT)
                    newPredicate.setExpressionType(ExpressionType.COMPARE_GREATERTHAN);
                if (ispn.getLookupType() == IndexLookupType.GTE)
                    newPredicate.setExpressionType(ExpressionType.COMPARE_GREATERTHANOREQUALTO);
                newPredicate.setRight(ispn.getSearchKeyExpressions().get(0));
                newPredicate.setLeft(aggExpr);
                newPredicate.setValueType(aggExpr.getValueType());
                ispn.clearSearchKeyExpression();
                aggplan.setPrePredicate(newPredicate);
            }

            return plan;
View Full Code Here

        boolean allowIndexedJoinFilters, boolean filterAction)
    {
        List<AbstractExpression> binding = null;
        AbstractExpression indexableExpr = null;
        AbstractExpression otherExpr = null;
        ComparisonExpression normalizedExpr = null;
        AbstractExpression originalFilter = null;
        for (AbstractExpression filter : filtersToCover) {
            // Expression type must be resolvable by an index scan
            if ((filter.getExpressionType() == targetComparator) ||
                (filter.getExpressionType() == altTargetComparator)) {
                normalizedExpr = (ComparisonExpression) filter;
                indexableExpr = filter.getLeft();
                otherExpr = filter.getRight();
                binding = bindingIfValidIndexedFilterOperand(tableScan, indexableExpr, otherExpr,
                                                             coveringExpr, coveringColId);
                if (binding != null) {
                    if ( ! allowIndexedJoinFilters) {
                        if (otherExpr.hasAnySubexpressionOfType(ExpressionType.VALUE_TUPLE)) {
                            // This filter can not be used with the index, possibly due to interactions
                            // wih IN LIST processing that would require a three-way NLIJ.
                            binding = null;
                            continue;
                        }
                    }
                    // Additional restrictions apply to LIKE pattern arguments
                    if (targetComparator == ExpressionType.COMPARE_LIKE) {
                        if (otherExpr instanceof ParameterValueExpression) {
                            ParameterValueExpression pve = (ParameterValueExpression)otherExpr;
                            // Can't use an index for parameterized LIKE filters,
                            // e.g. "T1.column LIKE ?"
                            // UNLESS the parameter was artificially substituted
                            // for a user-specified constant AND that constant was a prefix pattern.
                            // In that case, the parameter has to be added to the bound list
                            // for this index/statement.
                            ConstantValueExpression cve = pve.getOriginalValue();
                            if (cve == null || ! cve.isPrefixPatternString()) {
                                binding = null; // the filter is not usable, so the binding is invalid
                                continue;
                            }
                            // Remember that the binding list returned by
                            // bindingIfValidIndexedFilterOperand above
                            // is often a "shared object" and is intended to be treated as immutable.
                            // To add a parameter to it, first copy the List.
                            List<AbstractExpression> moreBinding =
                                new ArrayList<AbstractExpression>(binding);
                            moreBinding.add(pve);
                            binding = moreBinding;
                        } else if (otherExpr instanceof ConstantValueExpression) {
                            // Can't use an index for non-prefix LIKE filters,
                            // e.g. " T1.column LIKE '%ish' "
                            ConstantValueExpression cve = (ConstantValueExpression)otherExpr;
                            if ( ! cve.isPrefixPatternString()) {
                                // The constant is not an index-friendly prefix pattern.
                                binding = null; // the filter is not usable, so the binding is invalid
                                continue;
                            }
                        } else {
                            // Other cases are not indexable, e.g. " T1.column LIKE T2.column "
                            binding = null; // the filter is not usable, so the binding is invalid
                            continue;
                        }
                    }
                    if (targetComparator == ExpressionType.COMPARE_IN) {
                        if (otherExpr.hasAnySubexpressionOfType(ExpressionType.VALUE_TUPLE)) {
                            // This is a fancy edge case where the expression could only be indexed
                            // if it:
                            // A) does not reference the indexed table and
                            // B) has ee support for a three-way NLIJ where the table referenced in
                            // the list element expression feeds values from its current row to the
                            // Materialized scan which then re-evaluates its expressions to
                            // re-populate the temp table that drives the injected NLIJ with
                            // this index scan.
                            // This is a slightly more twisted variant of the three-way NLIJ that
                            // would be needed to support compound key indexing on a combination
                            // of (fixed) IN LIST elements and join key values from other tables.
                            // Punt for now on indexing this IN LIST filter.
                            binding = null; // the filter is not usable, so the binding is invalid
                            continue;
                        }
                        if (otherExpr instanceof ParameterValueExpression) {
                            // It's OK to use an index for a parameterized IN filter,
                            // e.g. "T1.column IN ?"
                            // EVEN if the parameter was -- someday -- artificially substituted
                            // for an entire user-specified list of constants.
                            // As of now, that is beyond the capabilities of the ad hoc statement
                            // parameterizer, so "T1.column IN (3, 4)" can use the plan for
                            // "T1.column IN (?, ?)" that might have been originally cached for
                            // "T1.column IN (1, 2)" but "T1.column IN (1, 2, 3)" would need its own
                            // "T1.column IN (?, ?, ?)" plan, etc. per list element count.
                        }
                        //TODO: Some day, there may be an optimization here that allows an entire
                        // IN LIST of constants to be serialized as a single value instead of a
                        // VectorValue composed of ConstantValue arguments.
                        // What's TBD is whether that would get its own AbstractExpression class or
                        // just be a special case of ConstantValueExpression.
                        else {
                            assert (otherExpr instanceof VectorValueExpression);
                        }
                    }
                    originalFilter = filter;
                    if (filterAction == EXCLUDE_FROM_POST_FILTERS) {
                        filtersToCover.remove(filter);
                    }
                    break;
                }
            }
            if ((filter.getExpressionType() == ComparisonExpression.reverses.get(targetComparator)) ||
                (filter.getExpressionType() == ComparisonExpression.reverses.get(altTargetComparator))) {
                normalizedExpr = (ComparisonExpression) filter;
                normalizedExpr = normalizedExpr.reverseOperator();
                indexableExpr = filter.getRight();
                otherExpr = filter.getLeft();
                binding = bindingIfValidIndexedFilterOperand(tableScan, indexableExpr, otherExpr,
                                                             coveringExpr, coveringColId);
                if (binding != null) {
View Full Code Here

        for (AbstractExpression comparator : endExprs) {
            AbstractExpression otherExpr = comparator.getRight();
            if (otherExpr == inListRhs) {
                endExprs.remove(comparator);
                AbstractExpression replacement =
                    new ComparisonExpression(ExpressionType.COMPARE_EQUAL,
                                             comparator.getLeft(),
                                             equalityRhs);
                endExprs.add(replacement);
                break;
            }
View Full Code Here

        public AbstractExpression getOriginalFilter() { return m_originalFilter; }
        public AbstractExpression getFilter() { return m_filter; }
        public List<AbstractExpression> getBindings() { return m_bindings; }

        public IndexableExpression extractStartFromPrefixLike() {
            ComparisonExpression gteFilter = m_filter.getGteFilterFromPrefixLike();
            return new IndexableExpression(null, gteFilter, m_bindings);
        }
View Full Code Here

            ComparisonExpression gteFilter = m_filter.getGteFilterFromPrefixLike();
            return new IndexableExpression(null, gteFilter, m_bindings);
        }

        public IndexableExpression extractEndFromPrefixLike() {
            ComparisonExpression ltFilter = m_filter.getLtFilterFromPrefixLike();
            return new IndexableExpression(null, ltFilter, m_bindings);
        }
View Full Code Here

TOP

Related Classes of org.voltdb.expressions.ComparisonExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.