From cdb82205107df9167b02d8861a2e9ef848c9a4a5 Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Mon, 10 Jul 2023 22:21:34 +0800 Subject: [PATCH] perf: add the 'COSN_FILESTATUS_LIST_RECURSIVE_ENABLED' property to improve the performance of the list op. --- src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java | 3 +++ src/main/java/org/apache/hadoop/fs/CosNFileSystem.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java index 942698a0..196662d1 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java +++ b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java @@ -205,4 +205,7 @@ public class CosNConfigKeys extends CommonConfigurationKeys { public static final String COSN_FILESTATUS_LIST_OP_ENABLED = "fs.cosn.filestatus.list.op.enabled"; public static final boolean DEFAULT_FILESTATUS_LIST_OP_ENABLED = true; + + public static final String COSN_FILESTATUS_LIST_RECURSIVE_ENABLED = "fs.cosn.filestatus.list.recursive.enabled"; + public static final boolean DEFAULT_FILESTATUS_LIST_RECURSIVE_ENABLED = false; } diff --git a/src/main/java/org/apache/hadoop/fs/CosNFileSystem.java b/src/main/java/org/apache/hadoop/fs/CosNFileSystem.java index 5f280bbc..508c2409 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNFileSystem.java +++ b/src/main/java/org/apache/hadoop/fs/CosNFileSystem.java @@ -611,7 +611,9 @@ public FileStatus innerGetFileStatus(Path f, boolean checkFile) throws IOExcepti LOG.debug("List the cos key [{}] to judge whether it is a directory or not. max keys [{}]", key, maxKeys); CosNResultInfo listObjectsResultInfo = new CosNResultInfo(); - CosNPartialListing listing = this.nativeStore.list(key, maxKeys, listObjectsResultInfo); + CosNPartialListing listing = this.nativeStore.list(key, maxKeys, null, + this.getConf().getBoolean(CosNConfigKeys.COSN_FILESTATUS_LIST_RECURSIVE_ENABLED, CosNConfigKeys.DEFAULT_FILESTATUS_LIST_RECURSIVE_ENABLED), + listObjectsResultInfo); if (listing.getFiles().length > 0 || listing.getCommonPrefixes().length > 0) { LOG.debug("List the cos key [{}] to find that it is a directory.", key); return newDirectory(absolutePath);