(String[][] table, Operator op, DataBag bag,
StringBuffer output)
| 192 | } |
| 193 | |
| 194 | static void DisplayTable(String[][] table, Operator op, DataBag bag, |
| 195 | StringBuffer output) throws FrontendException { |
| 196 | if (op instanceof LOStore && ((LOStore) op).isTmpStore()) |
| 197 | return; |
| 198 | |
| 199 | int cols = ((LogicalRelationalOperator)op).getSchema().getFields().size(); |
| 200 | List<LogicalSchema.LogicalFieldSchema> fields = ((LogicalRelationalOperator)op).getSchema().getFields(); |
| 201 | int rows = (int) bag.size(); |
| 202 | int[] maxColSizes = new int[cols]; |
| 203 | for (int i = 0; i < cols; ++i) { |
| 204 | maxColSizes[i] = fields.get(i).toString().length(); |
| 205 | if (maxColSizes[i] < 5) |
| 206 | maxColSizes[i] = 5; |
| 207 | } |
| 208 | int total = 0; |
| 209 | final String alias = ((LogicalRelationalOperator)op).getAlias(); |
| 210 | int aliasLength = (op instanceof LOStore ? alias.length() + 12 : alias.length() + 4); |
| 211 | for (int j = 0; j < cols; ++j) { |
| 212 | for (int i = 0; i < rows; ++i) { |
| 213 | int length = table[i][j].length(); |
| 214 | if (length > maxColSizes[j]) |
| 215 | maxColSizes[j] = length; |
| 216 | } |
| 217 | total += maxColSizes[j]; |
| 218 | } |
| 219 | |
| 220 | // Note of limit reset |
| 221 | if (op instanceof LOLimit) { |
| 222 | output.append("\nThe limit now in use, " + ((LOLimit)op).getLimit() + ", may have been changed for ILLUSTRATE purpose.\n"); |
| 223 | } |
| 224 | |
| 225 | // Display the schema first |
| 226 | output |
| 227 | .append(AddSpaces(total + 3 * (cols + 1) + aliasLength + 1, |
| 228 | false) |
| 229 | + "\n"); |
| 230 | if (op instanceof LOStore) |
| 231 | output.append("| Store : " + alias + AddSpaces(4, true) + " | "); |
| 232 | else |
| 233 | output.append("| " + alias + AddSpaces(4, true) + " | "); |
| 234 | for (int i = 0; i < cols; ++i) { |
| 235 | String field = fields.get(i).toString(false); |
| 236 | output.append(field |
| 237 | + AddSpaces(maxColSizes[i] - field.length(), true) + " | "); |
| 238 | } |
| 239 | output.append("\n" |
| 240 | + AddSpaces(total + 3 * (cols + 1) + aliasLength + 1, false) |
| 241 | + "\n"); |
| 242 | // now start displaying the data |
| 243 | for (int i = 0; i < rows; ++i) { |
| 244 | output.append("| " + AddSpaces(aliasLength, true) + " | "); |
| 245 | for (int j = 0; j < cols; ++j) { |
| 246 | String str = table[i][j]; |
| 247 | output.append(str |
| 248 | + AddSpaces(maxColSizes[j] - str.length(), true) |
| 249 | + " | "); |
| 250 | } |
| 251 | output.append("\n"); |
no test coverage detected