protected boolean producesOneRowOutput () {
        if (m_tableAliasMap.size() != 1) {
            return false;
        }

        // Get the table.  There's only one.
        StmtTableScan scan = m_tableAliasMap.values().iterator().next();
        Table table = getTableFromDB(scan.getTableName());
        // May be sub-query? If can't find the table there's no use to continue.
        if (table == null) {
            return false;
        }

        // Get all the indexes defined on the table
        CatalogMap<Index> indexes = table.getIndexes();
        if (indexes == null || indexes.size() == 0) {
            // no indexes defined on the table
            return false;
        }

        // Collect value equivalence expression for the SQL statement
        HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence();

        // If no value equivalence filter defined in SQL statement, there's no use to continue
        if (valueEquivalence.isEmpty()) {
            return false;
        }

        // Collect all tve expressions from value equivalence set which have equivalence
        // defined to parameterized or constant value expression.
        // Eg: T.A = ? or T.A = 1
        Set <AbstractExpression> parameterizedConstantKeys = new HashSet<>();
        Set<AbstractExpression> valueEquivalenceKeys = valueEquivalence.keySet();   // get all the keys
        for (AbstractExpression key : valueEquivalenceKeys) {
            if (key instanceof TupleValueExpression) {
                Set<AbstractExpression> values = valueEquivalence.get(key);
                for (AbstractExpression value : values) {
                    if ((value instanceof ParameterValueExpression) ||
                        (value instanceof ConstantValueExpression)) {
                        TupleValueExpression tve = (TupleValueExpression) key;
                        parameterizedConstantKeys.add(tve);
                    }
                }
            }
        }

        // Iterate over the unique indexes defined on the table to check if the unique
        // index defined on table appears in tve equivalence expression gathered above.
        for (Index index : indexes) {
            // Perform lookup only on pure column indices which are unique
            if (!index.getUnique() || !index.getExpressionsjson().isEmpty()) {
                continue;
            }

            Set<AbstractExpression> indexExpressions = new HashSet<>();
            CatalogMap<ColumnRef> indexColRefs = index.getColumns();
            for (ColumnRef indexColRef:indexColRefs) {
                Column col = indexColRef.getColumn();
                TupleValueExpression tve = new TupleValueExpression(scan.getTableName(),
                                                                    scan.getTableAlias(),
                                                                    col.getName(),
                                                                    col.getName(),
                                                                    col.getIndex());
                indexExpressions.add(tve);
            }

            if (parameterizedConstantKeys.containsAll(indexExpressions)) {
                return true;
            }
        }
        return false;
    }
protected boolean producesOneRowOutput ( ) { if ( m_tableAliasMap . size ( ) != 1 ) { return false ; } StmtTableScan scan = m_tableAliasMap . values ( ) . iterator ( ) . next ( ) ; Table table = getTableFromDB ( scan . getTableName ( ) ) ; if ( table == null ) { return false ; } CatalogMap < Index > indexes = table . getIndexes ( ) ; if ( indexes == null || indexes . size ( ) == 0 ) { return false ; } HashMap < AbstractExpression , Set < AbstractExpression > > valueEquivalence = analyzeValueEquivalence ( ) ; if ( valueEquivalence . isEmpty ( ) ) { return false ; } Set < AbstractExpression > parameterizedConstantKeys = new HashSet < > ( ) ; Set < AbstractExpression > valueEquivalenceKeys = valueEquivalence . keySet ( ) ; for ( AbstractExpression key : valueEquivalenceKeys ) { if ( key instanceof TupleValueExpression ) { Set < AbstractExpression > values = valueEquivalence . get ( key ) ; for ( AbstractExpression value : values ) { if ( ( value instanceof ParameterValueExpression ) || ( value instanceof ConstantValueExpression ) ) { TupleValueExpression tve = ( TupleValueExpression ) key ; parameterizedConstantKeys . add ( tve ) ; } } } } for ( Index index : indexes ) { if ( ! index . getUnique ( ) || ! index . getExpressionsjson ( ) . isEmpty ( ) ) { continue ; } Set < AbstractExpression > indexExpressions = new HashSet < > ( ) ; CatalogMap < ColumnRef > indexColRefs = index . getColumns ( ) ; for ( ColumnRef indexColRef : indexColRefs ) { Column col = indexColRef . getColumn ( ) ; TupleValueExpression tve = new TupleValueExpression ( scan . getTableName ( ) , scan . getTableAlias ( ) , col . getName ( ) , col . getName ( ) , col . getIndex ( ) ) ; indexExpressions . add ( tve ) ; } if ( parameterizedConstantKeys . containsAll ( indexExpressions ) ) { return true ; } } return false ; }
row else false