/** * Imports an existing schema stored at the given path. This * is generally used to bring in schemas written by previous * versions of this library. * * @param schemaPath A path to a schema to import * @return The URI of the schema file managed by this manager. */ public URI importSchema(Path schemaPath) { Schema schema = loadSchema(schemaPath); return writeSchema(schema); }
/** * Gets the newest schema version being managed. * * @return thew newest schema version */ public Schema getNewestSchema() { Path schemaPath = newestFile(); return schemaPath == null ? null : loadSchema(schemaPath); }
/** * Returns a map of schema versions with the schemas themselves. */ public Map<Integer,Schema> getSchemas() { Map<Integer,Schema> schemas = new TreeMap<Integer, Schema>(); try { FileStatus[] statuses = rootFileSystem.listStatus(schemaDirectory); for (FileStatus fileStatus: statuses) { int schemaNumber = getFileNumber(fileStatus); Schema schema = loadSchema(fileStatus.getPath()); schemas.put(schemaNumber, schema); } } catch (IOException e) { throw new DatasetIOException("Unable to list schema files.", e); } return schemas; } }
Schema previousSchema = loadSchema(previousPath);