Java 类org.apache.avro.io.parsing.ResolvingGrammarGenerator 实例源码

项目:cdk    文件:AvroEntitySchema.java   
/**
 * 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);
}
项目:cdk    文件:SchemaValidationUtil.java   
public static boolean canRead(Schema writtenWith, Schema readUsing) {
  try {
    return !hasErrors(new ResolvingGrammarGenerator().generate(
        writtenWith, readUsing));
  } catch (IOException e) {
    return false;
  }
}