Example usage for java.util LinkedHashMap size

List of usage examples for java.util LinkedHashMap size

Introduction

In this page you can find the example usage for java.util LinkedHashMap size.

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:jmri.enginedriver.throttle.java

void set_function_labels_and_listeners_for_view(int whichThrottle) {
    // Log.d("Engine_Driver","starting set_function_labels_and_listeners_for_view");

    //        // implemented in derived class, but called from this class

    if (fbs != null) { // if it is null it probably because the Throttle Screen Type does not have Functions Buttons
        if (fbs[0] != null) {
            ViewGroup tv; // group
            ViewGroup r; // row
            function_button_touch_listener fbtl;
            Button b; // button
            int k = 0; // button count
            LinkedHashMap<Integer, String> function_labels_temp;
            LinkedHashMap<Integer, Button> functionButtonMap = new LinkedHashMap<>();

            tv = fbs[whichThrottle];//from   w  w  w . j  a v  a  2 s.  c  o m

            // note: we make a copy of function_labels_x because TA might change it
            // while we are using it (causing issues during button update below)
            function_labels_temp = mainapp.function_labels_default;
            if (!prefAlwaysUseDefaultFunctionLabels) { //avoid npe
                if (mainapp.function_labels != null && mainapp.function_labels[whichThrottle] != null
                        && mainapp.function_labels[whichThrottle].size() > 0) {
                    function_labels_temp = new LinkedHashMap<>(mainapp.function_labels[whichThrottle]);
                } else {
                    if (mainapp.consists != null) { //avoid npe maybe
                        if (mainapp.consists[whichThrottle] != null
                                && !mainapp.consists[whichThrottle].isLeadFromRoster()) {
                            function_labels_temp = mainapp.function_labels_default;
                        } else {
                            function_labels_temp = mainapp.function_labels_default_for_roster;
                        }
                    }
                }
            }

            // put values in array for indexing in next step
            // to do this
            ArrayList<Integer> aList = new ArrayList<>(function_labels_temp.keySet());

            if (tv != null) {
                for (int i = 0; i < tv.getChildCount(); i++) {
                    r = (ViewGroup) tv.getChildAt(i);
                    for (int j = 0; j < r.getChildCount(); j++) {
                        b = (Button) r.getChildAt(j);
                        if (k < function_labels_temp.size()) {
                            Integer func = aList.get(k);
                            functionButtonMap.put(func, b); // save function to button
                            // mapping
                            String bt = function_labels_temp.get(func);
                            fbtl = new function_button_touch_listener(func, whichThrottle, bt);
                            b.setOnTouchListener(fbtl);
                            //                                if ((mainapp.getCurrentTheme().equals(THEME_DEFAULT))) {
                            //                                    bt = bt + "        ";  // pad with spaces, and limit to 7 characters
                            //                                    b.setText(bt.substring(0, 7));
                            //                                } else {
                            bt = bt + "                      "; // pad with spaces, and limit to 20 characters
                            b.setText(bt.trim());
                            //                                }
                            b.setVisibility(View.VISIBLE);
                            b.setEnabled(false); // start out with everything disabled
                        } else {
                            b.setVisibility(View.GONE);
                        }
                        k++;
                    }
                }
            }

            // update the function-to-button map for the current throttle
            functionMaps[whichThrottle] = functionButtonMap;
        }
    }
}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * Dokumentation anzeigen//w  ww .ja  v a 2 s . co  m
 * 
 * @throws Exception
 */

private void showDocumentation() throws Exception {
    this.debug(3, "showDocumentation");

    StringBuffer sqlStmt = new StringBuffer(
            "select \"TITLE\",\"APPLICATION\",\"SECTION\",\"NAME\",\"VALUE\",\"DISPLAY_TYPE\",\"INPUT_TYPE\" from "
                    + this.settings.source);

    String sqlAnd = " where ";

    String[] display_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_display_type_entries")
            .split(";");
    String[] input_type_entries = this.rb.getMessage("sos.settings.dialog.listbox_input_type_entries")
            .split(";");

    if (this.settings.section.equals(this.settings.entrySchemaSection)) {
        this.settings.section = this.settings.entrySchemaSection;
    }

    if (!this.settings.application.equals("")) {
        sqlStmt.append(sqlAnd + " \"" + this.settings.entryApplication + "\" = "
                + this.dbQuoted(this.settings.application));
        sqlAnd = " and ";
    }
    if (!this.settings.section.equals("")) {
        sqlStmt.append(
                sqlAnd + " \"" + this.settings.entrySection + "\" = " + this.dbQuoted(this.settings.section));
        sqlAnd = " and ";
    }

    sqlStmt.append(" order by \"" + this.settings.entryApplication + "\",\"" + this.settings.entrySection
            + "\",\"" + this.settings.entryName + "\"");

    try {
        Vector results = this.connection.getArrayAsVector(sqlStmt.toString());

        LinkedHashMap applications = new LinkedHashMap();
        LinkedHashMap sections = new LinkedHashMap();
        LinkedHashMap entries = new LinkedHashMap();

        for (Enumeration el = results.elements(); el.hasMoreElements();) {
            HashMap result = (HashMap) el.nextElement();
            if (result.get("application").toString().equals(result.get("section").toString())
                    && result.get("application").toString().equals(result.get("name").toString())) {

                applications.put(result.get("application").toString(), result);

            } else if (result.get("section").toString().equals(result.get("name").toString())
                    && !result.get("section").toString().equals(result.get("application").toString())) {

                String key = result.get("application").toString();
                LinkedHashMap section = new LinkedHashMap();

                if (sections.containsKey(key)) {
                    section = (LinkedHashMap) sections.get(key);
                }
                section.put(result.get("section").toString(), result);
                sections.put(key, section);

            } else {
                String appKey = result.get("application").toString();
                String secKey = result.get("section").toString();

                LinkedHashMap section = new LinkedHashMap();
                LinkedHashMap entry = new LinkedHashMap();

                if (entries.containsKey(appKey)) {
                    section = (LinkedHashMap) entries.get(appKey);
                    if (section.containsKey(secKey)) {
                        entry = (LinkedHashMap) section.get(secKey);
                    }
                }
                entry.put(result.get("name").toString(), result);
                section.put(secKey, entry);
                entries.put(appKey, section);

            }

        }
        //out.print(entries);

        results = null;
        this.styleBorder = "1\" bgcolor=\"#ffffff\" bordercolorlight=\"#D2D2D2\" bordercolordark=\"#ffffff";

        this.showTableBegin();
        if (applications.size() != 0) {
            Iterator appIt = applications.entrySet().iterator();
            while (appIt.hasNext()) {
                Map.Entry application = (Map.Entry) appIt.next();
                String app_key = application.getKey().toString();
                HashMap app_value = (HashMap) application.getValue();
                this.out.println("<tr>");
                this.out.println("   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                        + app_value.get("title") + "</td>");
                this.out.println("   <td nowrap>" + app_value.get("name") + "</td>");
                this.out.println("   <td nowrap>&nbsp;</td>");
                this.out.println("</tr>");
                if (sections.containsKey(app_key)) {
                    HashMap appSections = (HashMap) sections.get(app_key);
                    Iterator secIt = appSections.entrySet().iterator();
                    while (secIt.hasNext()) {
                        Map.Entry section = (Map.Entry) secIt.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        if (!sec_value.get("name").toString().equals(this.settings.entrySchemaSection)) {
                            this.out.println("<tr>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println(
                                    "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                            + sec_value.get("title") + "</td>");
                            this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                            this.out.println("   <td nowrap>&nbsp;</td>");
                            this.out.println("</tr>");
                            if (entries.containsKey(app_key)) {
                                HashMap secEntrie = (HashMap) entries.get(app_key);
                                if (secEntrie.containsKey(sec_key)) {
                                    HashMap secEntries = (HashMap) secEntrie.get(sec_key);

                                    Iterator entIt = secEntries.entrySet().iterator();
                                    while (entIt.hasNext()) {
                                        Map.Entry entry = (Map.Entry) entIt.next();
                                        String ent_key = entry.getKey().toString();
                                        HashMap ent_value = (HashMap) entry.getValue();

                                        this.out.println("<tr>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"20\" nowrap>&nbsp;</td>");
                                        this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                                + ent_value.get("title") + "</td>");
                                        this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                                + ent_value.get("name") + "</td>");
                                        this.out.println("   <td nowrap valign=\"top\">");
                                        if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                            this.out.println("[ "
                                                    + this.rb.getMessage(
                                                            "sos.settings.dialog.dialog_long_value_title")
                                                    + " ]");
                                            if (ent_value.get("display_type").toString().equals("4")) {
                                                this.out.println("&nbsp;" + display_type_entries[4]);
                                            }
                                        } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                            this.out.println("[ " + input_type_entries[6] + " ]");
                                        } else {
                                            if (ent_value.get("display_type").toString().endsWith("3")) {
                                                this.out.println("<pre>" + this.htmlSpecialChars(
                                                        ent_value.get("value").toString()) + "</pre>");
                                            } else {
                                                this.out.println(
                                                        this.htmlSpecialChars(ent_value.get("value").toString())
                                                                + "&nbsp;");
                                            }
                                        }
                                        this.out.println("   </td>");
                                        this.out.println("</tr>");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // if applications
        else if (sections.size() != 0) {
            try {
                HashMap application = this.connection.getSingle("select \"TITLE\",\"NAME\" from "
                        + this.settings.source + " where \"" + this.settings.entryApplication + "\" = "
                        + this.dbQuoted(this.settings.application) + " and \"" + this.settings.entrySection
                        + "\" = " + this.dbQuoted(this.settings.application) + " and \""
                        + this.settings.entryName + "\" = " + this.dbQuoted(this.settings.application));

                Iterator secIt = sections.entrySet().iterator();
                if (sections.containsKey(this.settings.application)) {
                    HashMap appSections = (HashMap) sections.get(this.settings.application);
                    Iterator secI = appSections.entrySet().iterator();
                    while (secI.hasNext()) {
                        Map.Entry section = (Map.Entry) secI.next();
                        String sec_key = section.getKey().toString();
                        HashMap sec_value = (HashMap) section.getValue();
                        this.out.println("<tr>");
                        this.out.println(
                                "   <td colspan=\"3\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + application.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + application.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        this.out.println("<tr>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println(
                                "   <td colspan=\"2\" nowrap style=\"color:#808080;font-weight:bold;\">"
                                        + sec_value.get("title") + "</td>");
                        this.out.println("   <td nowrap>" + sec_value.get("name") + "</td>");
                        this.out.println("   <td nowrap>&nbsp;</td>");
                        this.out.println("</tr>");
                        if (entries.containsKey(this.settings.application)) {
                            HashMap secEntrie = (HashMap) entries.get(this.settings.application);
                            if (secEntrie.containsKey(sec_key)) {
                                HashMap secEntries = (HashMap) secEntrie.get(sec_key);
                                Iterator entI = secEntries.entrySet().iterator();
                                while (entI.hasNext()) {
                                    Map.Entry entry = (Map.Entry) entI.next();
                                    String ent_key = entry.getKey().toString();
                                    HashMap ent_value = (HashMap) entry.getValue();

                                    this.out.println("<tr>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"3%\" nowrap>&nbsp;</td>");
                                    this.out.println("   <td width=\"35%\" nowrap valign=\"top\">"
                                            + ent_value.get("title") + "</td>");
                                    this.out.println("   <td width=\"10%\" nowrap valign=\"top\">"
                                            + ent_value.get("name") + "</td>");
                                    this.out.println("   <td nowrap valign=\"top\">");
                                    if (ent_value.get("input_type").toString().equals("5")) { // long_value
                                        this.out.println("[ " + this.rb.getMessage(
                                                "sos.settings.dialog.dialog_long_value_title") + " ]");
                                        if (ent_value.get("display_type").toString().equals("4")) {
                                            this.out.println("&nbsp;" + display_type_entries[4]);
                                        }
                                    } else if (ent_value.get("input_type").toString().equals("6")) { // binary versteckt
                                        this.out.println("[ " + input_type_entries[6] + " ]");
                                    } else {
                                        if (ent_value.get("display_type").toString().endsWith("3")) {
                                            this.out.println("<pre>"
                                                    + this.htmlSpecialChars(ent_value.get("value").toString())
                                                    + "</pre>");
                                        } else {
                                            this.out.println(
                                                    this.htmlSpecialChars(ent_value.get("value").toString()));
                                        }
                                    }
                                    this.out.println("   </td>");
                                    this.out.println("</tr>");
                                }
                            }
                        }
                    }
                    //out.print(section);

                }

            } catch (Exception e) {
                this.setError(e.getMessage(), SOSClassUtil.getMethodName());
                return;
            }
        }

        this.showTableEnd();

    } catch (Exception e) {
        this.setError(e.getMessage(), SOSClassUtil.getMethodName());
        return;
    }

}

From source file:sos.settings.SOSSettingsDialog.java

/**
 * !!! unter Produktion mu nich verwendet werden <br/>Anzeige von aktuellen
 * Request,Session usw Variablen//from  ww w.  j a v a  2  s .c o m
 * 
 * @param request
 * @param out
 * @throws IOException
 */
public void showDevelopmentData(LinkedHashMap requestMultipart) throws Exception {

    this.out.println(
            "<div id='div_temp_request' style=\"background-color:#ffffff;width:400px; overflow: auto; POSITION: absolute; Z-INDEX: 20; VISIBILITY: visible; TOP: "
                    + this.divDevelopmentDataTop + "; LEFT: " + this.divDevelopmentDataLeft
                    + "; border:solid 2px #dddddd;\">");

    this.out.println("<table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>action</b> = " + this.action + " <b>range</b> = " + this.range
            + " <b>item</b> = " + this.item + "</td>");
    this.out.println("</tr>");

    this.out.println("<tr>");
    this.out.println(
            "   <td colspan=\"2\"><b>application</b> = " + this.settings.application + " <b>section</b> = "
                    + this.settings.section + " <b>entry</b> = " + this.settings.entry + "</td>");
    this.out.println("</tr>");

    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>REQUEST PARAMETER: </b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td>");
    this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
    Enumeration en = this.request.getParameterNames();
    while (en.hasMoreElements()) {
        String a = (String) en.nextElement();
        this.out.println("<tr>");
        this.out.println("   <td><b>" + a + "</b></td>");
        this.out.println("    <td>" + this.request.getParameter(a) + "</td>");
        this.out.println("</tr>");
    }
    this.out.println("   </table>");
    this.out.println("   </td>");
    this.out.println("   <td>&nbsp;</td>");
    this.out.println("</tr>");
    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td width=\"50%\"><b>REQUEST ATTRIBUTE</b></td>");
    this.out.println("   <td><b>MULTIPART-REQUEST</b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td>");
    this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
    Enumeration ena = this.request.getAttributeNames();
    int r = 0;
    while (ena.hasMoreElements()) {
        String a = (String) ena.nextElement();
        this.out.println("<tr>");
        this.out.println("   <td><b>" + a + "</b></td>");
        this.out.println("    <td>" + (String) this.request.getAttribute(a) + "</td>");
        this.out.println("</tr>");
        r++;
    }
    this.out.println("   </table>");
    this.out.println("   </td>");
    this.out.println("   <td>");
    int m = 0;
    if (requestMultipart != null && requestMultipart.size() > 0) {
        this.out.println("   <table width=\"100%\" cellPadding=\"0\" cellSpacing=\"0\">");
        Iterator it = requestMultipart.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            this.out.println("<tr>");
            this.out.println("   <td><b>" + (String) entry.getKey() + "</b></td>");
            this.out.println("    <td>" + (String) entry.getValue() + "</td>");
            this.out.println("</tr>");
            m++;
        }
        this.out.println("   </table>");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");
    this.out.println("<tr><td>" + r + "</td><td>" + m + "</td></tr>");
    this.out.println("<tr><td colspan=\"2\">&nbsp;</td></tr>");

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>Session: </b></td>");
    this.out.println("</tr>");
    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\"><b>ID = </b>" + this.session.getId() + "</td>");
    this.out.println("</tr>");
    if (this.request.isRequestedSessionIdFromCookie()) {
        this.out.println("<tr>");
        this.out.println("   <td colspan=\"2\">Session aus Cookie</td>");
        this.out.println("</tr>");
    }
    if (this.request.isRequestedSessionIdFromURL()) {
        this.out.println("<tr>");
        this.out.println("   <td colspan=\"2\">Session aus URL</td>");
        this.out.println("</tr>");
    }

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\">");
    if (this.session.isNew()) {
        this.out.print("neue Session");
    } else {
        this.out.print("alte Session");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");

    Enumeration sessionAttributeNames = this.session.getAttributeNames();

    //this.session.setAttribute("SOS 1","SOS value");
    //String[] a = {"aa","bb","cc"};
    //this.session.setAttribute("SOS 2",a);

    this.out.println("<tr>");
    this.out.println("   <td colspan=\"2\">");
    while (sessionAttributeNames.hasMoreElements()) {
        String sessionAttribute = (String) sessionAttributeNames.nextElement();
        Object obj = this.session.getAttribute(sessionAttribute);
        this.out.print("<b>" + sessionAttribute + "</b>  = " + obj + "<br />");
    }
    this.out.println("   </td>");
    this.out.println("</tr>");
    this.out.println("</table>");

    this.out.println("</div>");

}

From source file:org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.java

@SuppressWarnings("nls")
private Operator genUnionPlan(String unionalias, String leftalias, Operator leftOp, String rightalias,
        Operator rightOp) throws SemanticException {

    // Currently, the unions are not merged - each union has only 2 parents. So,
    // a n-way union will lead to (n-1) union operators.
    // This can be easily merged into 1 union
    RowResolver leftRR = opParseCtx.get(leftOp).getRowResolver();
    RowResolver rightRR = opParseCtx.get(rightOp).getRowResolver();
    LinkedHashMap<String, ColumnInfo> leftmap = leftRR.getFieldMap(leftalias);
    LinkedHashMap<String, ColumnInfo> rightmap = rightRR.getFieldMap(rightalias);
    // make sure the schemas of both sides are the same
    ASTNode tabref = qb.getAliases().isEmpty() ? null
            : qb.getParseInfo().getSrcForAlias(qb.getAliases().get(0));
    if (leftmap.size() != rightmap.size()) {
        throw new SemanticException("Schema of both sides of union should match.");
    }// www . j av  a  2 s  .c o m

    RowResolver unionoutRR = new RowResolver();

    Iterator<Map.Entry<String, ColumnInfo>> lIter = leftmap.entrySet().iterator();
    Iterator<Map.Entry<String, ColumnInfo>> rIter = rightmap.entrySet().iterator();
    while (lIter.hasNext()) {
        Map.Entry<String, ColumnInfo> lEntry = lIter.next();
        Map.Entry<String, ColumnInfo> rEntry = rIter.next();
        ColumnInfo lInfo = lEntry.getValue();
        ColumnInfo rInfo = rEntry.getValue();

        String field = lEntry.getKey(); // use left alias (~mysql, postgresql)
        // try widening conversion, otherwise fail union
        TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(lInfo.getType(), rInfo.getType());
        if (commonTypeInfo == null) {
            throw new SemanticException(generateErrorMessage(tabref,
                    "Schema of both sides of union should match: Column " + field + " is of type "
                            + lInfo.getType().getTypeName() + " on first table and type "
                            + rInfo.getType().getTypeName() + " on second table"));
        }
        ColumnInfo unionColInfo = new ColumnInfo(lInfo);
        unionColInfo.setType(commonTypeInfo);
        unionoutRR.put(unionalias, field, unionColInfo);
    }

    // For Spark,TEZ we rely on the generated SelectOperator to do the type casting.
    // Consider:
    //    SEL_1 (int)   SEL_2 (int)    SEL_3 (double)
    // If we first merge SEL_1 and SEL_2 into a UNION_1, and then merge UNION_1
    // with SEL_3 to get UNION_2, then no SelectOperator will be inserted. Hence error
    // will happen afterwards. The solution here is to insert one after UNION_1, which
    // cast int to double.
    boolean isMR = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).equals("mr");

    if (!isMR || !(leftOp instanceof UnionOperator)) {
        leftOp = genInputSelectForUnion(leftOp, leftmap, leftalias, unionoutRR, unionalias);
    }

    if (!isMR || !(rightOp instanceof UnionOperator)) {
        rightOp = genInputSelectForUnion(rightOp, rightmap, rightalias, unionoutRR, unionalias);
    }

    // If one of the children (left or right) is:
    // (i) a union, or
    // (ii) an identity projection followed by a union,
    // merge with it
    // else create a new one
    if (leftOp instanceof UnionOperator || (leftOp instanceof SelectOperator
            && leftOp.getParentOperators() != null && !leftOp.getParentOperators().isEmpty()
            && leftOp.getParentOperators().get(0) instanceof UnionOperator
            && ((SelectOperator) leftOp).isIdentitySelect())) {

        if (!(leftOp instanceof UnionOperator)) {
            Operator oldChild = leftOp;
            leftOp = (Operator) leftOp.getParentOperators().get(0);
            leftOp.removeChildAndAdoptItsChildren(oldChild);
        }

        // make left a child of right
        List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
        child.add(leftOp);
        rightOp.setChildOperators(child);

        List<Operator<? extends OperatorDesc>> parent = leftOp.getParentOperators();
        parent.add(rightOp);

        UnionDesc uDesc = ((UnionOperator) leftOp).getConf();
        uDesc.setNumInputs(uDesc.getNumInputs() + 1);
        return putOpInsertMap(leftOp, unionoutRR);
    }

    if (rightOp instanceof UnionOperator || (rightOp instanceof SelectOperator
            && rightOp.getParentOperators() != null && !rightOp.getParentOperators().isEmpty()
            && rightOp.getParentOperators().get(0) instanceof UnionOperator
            && ((SelectOperator) rightOp).isIdentitySelect())) {

        if (!(rightOp instanceof UnionOperator)) {
            Operator oldChild = rightOp;
            rightOp = (Operator) rightOp.getParentOperators().get(0);
            rightOp.removeChildAndAdoptItsChildren(oldChild);
        }

        // make right a child of left
        List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
        child.add(rightOp);
        leftOp.setChildOperators(child);

        List<Operator<? extends OperatorDesc>> parent = rightOp.getParentOperators();
        parent.add(leftOp);
        UnionDesc uDesc = ((UnionOperator) rightOp).getConf();
        uDesc.setNumInputs(uDesc.getNumInputs() + 1);

        return putOpInsertMap(rightOp, unionoutRR);
    }

    // Create a new union operator
    Operator<? extends OperatorDesc> unionforward = OperatorFactory.getAndMakeChild(getOpContext(),
            new UnionDesc(), new RowSchema(unionoutRR.getColumnInfos()));

    // set union operator as child of each of leftOp and rightOp
    List<Operator<? extends OperatorDesc>> child = new ArrayList<Operator<? extends OperatorDesc>>();
    child.add(unionforward);
    rightOp.setChildOperators(child);

    child = new ArrayList<Operator<? extends OperatorDesc>>();
    child.add(unionforward);
    leftOp.setChildOperators(child);

    List<Operator<? extends OperatorDesc>> parent = new ArrayList<Operator<? extends OperatorDesc>>();
    parent.add(leftOp);
    parent.add(rightOp);
    unionforward.setParentOperators(parent);

    // create operator info list to return
    return putOpInsertMap(unionforward, unionoutRR);
}