Search in sources :

Example 1 with MapFileOperations

use of org.apache.accumulo.core.file.map.MapFileOperations in project accumulo by apache.

the class DispatchingFileFactory method findFileFactory.

private FileOperations findFileFactory(FileAccessOperation<?> options) {
    String file = options.getFilename();
    Path p = new Path(file);
    String name = p.getName();
    if (name.startsWith(Constants.MAPFILE_EXTENSION + "_")) {
        return new MapFileOperations();
    }
    String[] sp = name.split("\\.");
    if (sp.length < 2) {
        throw new IllegalArgumentException("File name " + name + " has no extension");
    }
    String extension = sp[sp.length - 1];
    if (extension.equals(Constants.MAPFILE_EXTENSION) || extension.equals(Constants.MAPFILE_EXTENSION + "_tmp")) {
        return new MapFileOperations();
    } else if (extension.equals(RFile.EXTENSION) || extension.equals(RFile.EXTENSION + "_tmp")) {
        return new RFileOperations();
    } else {
        throw new IllegalArgumentException("File type " + extension + " not supported");
    }
}
Also used : Path(org.apache.hadoop.fs.Path) RFileOperations(org.apache.accumulo.core.file.rfile.RFileOperations) MapFileOperations(org.apache.accumulo.core.file.map.MapFileOperations)

Aggregations

MapFileOperations (org.apache.accumulo.core.file.map.MapFileOperations)1 RFileOperations (org.apache.accumulo.core.file.rfile.RFileOperations)1 Path (org.apache.hadoop.fs.Path)1