@Test public void testArrayTypeLoad() { Column[] schema = SchemaUtils.fromString("key:BIGINT,value:ARRAY<STRING>"); Assert.assertEquals(2, schema.length); Assert.assertEquals(OdpsType.ARRAY, schema[1].getType()); Assert.assertEquals(OdpsType.STRING, schema[1].getGenericTypeList().get(0)); }
public static Column[] fromString(String str) { if (str == null || str.isEmpty()) { return new Column[0]; } String remain = str; ArrayList<Column> cols = new ArrayList<Column>(); int pos = 0; IllegalArgumentException exception = null; while (remain.length() > 0) { pos = remain.indexOf(SEPERATOR, pos); if (pos < 0) { pos = remain.length(); } String tok = remain.substring(0, pos); String[] knv = tok.split(DELIMITER, 2); if (knv.length != 2) { throw new IllegalArgumentException( "Malformed schema definition, expecting \"name:type\" but was \"" + tok + "\""); } try { TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(knv[1].trim()); if (typeInfo != null) { exception = null; cols.add(new Column(knv[0].trim(), typeInfo)); if (pos == remain.length()) { remain = ""; } else { remain = remain.substring(pos + 1); pos = 0; } continue; } } catch (IllegalArgumentException e) { exception = e; } if (pos == remain.length()) { remain = ""; } else { pos = pos + 1; } } if (exception != null) { throw exception; } else { return cols.toArray(new Column[]{}); } }
SchemaUtils { public static Column[] fromString(String str) { if (str == null || str.isEmpty()) { return new Column[0]; } String remain = str; ArrayList<Column> cols = new ArrayList<Column>(); int pos = 0; IllegalArgumentException exception = null; while (remain.length() > 0) { pos = remain.indexOf(SEPERATOR, pos); if (pos < 0) { pos = remain.length(); } String tok = remain.substring(0, pos); String[] knv = tok.split(DELIMITER, 2); if (knv.length != 2) { throw new IllegalArgumentException( "Malformed schema definition, expecting \"name:type\" but was \"" + tok + "\""); } try { TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(knv[1].trim()); if (typeInfo != null) { exception = null; cols.add(new Column(knv[0].trim(), typeInfo)); if (pos == remain.length()) { remain = ""; } else { remain = remain.substring(pos + 1); pos = 0; } continue; } } catch (IllegalArgumentException e) { exception = e; } if (pos == remain.length()) { remain = ""; } else { pos = pos + 1; } } if (exception != null) { throw exception; } else { return cols.toArray(new Column[]{}); } } }
SchemaUtils { public static Column[] fromString(String str) { if (str == null || str.isEmpty()) { return new Column[0]; } String remain = str; ArrayList<Column> cols = new ArrayList<Column>(); int pos = 0; IllegalArgumentException exception = null; while (remain.length() > 0) { pos = remain.indexOf(SEPERATOR, pos); if (pos < 0) { pos = remain.length(); } String tok = remain.substring(0, pos); String[] knv = tok.split(DELIMITER, 2); if (knv.length != 2) { throw new IllegalArgumentException( "Malformed schema definition, expecting \"name:type\" but was \"" + tok + "\""); } try { TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(knv[1].trim()); if (typeInfo != null) { exception = null; cols.add(new Column(knv[0].trim(), typeInfo)); if (pos == remain.length()) { remain = ""; } else { remain = remain.substring(pos + 1); pos = 0; } continue; } } catch (IllegalArgumentException e) { exception = e; } if (pos == remain.length()) { remain = ""; } else { pos = pos + 1; } } if (exception != null) { throw exception; } else { return cols.toArray(new Column[]{}); } }  }
SchemaUtils { public static Column[] fromString(String str) { if (str == null || str.isEmpty()) { return new Column[0]; } String remain = str; ArrayList<Column> cols = new ArrayList<Column>(); int pos = 0; IllegalArgumentException exception = null; while (remain.length() > 0) { pos = remain.indexOf(SEPERATOR, pos); if (pos < 0) { pos = remain.length(); } String tok = remain.substring(0, pos); String[] knv = tok.split(DELIMITER, 2); if (knv.length != 2) { throw new IllegalArgumentException( "Malformed schema definition, expecting \"name:type\" but was \"" + tok + "\""); } try { TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(knv[1].trim()); if (typeInfo != null) { exception = null; cols.add(new Column(knv[0].trim(), typeInfo)); if (pos == remain.length()) { remain = ""; } else { remain = remain.substring(pos + 1); pos = 0; } continue; } } catch (IllegalArgumentException e) { exception = e; } if (pos == remain.length()) { remain = ""; } else { pos = pos + 1; } } if (exception != null) { throw exception; } else { return cols.toArray(new Column[]{}); } }  static Column[] fromString(String str); static String toString(Column[] cols); static String[] getNames(Column[] cols); static OdpsType[] getTypes(Column[] cols); static com.aliyun.odps.type.TypeInfo[] getTypeInfos(Column[] cols); }
SchemaUtils { public static Column[] fromString(String str) { if (str == null || str.isEmpty()) { return new Column[0]; } String remain = str; ArrayList<Column> cols = new ArrayList<Column>(); int pos = 0; IllegalArgumentException exception = null; while (remain.length() > 0) { pos = remain.indexOf(SEPERATOR, pos); if (pos < 0) { pos = remain.length(); } String tok = remain.substring(0, pos); String[] knv = tok.split(DELIMITER, 2); if (knv.length != 2) { throw new IllegalArgumentException( "Malformed schema definition, expecting \"name:type\" but was \"" + tok + "\""); } try { TypeInfo typeInfo = TypeInfoParser.getTypeInfoFromTypeString(knv[1].trim()); if (typeInfo != null) { exception = null; cols.add(new Column(knv[0].trim(), typeInfo)); if (pos == remain.length()) { remain = ""; } else { remain = remain.substring(pos + 1); pos = 0; } continue; } } catch (IllegalArgumentException e) { exception = e; } if (pos == remain.length()) { remain = ""; } else { pos = pos + 1; } } if (exception != null) { throw exception; } else { return cols.toArray(new Column[]{}); } }  static Column[] fromString(String str); static String toString(Column[] cols); static String[] getNames(Column[] cols); static OdpsType[] getTypes(Column[] cols); static com.aliyun.odps.type.TypeInfo[] getTypeInfos(Column[] cols);  }