@Override public String convertSchema(Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { String schema = super.convertSchema(inputSchema, workUnit); contentType = inputSchema.getFullName() + "+json"; return schema; }
private void put(Schema schema) { String fullName = schema.getFullName(); if(schemas.containsKey(fullName)){ throw new SchemaParseException("Can't redefine: " + fullName); } schemas.put(fullName, schema); }
private void setDefault(Schema record, Field f) { String recordName = record.getFullName(); Map<String,Object> recordDefaults = defaults.get(recordName); if (recordDefaults == null) { recordDefaults = new HashMap<>(); defaults.put(recordName, recordDefaults); } recordDefaults.put(f.name(), model.getDefaultValue(f)); }
/** * Gets the full name. * * @param record the record * @return the full name */ private static String getFullName(GenericContainer record) { return record.getSchema().getFullName(); }
private void put(Schema schema) { String fullName = schema.getFullName(); if(schemas.containsKey(fullName)){ throw new SchemaParseException("Can't redefine: " + fullName); } schemas.put(fullName, schema); }
/** * Retrieves full schema name of the given enum. * * @param symbol enum symbol whose name will be returned. * @return schema full name. */ public static String getEnumFullName(GenericEnumSymbol symbol) { Schema enumSchema = symbol.getSchema(); return enumSchema.getFullName(); }
/** Returns the set of defined, named types known to this parser. */ public Map<String,Schema> getTypes() { Map<String,Schema> result = new LinkedHashMap<String,Schema>(); for (Schema s : names.values()) result.put(s.getFullName(), s); return result; }
private String p(String parent, Schema child, String sep) { if (child.getType() == Schema.Type.UNION) return parent; return p(parent, child.getFullName(), sep); }
/** Returns the set of defined, named types known to this parser. */ public Map<String,Schema> getTypes() { Map<String,Schema> result = new LinkedHashMap<>(); for (Schema s : names.values()) result.put(s.getFullName(), s); return result; }
void validateRecordSchema(Schema schema) throws KaaAdminServiceException { SchemaUtil.compileAvroSchema(schema); if (schema.getType() != Schema.Type.RECORD) { throw new KaaAdminServiceException("Schema " + schema.getFullName() + " is not a record schema!", ServiceErrorCode.INVALID_SCHEMA); } }
private static Schema getSchemaByFullName(List<Schema> types, String fullName) { for (Schema type : types) { if (type.getFullName().equals(fullName)) { return type; } } return null; }
public static Schema getSchemaByFullName(List<Schema> types, String fullName) { for (Schema type : types) { if (type.getFullName().equals(fullName)) { return type; } } return null; }
@Override public T createSchema(DataSchema configSchema) throws SchemaCreationException { addressableRecords.clear(); processedRecords.clear(); Schema avroSchema = new Schema.Parser().parse(configSchema.getRawSchema()); rootSchemaName = avroSchema.getFullName(); Schema resultSchema = convert(avroSchema); return strategy.createSchema(strategy.onSchemaProcessed(resultSchema, addressableRecords)); } }
private boolean isAddressableValue(Schema value) { if (value.getType().equals(Type.RECORD)) { if (value.getJsonProp(ADDRESSABLE_NAME) != null && !value.getFullName().equals(rootSchemaName)) { return value.getJsonProp(ADDRESSABLE_NAME).asBoolean(); } return true; } return false; }
private void readV1(DataInputView in, ClassLoader userCodeClassLoader) throws IOException { final String previousSchemaDefinition = in.readUTF(); this.schema = parseAvroSchema(previousSchemaDefinition); this.runtimeType = findClassOrFallbackToGeneric(userCodeClassLoader, schema.getFullName()); this.runtimeSchema = tryExtractAvroSchema(userCodeClassLoader, runtimeType); }
private String generateDefaultRecord() throws ConfigurationGenerationException, IOException { org.apache.avro.Schema schemaBody = new org.apache.avro.Schema.Parser().parse(body); String fqn = schemaBody.getFullName(); RawSchema rawSchema = new RawSchema(schemaBody.toString()); DefaultRecordGenerationAlgorithm<RawData> algorithm = new DefaultRecordGenerationAlgorithmImpl<>(rawSchema, new RawDataFactory()); return algorithm.getRootData().getRawData(); } }
private static Schema getDeltaSchemaByFullName(Schema deltaSchema, String fullName) { Schema deltaT = deltaSchema.getElementType(); Schema deltaUnion = deltaT.getField("delta").schema(); List<Schema> deltas = deltaUnion.getTypes(); for (Schema delta : deltas) { if (delta.getFullName().equals(fullName)) { return delta; } } return null; }
public static Schema getDeltaSchemaByFullName(Schema deltaSchema, String fullName) { Schema deltaT = deltaSchema.getElementType(); Schema deltaUnion = deltaT.getField("delta").schema(); List<Schema> deltas = deltaUnion.getTypes(); for (Schema delta : deltas) { if (delta.getFullName().equals(fullName)) { return delta; } } return null; }
@Override public String convertSchema(final Schema inputSchema, WorkUnitState workUnit) throws SchemaConversionException { this.defaultMetadata = new Metadata(); defaultMetadata.getGlobalMetadata().setContentType(inputSchema.getFullName() + "+json"); return innerConverter.convertSchema(inputSchema, workUnit); }
@Test public void testNullNamespaceAlias() { Schema s = Schema.parse("{\"type\":\"record\",\"name\":\"Z\",\"fields\":[]}"); Schema t = Schema.parse("{\"type\":\"record\",\"name\":\"x.Y\",\"aliases\":[\".Z\"]," +"\"fields\":[]}"); Schema u = Schema.applyAliases(s, t); assertEquals("x.Y", u.getFullName()); }