Search in sources :

Example 11 with ExtendedFileSystem

use of com.facebook.presto.hive.filesystem.ExtendedFileSystem in project presto by prestodb.

the class HiveCachingHdfsConfiguration method getConfiguration.

@Override
public Configuration getConfiguration(HdfsContext context, URI uri) {
    @SuppressWarnings("resource") Configuration config = new CachingJobConf((factoryConfig, factoryUri) -> {
        try {
            FileSystem fileSystem = (new Path(factoryUri)).getFileSystem(hiveHdfsConfiguration.getConfiguration(context, factoryUri));
            checkState(fileSystem instanceof ExtendedFileSystem);
            return cacheFactory.createCachingFileSystem(factoryConfig, factoryUri, (ExtendedFileSystem) fileSystem, cacheManager, context.getSession().map(HiveSessionProperties::isCacheEnabled).orElse(cacheConfig.isCachingEnabled()), cacheConfig.getCacheType(), cacheConfig.isValidationEnabled());
        } catch (IOException e) {
            throw new PrestoException(GENERIC_INTERNAL_ERROR, "cannot create caching file system", e);
        }
    });
    Configuration defaultConfig = hiveHdfsConfiguration.getConfiguration(context, uri);
    copy(defaultConfig, config);
    return config;
}
Also used : Path(org.apache.hadoop.fs.Path) HdfsConfiguration(com.facebook.presto.hive.HdfsConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileSystem(org.apache.hadoop.fs.FileSystem) ExtendedFileSystem(com.facebook.presto.hive.filesystem.ExtendedFileSystem) ForCachingFileSystem(com.facebook.presto.cache.ForCachingFileSystem) ExtendedFileSystem(com.facebook.presto.hive.filesystem.ExtendedFileSystem) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException) HiveSessionProperties(com.facebook.presto.hive.HiveSessionProperties)

Example 12 with ExtendedFileSystem

use of com.facebook.presto.hive.filesystem.ExtendedFileSystem in project presto by prestodb.

the class ManifestPartitionLoader method validateManifest.

private void validateManifest(HivePartitionMetadata partition, Path path, List<String> manifestFileNames, List<Long> manifestFileSizes) throws IOException {
    ExtendedFileSystem fileSystem = hdfsEnvironment.getFileSystem(hdfsContext, path);
    HiveDirectoryContext hiveDirectoryContext = new HiveDirectoryContext(recursiveDirWalkerEnabled ? RECURSE : IGNORED, false);
    Iterator<HiveFileInfo> fileInfoIterator = directoryLister.list(fileSystem, table, path, namenodeStats, ignore -> true, hiveDirectoryContext);
    int fileCount = 0;
    while (fileInfoIterator.hasNext()) {
        HiveFileInfo fileInfo = fileInfoIterator.next();
        String fileName = fileInfo.getPath().getName();
        if (!manifestFileNames.contains(fileName)) {
            throw new PrestoException(MALFORMED_HIVE_FILE_STATISTICS, format("Filename = %s not stored in manifest. Partition = %s, TableName = %s", fileName, partition.getHivePartition().getPartitionId(), table.getTableName()));
        }
        int index = manifestFileNames.indexOf(fileName);
        if (!manifestFileSizes.get(index).equals(fileInfo.getLength())) {
            throw new PrestoException(MALFORMED_HIVE_FILE_STATISTICS, format("FilesizeFromManifest = %s is not equal to FilesizeFromStorage = %s. File = %s, Partition = %s, TableName = %s", manifestFileSizes.get(index), fileInfo.getLength(), fileName, partition.getHivePartition().getPartitionId(), table.getTableName()));
        }
        fileCount++;
    }
    if (fileCount != manifestFileNames.size()) {
        throw new PrestoException(MALFORMED_HIVE_FILE_STATISTICS, format("Number of files in Manifest = %s is not equal to Number of files in storage = %s. Partition = %s, TableName = %s", manifestFileNames.size(), fileCount, partition.getHivePartition().getPartitionId(), table.getTableName()));
    }
}
Also used : ExtendedFileSystem(com.facebook.presto.hive.filesystem.ExtendedFileSystem) PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

ExtendedFileSystem (com.facebook.presto.hive.filesystem.ExtendedFileSystem)12 PrestoException (com.facebook.presto.spi.PrestoException)9 Path (org.apache.hadoop.fs.Path)9 IOException (java.io.IOException)8 Configuration (org.apache.hadoop.conf.Configuration)7 Domain (com.facebook.presto.common.predicate.Domain)5 ConnectorSession (com.facebook.presto.spi.ConnectorSession)5 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)5 String.format (java.lang.String.format)5 List (java.util.List)5 Objects.requireNonNull (java.util.Objects.requireNonNull)5 Optional (java.util.Optional)5 FileStatus (org.apache.hadoop.fs.FileStatus)5 SchemaTableName (com.facebook.presto.spi.SchemaTableName)4 NOT_SUPPORTED (com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED)4 ArrayList (java.util.ArrayList)4 ForCachingFileSystem (com.facebook.presto.cache.ForCachingFileSystem)2 FileMergeCachingFileSystem (com.facebook.presto.cache.filemerge.FileMergeCachingFileSystem)2 RuntimeStats (com.facebook.presto.common.RuntimeStats)2