Skip to content

Commit

Permalink
Reduce number of hdfsConfiguration copies
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Collooru authored and NikhilCollooru committed Aug 1, 2022
1 parent 0860390 commit 1f37a95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -166,7 +166,7 @@ public ListenableFuture<?> loadPartition(HivePartitionMetadata partition, HiveSp
Path path = new Path(location);
Configuration configuration = hdfsEnvironment.getConfiguration(hdfsContext, path);
InputFormat<?, ?> inputFormat = getInputFormat(configuration, inputFormatName, false);
ExtendedFileSystem fs = hdfsEnvironment.getFileSystem(hdfsContext, path);
ExtendedFileSystem fs = hdfsEnvironment.getFileSystem(hdfsContext.getIdentity().getUser(), path, configuration);
boolean s3SelectPushdownEnabled = shouldEnablePushdownForTable(session, table, path.toString(), partition.getPartition());

if (inputFormat instanceof SymlinkTextInputFormat) {
Expand Down
Expand Up @@ -62,10 +62,15 @@ public HiveCachingHdfsConfiguration(
@Override
public Configuration getConfiguration(HdfsContext context, URI uri)
{
Configuration defaultConfig = hiveHdfsConfiguration.getConfiguration(context, uri);
@SuppressWarnings("resource")
Configuration config = new CachingJobConf((factoryConfig, factoryUri) -> {
try {
FileSystem fileSystem = (new Path(factoryUri)).getFileSystem(hiveHdfsConfiguration.getConfiguration(context, factoryUri));
Configuration currentConfig = defaultConfig;
if (uri.compareTo(factoryUri) != 0) {
currentConfig = hiveHdfsConfiguration.getConfiguration(context, factoryUri);
}
FileSystem fileSystem = (new Path(factoryUri)).getFileSystem(currentConfig);
checkState(fileSystem instanceof ExtendedFileSystem);
return cacheFactory.createCachingFileSystem(
factoryConfig,
Expand All @@ -79,7 +84,7 @@ public Configuration getConfiguration(HdfsContext context, URI uri)
catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "cannot create caching file system", e);
}
}, hiveHdfsConfiguration.getConfiguration(context, uri));
}, defaultConfig);
return config;
}

Expand Down

0 comments on commit 1f37a95

Please sign in to comment.