@Override public Dataset create(String name, DatasetDescriptor descriptor) { Preconditions.checkArgument(name != null, "Name can not be null"); Preconditions.checkArgument(descriptor != null, "Descriptor can not be null"); Schema schema = descriptor.getSchema(); Path datasetPath = pathForDataset(name); try { if (fileSystem.exists(datasetPath)) { throw new DatasetRepositoryException("Attempt to create an existing dataset:" + name); } } catch (IOException e) { throw new DatasetRepositoryException( "Internal error while determining if dataset path already exists:" + datasetPath, e); } logger.debug( "Creating dataset:{} schema:{} datasetPath:{}", new Object[] {name, schema, datasetPath}); try { if (!fileSystem.mkdirs(datasetPath)) { throw new DatasetRepositoryException("Failed to make dataset path:" + datasetPath); } } catch (IOException e) { throw new DatasetRepositoryException( "Internal failure while creating dataset path:" + datasetPath, e); } metadataProvider.save(name, descriptor); return new FileSystemDataset.Builder() .name(name) .fileSystem(fileSystem) .descriptor(descriptor) .directory(pathForDataset(name)) .partitionKey(descriptor.isPartitioned() ? Accessor.getDefault().newPartitionKey() : null) .get(); }