/** * Creates a new schema manager using the given root directory of a * dataset for its base. * * @param conf the Hadoop configuration * @param schemaDirectory directory in which the manager * stores schemas. * * @return a schema manager instance. */ public static SchemaManager create(Configuration conf, Path schemaDirectory) { try { FileSystem rootFileSystem = schemaDirectory.getFileSystem(conf); rootFileSystem.mkdirs(schemaDirectory); return new SchemaManager(schemaDirectory, rootFileSystem); } catch (IOException e) { throw new DatasetIOException("Unable to create schema manager directory: " + schemaDirectory, e); } }
/** * Loads a schema manager that stores data under the given dataset root * directory it exists. Returns <code>null</code> if it does not. * * @param conf the Hadoop configuration * @param schemaDirectory directory in which the manager stores schemas. * * @return a schema manager instance, or <code>null</code> if the given * directory does not exist. */ public static SchemaManager load(Configuration conf, Path schemaDirectory) { try { FileSystem rootFileSystem = schemaDirectory.getFileSystem(conf); if (rootFileSystem.exists(schemaDirectory)) { return new SchemaManager(schemaDirectory, rootFileSystem); } else { return null; } } catch (IOException e) { throw new DatasetIOException ("Cannot load schema manager at:" + schemaDirectory, e); } }