/** * Returns true if the writer and reader schema are compatible with each * other, following the avro specification. * * @param writer * writer schema * @param reader * reader schema * @return True if compatible, false if not. */ private static boolean avroReadWriteSchemasCompatible(Schema writer, Schema reader) { Symbol rootSymbol; try { ResolvingGrammarGenerator g = new ResolvingGrammarGenerator(); rootSymbol = g.generate(writer, reader); } catch (IOException e) { throw new DatasetException("IOException while generating grammar.", e); } return !hasErrorSymbol(rootSymbol); }
public static boolean canRead(Schema writtenWith, Schema readUsing) { try { return !hasErrors(new ResolvingGrammarGenerator().generate( writtenWith, readUsing)); } catch (IOException e) { return false; } }