private Schema getSchemaFromFile(@NonNull final LocatedFileStatus resultSchemaFile) throws IOException { return getSchemaFromPath(resultSchemaFile.getPath()); }
@Override public HDFSSchemaServiceReader getReader(@NotEmpty final String schemaName, final int schemaVersion) { HDFSSchemaServiceReader reader; try { final HDFSSchemaServiceConfiguration conf = new HDFSSchemaServiceConfiguration(this.conf); Path schemaPath = new Path(conf.getPath(), String.format(AVRO_SCHEMA_FILE_PATTERN, schemaName, schemaVersion)); reader = new HDFSSchemaServiceReader(getSchemaFromPath(schemaPath)); } catch (IOException e) { throw new JobRuntimeException("Unable to load schema", e); } return reader; }
/** * It fetches latest version of the schema. * @param schemaName Fully qualified schema name * @param schemaVersion schema version * @return Avro schema */ public Schema getSchema(@NotEmpty final String schemaName, final int schemaVersion) { try { final HDFSSchemaServiceConfiguration conf = new HDFSSchemaServiceConfiguration(this.conf); Path schemaPath = new Path(conf.getPath(), String.format(AVRO_SCHEMA_FILE_PATTERN, schemaName, schemaVersion)); return getSchemaFromPath(schemaPath); } catch (IOException e) { throw new JobRuntimeException("Unable to load schema", e); } }
@Override public HDFSSchemaServiceWriter getWriter(@NotEmpty final String schemaName, final int schemaVersion) { HDFSSchemaServiceWriter writer; try { final HDFSSchemaServiceConfiguration conf = new HDFSSchemaServiceConfiguration(this.conf); Path schemaPath = new Path(conf.getPath(), String.format(AVRO_SCHEMA_FILE_PATTERN, schemaName, schemaVersion)); writer = new HDFSSchemaServiceWriter(getSchemaFromPath(schemaPath)); } catch (IOException e) { throw new JobRuntimeException("Unable to load schema", e); } return writer; }