public static List<Integer> genReadColsIndexes(TableMeta meta, String[] readCols) { if (readCols == null || readCols.length == 0 || readCols[0] == null || readCols[0].trim().length() == 0) { return null; } List<Integer> indexes = new ArrayList<Integer>(); for (String col : readCols) { boolean found = false; for (int j = 0; j < meta.getCols().length; ++j) { if (meta.getCols()[j].getName().equals(col)) { indexes.add(j); found = true; break; } } if (!found) { throw new RuntimeException( ExceptionCode.ODPS_0720021 + " - " + col + " in table " + meta.getProjName() + "." + meta.getTableName()); } } return indexes; }
public static Column[] getInputTableFields(TableMeta meta, String[] cols) { if (cols == null || cols[0].length() == 0) { return meta.getCols(); } List<Column> fields = new ArrayList<Column>(); for (String col : cols) { for (Column field : meta.getCols()) { if (col.equals(field.getName())) { fields.add(field); } } } return fields.toArray(new Column[fields.size()]); }