public static SchemaFieldInfoStorable fromSchemaFieldInfo(SchemaFieldInfo schemaFieldInfo, Long id) { SchemaFieldInfoStorable schemaFieldInfoStorable = new SchemaFieldInfoStorable(id); schemaFieldInfoStorable.setFieldNamespace(schemaFieldInfo.getNamespace()); schemaFieldInfoStorable.setName(schemaFieldInfo.getName()); schemaFieldInfoStorable.setType(schemaFieldInfo.getType()); return schemaFieldInfoStorable; }
private void parseField(Schema.Field field, List<SchemaFieldInfo> schemaFieldInfos, Set<String> visitedRecords) { Schema schema = field.schema(); Schema.Type type = schema.getType(); String name = field.name(); LOG.debug("Visiting field: [{}]", field); String namespace = null; try { namespace = schema.getNamespace(); } catch (Exception e) { //ignore. } schemaFieldInfos.add(new SchemaFieldInfo(namespace, name, type.name())); // todo check whether fields should be mapped to the root schema. parseSchema(schema, schemaFieldInfos, visitedRecords); }
private void parseField(Schema.Field field, List<SchemaFieldInfo> schemaFieldInfos, Set<String> visitedRecords) { Schema schema = field.schema(); Schema.Type type = schema.getType(); String name = field.name(); LOG.debug("Visiting field: [{}]", field); String namespace = null; try { namespace = schema.getNamespace(); } catch (Exception e) { //ignore. } schemaFieldInfos.add(new SchemaFieldInfo(namespace, name, type.name())); // todo check whether fields should be mapped to the root schema. parseSchema(schema, schemaFieldInfos, visitedRecords); }
@Override public List<SchemaFieldInfo> generateFields(String schemaText) { // schema should be in json form. List<Schema.Field> fields; try { fields = new ObjectMapper().readValue(schemaText, new TypeReference<List<Schema.Field>>() {}); } catch (IOException e) { throw new RuntimeException(e); } List<SchemaFieldInfo> fieldInfos = new ArrayList<>(fields.size()); for (Schema.Field field : fields) { // currently internal schema implementation does not have namespace. fieldInfos.add(new SchemaFieldInfo("__universal", field.getName(), field.getType().toString())); } return fieldInfos; } }