Search in sources :

Example 1 with AbstractDFSCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.AbstractDFSCarbonFile in project carbondata by apache.

the class BlockletDataMapIndexStore method createBlockMetaInfo.

private BlockMetaInfo createBlockMetaInfo(String carbonDataFile) throws IOException {
    CarbonFile carbonFile = FileFactory.getCarbonFile(carbonDataFile);
    if (carbonFile instanceof AbstractDFSCarbonFile) {
        RemoteIterator<LocatedFileStatus> iter = ((AbstractDFSCarbonFile) carbonFile).fs.listLocatedStatus(new Path(carbonDataFile));
        LocatedFileStatus fileStatus = iter.next();
        String[] location = fileStatus.getBlockLocations()[0].getHosts();
        long len = fileStatus.getLen();
        return new BlockMetaInfo(location, len);
    } else {
        return new BlockMetaInfo(new String[] { "localhost" }, carbonFile.getSize());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) CarbonFile(org.apache.carbondata.core.datastore.filesystem.CarbonFile) AbstractDFSCarbonFile(org.apache.carbondata.core.datastore.filesystem.AbstractDFSCarbonFile) AbstractDFSCarbonFile(org.apache.carbondata.core.datastore.filesystem.AbstractDFSCarbonFile) LocatedFileStatus(org.apache.hadoop.fs.LocatedFileStatus)

Aggregations

AbstractDFSCarbonFile (org.apache.carbondata.core.datastore.filesystem.AbstractDFSCarbonFile)1 CarbonFile (org.apache.carbondata.core.datastore.filesystem.CarbonFile)1 LocatedFileStatus (org.apache.hadoop.fs.LocatedFileStatus)1 Path (org.apache.hadoop.fs.Path)1