private void init(JsonNode operatorJson, BlockSchema inputSchema) { JsonNode exprListNode = operatorJson.get("genExpressions"); Iterator<JsonNode> it = exprListNode.getElements(); while (it.hasNext()) { JsonNode expr = it.next(); String colName = expr.get("col").getTextValue(); int columnId = inputSchema.getIndex(colName); flattenColumnNameSet.add(colName); columnIndexArray.add(columnId); if (expr.has("flatten")) { final String flattenTypeStr = expr.get("flatten").getTextValue(); flattenPositions.put(inputSchema.getIndex(colName), FlattenType.fromString(flattenTypeStr)); odometerIterators.add(null); // Extract output column definition from 'expr' List<ColumnType> outputColumTypeList = new ArrayList<ColumnType>(); inputColumnIndexToOutputTypes.put(columnId, outputColumTypeList); JsonNode outputNode = expr.get("output"); for (JsonNode j : outputNode) { String outColName = j.get("col").getTextValue(); DataType outType = DataType.valueOf(j.get("type").getTextValue()); outputColumTypeList.add(new ColumnType(outColName, outType)); } } } this.outSchema = generateOutSchema(inputSchema); }
public static FlattenType fromString(String s) throws IllegalArgumentException { for (FlattenType ftype : FlattenType.values()) { if (s.equalsIgnoreCase(ftype.toString())) return ftype; } throw new IllegalArgumentException("Unmatched FlattenType"); }