2018.4.28

2018.4.28

for (ArrayList<Row> rows : joinedTable) {
    Row tmpLeftRow = rows.get(0);
    Row tmpRightRow = rows.get(1);
    boolean valid = false; // 这一行是否满足where条件
    if (whereInLeft) {
        if (tmpLeftRow.getEntries().get(whereAttrIndex).compareTo(whereAttrEntry) == 0) {
            valid = true;
        }
    } else {
        if (tmpRightRow.getEntries().get(whereAttrIndex).compareTo(whereAttrEntry) == 0) {
            valid = true;
        }
    }
    if (valid) {
        StringBuilder currentRow = new StringBuilder();
        for (int j = 0; j < leftAttrIndices.size() - 1; j++) {
            currentRow
                    .append(tmpLeftRow.getEntries().get(leftAttrIndices.get(j)).toString())
                    .append(", ");
        }
        currentRow
                .append(tmpLeftRow.getEntries()
                        .get(leftAttrIndices.get(leftAttrIndices.size() - 1)).toString());
        if (!rightAttrIndices.isEmpty()) {
            currentRow.append(", ");
        }
        for (int j = 0; j < rightAttrIndices.size() - 1; j++) {
            currentRow
                    .append(tmpRightRow.getEntries().get(rightAttrIndices.get(j)).toString())
                    .append(", ");
        }
        currentRow
                .append(tmpRightRow.getEntries()
                        .get(rightAttrIndices.get(rightAttrIndices.size() - 1)).toString());
        ArrayList<String> tmpRow = new ArrayList<>();
        tmpRow.add(currentRow.toString());
        resp.rowList.add(tmpRow);
    }
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/swy_swy_swy/article/details/106219809