This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-fs-spi
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-fs-spi by this push:
     new 05469050484 [refactor](fe) Implement Phase 1 FS interface refactoring: 
new FileSystem API and value objects (#61908)
05469050484 is described below

commit 054690504849997c99fc2611e6a1289199203967
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Mon Mar 30 13:55:14 2026 -0700

    [refactor](fe) Implement Phase 1 FS interface refactoring: new FileSystem 
API and value objects (#61908)
    
    ### What problem does this PR solve?
    
    Issue Number: #61860
    
    Problem Summary: The existing FileSystem interface uses Status-based
    return values, bare String paths, and Hadoop-dependent RemoteFile
    objects throughout the FE codebase, making it hard to test and
    impossible to isolate from Hadoop at the module boundary. Phase 1
    introduces the new clean IOException-based FileSystem API with typed
    Location value objects, while preserving full backward compatibility via
    LegacyFileSystemApi.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test: Manual build verification (./build.sh --fe) passes with zero
    errors
    - Behavior changed: No (all existing code paths preserved via
    LegacyFileSystemApi)
    - Does this need documentation: No
    
    New files:
    - Location.java: immutable URI value object replacing bare String paths
    - FileEntry.java: immutable file/dir descriptor replacing
    Hadoop-dependent RemoteFile
    - FileIterator.java: lazy Closeable iterator interface for directory
    listing
    - LegacyFileSystemApi.java: @Deprecated copy of old FileSystem interface
    (Status-based)
    - LegacyFileSystemAdapter.java: abstract bridge implementing new
    FileSystem via legacy* methods
    - LegacyToNewFsAdapter.java: wraps any LegacyFileSystemApi as new
    FileSystem
    - MemoryFileSystem.java: in-memory FileSystem for unit testing
    
    Modified files:
    - FileSystem.java: replaced with new clean IOException-based interface
    - PersistentFileSystem, LocalDfsFileSystem, SwitchingFileSystem:
    implements LegacyFileSystemApi
    - FileSystemProvider, FileSystemLookup: return LegacyFileSystemApi
    - DorisInputFile, DorisOutputFile: add location() method; deprecate
    path()
    - HdfsInputFile, HdfsOutputFile, HdfsInputStream: use Location instead
    of ParsedPath
    - ParsedPath: @Deprecated + toLocation() conversion method
    - RemoteFile: @Deprecated + toFileEntry()/fromFileEntry() conversion
    methods
    - RemoteFiles, RemoteFileRemoteIterator: @Deprecated
    - All callers updated to use LegacyFileSystemApi type
    
    Co-authored-by: Copilot <[email protected]>
---
 .../org/apache/doris/datasource/hive/AcidUtil.java |   8 +-
 .../doris/datasource/hive/HMSTransaction.java      |   4 +-
 .../datasource/iceberg/fileio/DelegateFileIO.java  |   6 +-
 .../iceberg/fileio/DelegateOutputFile.java         |   6 +-
 .../java/org/apache/doris/fs/DirectoryLister.java  |   2 +-
 .../main/java/org/apache/doris/fs/FileEntry.java   | 213 +++++++++++++++++
 .../java/org/apache/doris/fs/FileIterator.java     | 120 ++++++++++
 .../main/java/org/apache/doris/fs/FileSystem.java  | 195 +++++++--------
 .../apache/doris/fs/FileSystemDirectoryLister.java |   3 +-
 .../java/org/apache/doris/fs/FileSystemLookup.java |   2 +-
 .../org/apache/doris/fs/FileSystemProvider.java    |   2 +-
 .../apache/doris/fs/FileSystemProviderImpl.java    |   2 +-
 .../java/org/apache/doris/fs/FileSystemUtil.java   |   4 +-
 .../apache/doris/fs/LegacyFileSystemAdapter.java   | 221 +++++++++++++++++
 .../{FileSystem.java => LegacyFileSystemApi.java}  |  15 +-
 .../org/apache/doris/fs/LegacyToNewFsAdapter.java  |  92 +++++++
 .../org/apache/doris/fs/LocalDfsFileSystem.java    |   2 +-
 .../main/java/org/apache/doris/fs/Location.java    | 169 +++++++++++++
 .../java/org/apache/doris/fs/MemoryFileSystem.java | 263 +++++++++++++++++++++
 .../org/apache/doris/fs/PersistentFileSystem.java  |   2 +-
 .../apache/doris/fs/RemoteFileRemoteIterator.java  |   4 +
 .../main/java/org/apache/doris/fs/RemoteFiles.java |   4 +
 .../fs/TransactionScopeCachingDirectoryLister.java |   7 +-
 .../org/apache/doris/fs/io/DorisInputFile.java     |  14 +-
 .../org/apache/doris/fs/io/DorisOutputFile.java    |  16 +-
 .../java/org/apache/doris/fs/io/ParsedPath.java    |  15 +-
 .../org/apache/doris/fs/io/hdfs/HdfsInputFile.java |  34 +--
 .../apache/doris/fs/io/hdfs/HdfsInputStream.java   |  13 +-
 .../apache/doris/fs/io/hdfs/HdfsOutputFile.java    |  28 +--
 .../org/apache/doris/fs/remote/RemoteFile.java     |  57 +++++
 .../doris/fs/remote/SwitchingFileSystem.java       |   6 +-
 .../apache/doris/fs/remote/dfs/DFSFileSystem.java  |   5 +-
 .../datasource/hive/HMSTransactionPathTest.java    |  12 +-
 .../doris/datasource/hive/HmsCommitTest.java       |   6 +-
 ...TransactionScopeCachingDirectoryListerTest.java |   3 +-
 35 files changed, 1371 insertions(+), 184 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/AcidUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/AcidUtil.java
index 8c961808dca..721d7cc01ad 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/AcidUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/AcidUtil.java
@@ -22,7 +22,7 @@ import org.apache.doris.common.util.LocationPath;
 import org.apache.doris.datasource.hive.AcidInfo.DeleteDeltaInfo;
 import org.apache.doris.datasource.hive.HiveExternalMetaCache.FileCacheValue;
 import org.apache.doris.datasource.property.storage.StorageProperties;
-import org.apache.doris.fs.FileSystem;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.remote.RemoteFile;
 
 import lombok.EqualsAndHashCode;
@@ -132,7 +132,7 @@ public class AcidUtil {
     }
 
 
-    private static boolean isValidMetaDataFile(FileSystem fileSystem, String 
baseDir)
+    private static boolean isValidMetaDataFile(LegacyFileSystemApi fileSystem, 
String baseDir)
             throws IOException {
         String fileLocation = baseDir + "_metadata_acid";
         Status status = fileSystem.exists(fileLocation);
@@ -162,7 +162,7 @@ public class AcidUtil {
         return true;
     }
 
-    private static boolean isValidBase(FileSystem fileSystem, String baseDir,
+    private static boolean isValidBase(LegacyFileSystemApi fileSystem, String 
baseDir,
             ParsedBase base, ValidWriteIdList writeIdList) throws IOException {
         if (base.writeId == Long.MIN_VALUE) {
             //Ref: https://issues.apache.org/jira/browse/HIVE-13369
@@ -239,7 +239,7 @@ public class AcidUtil {
     //Since the hive3 library cannot read the hive4 transaction table 
normally, and there are many problems
     // when using the Hive 4 library directly, this method is implemented.
     //Ref: 
hive/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java#getAcidState
-    public static FileCacheValue getAcidState(FileSystem fileSystem, 
HivePartition partition,
+    public static FileCacheValue getAcidState(LegacyFileSystemApi fileSystem, 
HivePartition partition,
             Map<String, String> txnValidIds, Map<StorageProperties.Type, 
StorageProperties> storagePropertiesMap,
                                               boolean isFullAcid) throws 
Exception {
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSTransaction.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSTransaction.java
index dda3ae0c1d7..362658b2007 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSTransaction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSTransaction.java
@@ -28,9 +28,9 @@ import org.apache.doris.common.profile.SummaryProfile;
 import org.apache.doris.datasource.NameMapping;
 import org.apache.doris.datasource.statistics.CommonStatistics;
 import org.apache.doris.foundation.util.PathUtils;
-import org.apache.doris.fs.FileSystem;
 import org.apache.doris.fs.FileSystemProvider;
 import org.apache.doris.fs.FileSystemUtil;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.remote.MultipartUploadCapable;
 import org.apache.doris.fs.remote.RemoteFile;
 import org.apache.doris.fs.remote.S3FileSystem;
@@ -90,7 +90,7 @@ import java.util.stream.Collectors;
 public class HMSTransaction implements Transaction {
     private static final Logger LOG = 
LogManager.getLogger(HMSTransaction.class);
     private final HiveMetadataOps hiveOps;
-    private final FileSystem fs;
+    private final LegacyFileSystemApi fs;
     private Optional<SummaryProfile> summaryProfile = Optional.empty();
     private String queryId;
     private boolean isOverwrite = false;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateFileIO.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateFileIO.java
index 51568be3732..dd6fc5996ba 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateFileIO.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateFileIO.java
@@ -19,8 +19,8 @@ package org.apache.doris.datasource.iceberg.fileio;
 
 import org.apache.doris.backup.Status;
 import org.apache.doris.datasource.property.storage.StorageProperties;
-import org.apache.doris.fs.FileSystem;
 import org.apache.doris.fs.FileSystemFactory;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.io.ParsedPath;
 
 import com.google.common.collect.Iterables;
@@ -52,7 +52,7 @@ public class DelegateFileIO implements SupportsBulkOperations 
{
     /**
      * The underlying Doris file system used for file operations.
      */
-    private FileSystem fileSystem;
+    private LegacyFileSystemApi fileSystem;
 
     /**
      * Default constructor.
@@ -66,7 +66,7 @@ public class DelegateFileIO implements SupportsBulkOperations 
{
      *
      * @param fileSystem the Doris file system to delegate operations to
      */
-    public DelegateFileIO(FileSystem fileSystem) {
+    public DelegateFileIO(LegacyFileSystemApi fileSystem) {
         this.fileSystem = Objects.requireNonNull(fileSystem, "fileSystem is 
null");
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateOutputFile.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateOutputFile.java
index 23521a53cc6..fcf460fc70f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateOutputFile.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/fileio/DelegateOutputFile.java
@@ -17,7 +17,7 @@
 
 package org.apache.doris.datasource.iceberg.fileio;
 
-import org.apache.doris.fs.FileSystem;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.io.DorisOutputFile;
 import org.apache.doris.fs.io.ParsedPath;
 
@@ -40,7 +40,7 @@ public class DelegateOutputFile implements OutputFile {
     /**
      * The underlying Doris file system used for file operations.
      */
-    private final FileSystem fileSystem;
+    private final LegacyFileSystemApi fileSystem;
     /**
      * The DorisOutputFile instance representing the output file.
      */
@@ -52,7 +52,7 @@ public class DelegateOutputFile implements OutputFile {
      * @param fileSystem the Doris file system to delegate operations to
      * @param path the ParsedPath representing the file location
      */
-    public DelegateOutputFile(FileSystem fileSystem, ParsedPath path) {
+    public DelegateOutputFile(LegacyFileSystemApi fileSystem, ParsedPath path) 
{
         this.fileSystem = Objects.requireNonNull(fileSystem, "fileSystem is 
null");
         this.outputFile = fileSystem.newOutputFile(path);
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/DirectoryLister.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/DirectoryLister.java
index e97bc2c684f..660e66945ba 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/DirectoryLister.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/DirectoryLister.java
@@ -24,6 +24,6 @@ import org.apache.doris.catalog.TableIf;
 import org.apache.doris.fs.remote.RemoteFile;
 
 public interface DirectoryLister {
-    RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean recursive, 
TableIf table, String location)
+    RemoteIterator<RemoteFile> listFiles(LegacyFileSystemApi fs, boolean 
recursive, TableIf table, String location)
             throws FileSystemIOException;
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileEntry.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileEntry.java
new file mode 100644
index 00000000000..f76b783e1c4
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileEntry.java
@@ -0,0 +1,213 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Immutable record describing a file or directory in a storage system.
+ * <p>
+ * Replaces {@link org.apache.doris.fs.remote.RemoteFile} with zero Hadoop 
dependency.
+ * Block location information uses {@link BlockInfo} instead of {@code 
BlockLocation[]}.
+ */
+public final class FileEntry {
+
+    private final Location location;
+    private final boolean directory;
+    private final long length;
+    private final long blockSize;
+    private final long modificationTime;
+    private final List<BlockInfo> blocks;
+
+    private FileEntry(Builder builder) {
+        this.location = Objects.requireNonNull(builder.location, "location");
+        this.directory = builder.directory;
+        this.length = builder.length;
+        this.blockSize = builder.blockSize;
+        this.modificationTime = builder.modificationTime;
+        this.blocks = builder.blocks == null
+                ? Collections.emptyList()
+                : Collections.unmodifiableList(builder.blocks);
+    }
+
+    /** Full location (URI) of this file or directory. */
+    public Location location() {
+        return location;
+    }
+
+    /** Returns the last component of the path (file or directory name). */
+    public String name() {
+        return location.name();
+    }
+
+    public boolean isDirectory() {
+        return directory;
+    }
+
+    public boolean isFile() {
+        return !directory;
+    }
+
+    /** File size in bytes. -1 if unknown. */
+    public long length() {
+        return length;
+    }
+
+    /** Underlying block size of the storage (e.g., HDFS 128 MB). 0 for object 
storage. */
+    public long blockSize() {
+        return blockSize;
+    }
+
+    /** Last-modified time in milliseconds since epoch. */
+    public long modificationTime() {
+        return modificationTime;
+    }
+
+    /** Block location hints for split planning. Empty list for object 
storage. */
+    public List<BlockInfo> blocks() {
+        return blocks;
+    }
+
+    @Override
+    public String toString() {
+        return "FileEntry{location=" + location
+                + ", directory=" + directory
+                + ", length=" + length
+                + ", modificationTime=" + modificationTime + "}";
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof FileEntry)) {
+            return false;
+        }
+        FileEntry that = (FileEntry) o;
+        return directory == that.directory
+                && length == that.length
+                && modificationTime == that.modificationTime
+                && location.equals(that.location);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(location, directory, length, modificationTime);
+    }
+
+    public static Builder builder(Location location) {
+        return new Builder(location);
+    }
+
+    /** Convenience factory for simple file entries (no block info). */
+    public static FileEntry file(Location location, long length, long 
modificationTime) {
+        return 
builder(location).length(length).modificationTime(modificationTime).build();
+    }
+
+    /** Convenience factory for directory entries. */
+    public static FileEntry directory(Location location, long 
modificationTime) {
+        return 
builder(location).directory(true).modificationTime(modificationTime).build();
+    }
+
+    public static final class Builder {
+        private final Location location;
+        private boolean directory = false;
+        private long length = -1L;
+        private long blockSize = 0L;
+        private long modificationTime = 0L;
+        private List<BlockInfo> blocks;
+
+        private Builder(Location location) {
+            this.location = Objects.requireNonNull(location);
+        }
+
+        public Builder directory(boolean isDirectory) {
+            this.directory = isDirectory;
+            return this;
+        }
+
+        public Builder length(long fileLength) {
+            this.length = fileLength;
+            return this;
+        }
+
+        public Builder blockSize(long bSize) {
+            this.blockSize = bSize;
+            return this;
+        }
+
+        public Builder modificationTime(long modTime) {
+            this.modificationTime = modTime;
+            return this;
+        }
+
+        public Builder blocks(List<BlockInfo> blockList) {
+            this.blocks = blockList;
+            return this;
+        }
+
+        public Builder addBlock(BlockInfo block) {
+            if (this.blocks == null) {
+                this.blocks = new java.util.ArrayList<>();
+            }
+            this.blocks.add(block);
+            return this;
+        }
+
+        public FileEntry build() {
+            return new FileEntry(this);
+        }
+    }
+
+    /**
+     * Lightweight replacement for {@code org.apache.hadoop.fs.BlockLocation}.
+     * Contains only the data needed by Doris split planning.
+     */
+    public static final class BlockInfo {
+        private final long offset;
+        private final long length;
+        private final List<String> hosts;
+
+        public BlockInfo(long offset, long length, List<String> hosts) {
+            this.offset = offset;
+            this.length = length;
+            this.hosts = hosts == null ? Collections.emptyList() : 
Collections.unmodifiableList(hosts);
+        }
+
+        public long offset() {
+            return offset;
+        }
+
+        public long length() {
+            return length;
+        }
+
+        /** Data-local host names for this block (for scheduling affinity). */
+        public List<String> hosts() {
+            return hosts;
+        }
+
+        @Override
+        public String toString() {
+            return "BlockInfo{offset=" + offset + ", length=" + length + ", 
hosts=" + hosts + "}";
+        }
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileIterator.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileIterator.java
new file mode 100644
index 00000000000..78ca1fc869e
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileIterator.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * Lazy iterator over {@link FileEntry} objects in a directory listing.
+ * <p>
+ * Unlike {@link java.util.Iterator}, both {@link #hasNext()} and {@link 
#next()} may throw
+ * {@link IOException} since they may perform remote I/O (e.g., pagination 
requests).
+ * <p>
+ * Implementations must be {@link Closeable}. Always use in a 
try-with-resources block:
+ * <pre>
+ *   try (FileIterator it = fs.listFiles(location, false)) {
+ *       while (it.hasNext()) {
+ *           FileEntry entry = it.next();
+ *           // process entry
+ *       }
+ *   }
+ * </pre>
+ */
+public interface FileIterator extends Closeable {
+
+    /**
+     * Returns {@code true} if there are more entries to iterate.
+     *
+     * @throws IOException if an I/O error occurs while checking for more 
entries
+     */
+    boolean hasNext() throws IOException;
+
+    /**
+     * Returns the next {@link FileEntry}.
+     *
+     * @throws IOException            if an I/O error occurs while fetching 
the next entry
+     * @throws NoSuchElementException if there are no more entries
+     */
+    FileEntry next() throws IOException;
+
+    /**
+     * Releases any resources held by this iterator (e.g., HTTP connections).
+     * Idempotent — safe to call multiple times.
+     */
+    @Override
+    void close() throws IOException;
+
+    /**
+     * Drains the remaining entries into a list.
+     * Consumes the iterator; calling {@link #hasNext()} afterwards returns 
{@code false}.
+     */
+    default List<FileEntry> toList() throws IOException {
+        List<FileEntry> result = new ArrayList<>();
+        while (hasNext()) {
+            result.add(next());
+        }
+        return result;
+    }
+
+    /** Returns an empty iterator. */
+    static FileIterator empty() {
+        return new FileIterator() {
+            @Override
+            public boolean hasNext() {
+                return false;
+            }
+
+            @Override
+            public FileEntry next() {
+                throw new NoSuchElementException();
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+    /** Wraps a pre-built list as a FileIterator. Useful for testing and 
adapters. */
+    static FileIterator ofList(List<FileEntry> entries) {
+        return new FileIterator() {
+            private int index = 0;
+
+            @Override
+            public boolean hasNext() {
+                return index < entries.size();
+            }
+
+            @Override
+            public FileEntry next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
+                return entries.get(index++);
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java
index 81cdaf5d2a6..2404068a2ff 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java
@@ -17,131 +17,138 @@
 
 package org.apache.doris.fs;
 
-import org.apache.doris.backup.Status;
 import org.apache.doris.fs.io.DorisInputFile;
 import org.apache.doris.fs.io.DorisOutputFile;
-import org.apache.doris.fs.io.ParsedPath;
-import org.apache.doris.fs.remote.RemoteFile;
 
-import java.util.List;
-import java.util.Map;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Collection;
 import java.util.Set;
 
 /**
- * File system interface.
- * All file operations should use DFSFileSystem.
- * @see org.apache.doris.fs.remote.dfs.DFSFileSystem
- * If the file system use the object storage's SDK, use ObjStorage
- * @see org.apache.doris.fs.remote.ObjFileSystem
- * Read and Write operation put in FileOperations
- * @see org.apache.doris.fs.operations.FileOperations
+ * Core filesystem abstraction for Apache Doris.
+ * <p>
+ * All methods use {@link Location} for path arguments and throw {@link 
IOException}
+ * on failure rather than returning a {@link org.apache.doris.backup.Status} 
object.
+ * <p>
+ * Implementations must be thread-safe. Instances may be shared and cached.
+ *
+ * @see LegacyFileSystemAdapter for adapting existing Status-based 
implementations
+ * @see MemoryFileSystem for in-memory testing
+ * @see LegacyFileSystemApi for the legacy Status-based interface (deprecated)
  */
-public interface FileSystem {
-    Map<String, String> getProperties();
+public interface FileSystem extends Closeable {
 
-    Status exists(String remotePath);
+    // ─────────────────────────── I/O FILE ACCESS ───────────────────────────
 
-    default Status directoryExists(String dir) {
-        return exists(dir);
-    }
+    /**
+     * Creates a new {@link DorisInputFile} for reading from the given 
location.
+     * Does not check existence; the file is opened lazily when
+     * {@link DorisInputFile#newInput()} or {@link DorisInputFile#newStream()} 
is called.
+     */
+    DorisInputFile newInputFile(Location location);
 
-    Status downloadWithFileSize(String remoteFilePath, String localFilePath, 
long fileSize);
+    /**
+     * Creates a new {@link DorisInputFile} with a known file length.
+     * The {@code length} hint may be used to skip a remote {@code stat()} 
call.
+     */
+    DorisInputFile newInputFile(Location location, long length);
 
-    Status upload(String localPath, String remotePath);
+    /**
+     * Creates a new {@link DorisOutputFile} for writing to the given location.
+     */
+    DorisOutputFile newOutputFile(Location location);
 
-    Status directUpload(String content, String remoteFile);
+    // ─────────────────────────── METADATA OPERATIONS 
───────────────────────────
 
-    Status rename(String origFilePath, String destFilePath);
+    /**
+     * Returns {@code true} if the location exists (file or directory).
+     *
+     * @throws IOException if the existence check fails for a reason other 
than "not found"
+     */
+    boolean exists(Location location) throws IOException;
 
-    default Status renameDir(String origFilePath, String destFilePath) {
-        return renameDir(origFilePath, destFilePath, () -> {});
-    }
+    // ─────────────────────────── MUTATION OPERATIONS 
───────────────────────────
 
-    default Status renameDir(String origFilePath,
-                             String destFilePath,
-                             Runnable runWhenPathNotExist) {
-        throw new UnsupportedOperationException("Unsupported operation rename 
dir on current file system.");
-    }
+    /**
+     * Deletes the file at the given location.
+     *
+     * @throws IOException if deletion fails or the location is a directory
+     */
+    void deleteFile(Location location) throws IOException;
 
-    default Status deleteAll(List<String> remotePaths) {
-        for (String remotePath : remotePaths) {
-            Status deleteStatus = delete(remotePath);
-            if (!deleteStatus.ok()) {
-                return deleteStatus;
-            }
+    /**
+     * Deletes multiple files. Default implementation calls {@link 
#deleteFile} in a loop;
+     * implementations may override for batch efficiency.
+     */
+    default void deleteFiles(Collection<Location> locations) throws 
IOException {
+        for (Location location : locations) {
+            deleteFile(location);
         }
-        return Status.OK;
-    }
-
-    Status delete(String remotePath);
-
-    default Status deleteDirectory(String dir) {
-        return delete(dir);
     }
 
-    Status makeDir(String remotePath);
-
-    /*
-     * List files in remotePath
-     * @param remotePath remote path
-     * @param recursive whether to list files recursively
-     * <pre>
-     * If the path is a directory,
-     *   if recursive is false, returns files in the directory;
-     *   if recursive is true, return files in the subtree rooted at the path.
-     * If the path is a file, return the file's status and block locations.
-     * </pre>
-     * */
-    Status listFiles(String remotePath, boolean recursive, List<RemoteFile> 
result);
+    /**
+     * Atomically renames (moves) a file from {@code source} to {@code target}.
+     *
+     * @throws IOException if the rename fails
+     */
+    void renameFile(Location source, Location target) throws IOException;
 
     /**
-     * List files in remotePath by wildcard <br/>
-     * The {@link RemoteFile}'name will only contain file name (Not full path)
-     * @param remotePath remote path
-     * @param result All eligible files under the path
-     * @return
+     * Recursively deletes a directory and all its contents.
+     *
+     * @throws IOException if deletion fails
      */
-    default Status globList(String remotePath, List<RemoteFile> result) {
-        return globList(remotePath, result, true);
-    }
+    void deleteDirectory(Location location) throws IOException;
 
     /**
-     * List files in remotePath by wildcard <br/>
-     * @param remotePath remote path
-     * @param result All eligible files under the path
-     * @param fileNameOnly for {@link RemoteFile}'name: whether the full path 
is included.<br/>
-     *                     true: only contains file name, false: contains full 
path<br/>
-     * @return
+     * Creates a directory (and any missing parent directories).
+     *
+     * @throws IOException if creation fails
      */
-    Status globList(String remotePath, List<RemoteFile> result, boolean 
fileNameOnly);
+    void createDirectory(Location location) throws IOException;
 
     /**
-     * List files in remotePath <br/>
-     * @param remotePath remote path
-     * @param result All eligible files under the path
-     * @param startFile start file name
-     * @param fileSizeLimit limit the total size of files to be listed.
-     * @param fileNumLimit limit the total number of files to be listed.
-     * @return
+     * Renames (moves) a directory from {@code source} to {@code target}.
+     *
+     * @throws IOException if the rename fails
      */
-    default GlobListResult globListWithLimit(String remotePath, 
List<RemoteFile> result,
-            String startFile, long fileSizeLimit, long fileNumLimit) {
-        throw new UnsupportedOperationException("Unsupported operation glob 
list with limit on current file system.");
-    }
+    void renameDirectory(Location source, Location target) throws IOException;
 
-    default Status listDirectories(String remotePath, Set<String> result) {
-        throw new UnsupportedOperationException("Unsupported operation list 
directories on current file system.");
-    }
+    // ─────────────────────────── LISTING OPERATIONS 
───────────────────────────
 
-    default DorisOutputFile newOutputFile(ParsedPath path) {
-        throw new UnsupportedOperationException("Unsupported operation new 
output file on current file system.");
-    }
+    /**
+     * Returns a lazy iterator over files under {@code location}.
+     * <p>
+     * If {@code recursive} is {@code false}, only direct children are listed.
+     * If {@code recursive} is {@code true}, the entire subtree is traversed.
+     * The iterator must be closed after use (use try-with-resources).
+     *
+     * @throws IOException if the listing request fails
+     */
+    FileIterator listFiles(Location location, boolean recursive) throws 
IOException;
 
-    default DorisInputFile newInputFile(ParsedPath path) {
-        return newInputFile(path, -1);
-    }
+    /**
+     * Returns the set of direct child directory locations under {@code 
location}.
+     *
+     * @throws IOException if the listing request fails
+     */
+    Set<Location> listDirectories(Location location) throws IOException;
 
-    default DorisInputFile newInputFile(ParsedPath path, long length) {
-        throw new UnsupportedOperationException("Unsupported operation new 
input file on current file system.");
+    /**
+     * Returns a lazy iterator of files matching the glob {@code pattern}.
+     * Default implementation throws {@link UnsupportedOperationException}.
+     * Override for native glob support (e.g., HDFS glob).
+     */
+    default FileIterator globFiles(Location pattern) throws IOException {
+        throw new UnsupportedOperationException(
+                "globFiles not supported by " + getClass().getSimpleName());
     }
+
+    /**
+     * Releases resources held by this filesystem (connections, thread pools, 
etc.).
+     * Idempotent — safe to call multiple times.
+     */
+    @Override
+    void close() throws IOException;
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemDirectoryLister.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemDirectoryLister.java
index dcd7eeb16b3..95a46d44e55 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemDirectoryLister.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemDirectoryLister.java
@@ -25,7 +25,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class FileSystemDirectoryLister implements DirectoryLister {
-    public RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean 
recursive, TableIf table, String location)
+    public RemoteIterator<RemoteFile> listFiles(LegacyFileSystemApi fs, 
boolean recursive,
+            TableIf table, String location)
             throws FileSystemIOException {
         List<RemoteFile> result = new ArrayList<>();
         Status status = fs.listFiles(location, recursive, result);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemLookup.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemLookup.java
index 09f3a453ce4..0bd67143504 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemLookup.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemLookup.java
@@ -26,5 +26,5 @@ public interface FileSystemLookup {
      * Looks up and returns a cached FileSystem for the given key.
      * Creates a new instance if not cached.
      */
-    FileSystem lookup(FileSystemCache.FileSystemCacheKey key);
+    LegacyFileSystemApi lookup(FileSystemCache.FileSystemCacheKey key);
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProvider.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProvider.java
index aab7471fd99..1dd276fc12c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProvider.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProvider.java
@@ -20,5 +20,5 @@ package org.apache.doris.fs;
 import org.apache.doris.datasource.SessionContext;
 
 public interface FileSystemProvider {
-    FileSystem get(SessionContext ctx);
+    LegacyFileSystemApi get(SessionContext ctx);
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProviderImpl.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProviderImpl.java
index c9c2010dd1c..bd375add070 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProviderImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemProviderImpl.java
@@ -36,7 +36,7 @@ public class FileSystemProviderImpl implements 
FileSystemProvider {
     }
 
     @Override
-    public FileSystem get(SessionContext ctx) {
+    public LegacyFileSystemApi get(SessionContext ctx) {
         return new SwitchingFileSystem(
                 key -> extMetaCacheMgr.getFsCache().getRemoteFileSystem(key),
                 storagePropertiesMap);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemUtil.java
index 0d4c13c7651..4f13f1b1335 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemUtil.java
@@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 public class FileSystemUtil {
 
-    public static void asyncRenameFiles(FileSystem fs,
+    public static void asyncRenameFiles(LegacyFileSystemApi fs,
                                         Executor executor,
                                         List<CompletableFuture<?>> 
renameFileFutures,
                                         AtomicBoolean cancelled,
@@ -50,7 +50,7 @@ public class FileSystemUtil {
         }
     }
 
-    public static void asyncRenameDir(FileSystem fs,
+    public static void asyncRenameDir(LegacyFileSystemApi fs,
                                       Executor executor,
                                       List<CompletableFuture<?>> 
renameFileFutures,
                                       AtomicBoolean cancelled,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemAdapter.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemAdapter.java
new file mode 100644
index 00000000000..c3b53f44f43
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemAdapter.java
@@ -0,0 +1,221 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import org.apache.doris.backup.Status;
+import org.apache.doris.fs.io.DorisInputFile;
+import org.apache.doris.fs.io.DorisOutputFile;
+import org.apache.doris.fs.io.ParsedPath;
+import org.apache.doris.fs.remote.RemoteFile;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Bridge adapter that implements the new {@link FileSystem} interface by 
delegating
+ * to existing Status-based legacy methods.
+ * <p>
+ * Subclasses override the {@code legacy*()} methods (which have the old 
Status-based
+ * signatures) and gain the new IOException-based interface for free.
+ * <p>
+ * Migration path:
+ * <ol>
+ *   <li>Existing classes that extend {@link 
org.apache.doris.fs.remote.RemoteFileSystem}
+ *       (or its subclasses) should be gradually updated to extend this class 
instead.</li>
+ *   <li>In Phase 3, when {@code RemoteFileSystem} is removed, all subclasses 
will directly
+ *       extend this class and implement {@code legacy*()} methods.</li>
+ * </ol>
+ */
+public abstract class LegacyFileSystemAdapter implements FileSystem {
+
+    // ─────────────────────────── ABSTRACT LEGACY METHODS 
───────────────────────────
+
+    /** Checks file/directory existence. Returns {@link 
Status.ErrCode#NOT_FOUND} if absent. */
+    protected abstract Status legacyExists(String remotePath);
+
+    /** Deletes a file at {@code remotePath}. */
+    protected abstract Status legacyDelete(String remotePath);
+
+    /** Renames (moves) a file from {@code orig} to {@code dest}. */
+    protected abstract Status legacyRename(String orig, String dest);
+
+    /** Creates a directory at {@code remotePath} (including parents). */
+    protected abstract Status legacyMakeDir(String remotePath);
+
+    /**
+     * Lists files under {@code remotePath}.
+     * Results are appended to {@code result}.
+     */
+    protected abstract Status legacyListFiles(String remotePath, boolean 
recursive,
+                                               List<RemoteFile> result);
+
+    /**
+     * Lists immediate child directories under {@code remotePath}.
+     * Results are appended to {@code result}.
+     * Default implementation throws UnsupportedOperationException.
+     */
+    protected Status legacyListDirectories(String remotePath, Set<String> 
result) {
+        throw new UnsupportedOperationException(
+                "listDirectories not supported by " + 
getClass().getSimpleName());
+    }
+
+    /**
+     * Creates a new output file. Subclasses must implement.
+     */
+    protected abstract DorisOutputFile legacyNewOutputFile(ParsedPath path);
+
+    /** Creates a new input file with optional length hint (-1 = unknown). */
+    protected abstract DorisInputFile legacyNewInputFile(ParsedPath path, long 
length);
+
+    // ─────────────────────────── NEW INTERFACE IMPLEMENTATIONS 
───────────────────────────
+
+    @Override
+    public DorisInputFile newInputFile(Location location) {
+        return legacyNewInputFile(new ParsedPath(location.toString()), -1L);
+    }
+
+    @Override
+    public DorisInputFile newInputFile(Location location, long length) {
+        return legacyNewInputFile(new ParsedPath(location.toString()), length);
+    }
+
+    @Override
+    public DorisOutputFile newOutputFile(Location location) {
+        return legacyNewOutputFile(new ParsedPath(location.toString()));
+    }
+
+    @Override
+    public boolean exists(Location location) throws IOException {
+        Status status = legacyExists(location.toString());
+        if (status.ok()) {
+            return true;
+        }
+        if (Status.ErrCode.NOT_FOUND.equals(status.getErrCode())) {
+            return false;
+        }
+        throw new IOException("exists(" + location + ") failed: " + 
status.getErrMsg());
+    }
+
+    @Override
+    public void deleteFile(Location location) throws IOException {
+        Status status = legacyDelete(location.toString());
+        if (!status.ok()) {
+            throw new IOException("deleteFile(" + location + ") failed: " + 
status.getErrMsg());
+        }
+    }
+
+    @Override
+    public void renameFile(Location source, Location target) throws 
IOException {
+        Status status = legacyRename(source.toString(), target.toString());
+        if (!status.ok()) {
+            throw new IOException("renameFile(" + source + " -> " + target + 
") failed: "
+                    + status.getErrMsg());
+        }
+    }
+
+    @Override
+    public void deleteDirectory(Location location) throws IOException {
+        Status status = legacyDelete(location.toString());
+        if (!status.ok()) {
+            throw new IOException("deleteDirectory(" + location + ") failed: " 
+ status.getErrMsg());
+        }
+    }
+
+    @Override
+    public void createDirectory(Location location) throws IOException {
+        Status status = legacyMakeDir(location.toString());
+        if (!status.ok()) {
+            throw new IOException("createDirectory(" + location + ") failed: " 
+ status.getErrMsg());
+        }
+    }
+
+    @Override
+    public void renameDirectory(Location source, Location target) throws 
IOException {
+        Status status = legacyRename(source.toString(), target.toString());
+        if (!status.ok()) {
+            throw new IOException("renameDirectory(" + source + " -> " + 
target + ") failed: "
+                    + status.getErrMsg());
+        }
+    }
+
+    @Override
+    public FileIterator listFiles(Location location, boolean recursive) throws 
IOException {
+        List<RemoteFile> remoteFiles = new ArrayList<>();
+        Status status = legacyListFiles(location.toString(), recursive, 
remoteFiles);
+        if (!status.ok()) {
+            throw new IOException("listFiles(" + location + ") failed: " + 
status.getErrMsg());
+        }
+        String base = location.toString();
+        List<FileEntry> entries = remoteFiles.stream()
+                .map(rf -> convertRemoteFile(rf, base))
+                .collect(Collectors.toList());
+        return FileIterator.ofList(entries);
+    }
+
+    @Override
+    public Set<Location> listDirectories(Location location) throws IOException 
{
+        Set<String> dirs = new HashSet<>();
+        Status status = legacyListDirectories(location.toString(), dirs);
+        if (!status.ok()) {
+            throw new IOException("listDirectories(" + location + ") failed: " 
+ status.getErrMsg());
+        }
+        Set<Location> result = new HashSet<>(dirs.size() * 2);
+        for (String dir : dirs) {
+            result.add(Location.of(dir));
+        }
+        return result;
+    }
+
+    // ─────────────────────────── HELPERS ───────────────────────────
+
+    private static FileEntry convertRemoteFile(RemoteFile rf, String baseUri) {
+        org.apache.hadoop.fs.Path hadoopPath = rf.getPath();
+        Location loc = hadoopPath != null
+                ? Location.of(hadoopPath.toString())
+                : Location.of(baseUri.endsWith("/") ? baseUri + rf.getName()
+                                                     : baseUri + "/" + 
rf.getName());
+
+        FileEntry.Builder builder = FileEntry.builder(loc)
+                .directory(rf.isDirectory())
+                .length(rf.getSize())
+                .blockSize(rf.getBlockSize())
+                .modificationTime(rf.getModificationTime());
+
+        if (rf.getBlockLocations() != null) {
+            List<FileEntry.BlockInfo> blocks = new ArrayList<>();
+            for (org.apache.hadoop.fs.BlockLocation bl : 
rf.getBlockLocations()) {
+                try {
+                    String[] hostsArr = bl.getHosts();
+                    List<String> hosts = hostsArr != null
+                            ? java.util.Arrays.asList(hostsArr)
+                            : java.util.Collections.emptyList();
+                    blocks.add(new FileEntry.BlockInfo(bl.getOffset(), 
bl.getLength(), hosts));
+                } catch (IOException e) {
+                    blocks.add(new FileEntry.BlockInfo(bl.getOffset(), 
bl.getLength(),
+                            java.util.Collections.emptyList()));
+                }
+            }
+            builder.blocks(blocks);
+        }
+        return builder.build();
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemApi.java
similarity index 93%
copy from fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java
copy to fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemApi.java
index 81cdaf5d2a6..eea9fc65d63 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyFileSystemApi.java
@@ -28,15 +28,14 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * File system interface.
- * All file operations should use DFSFileSystem.
- * @see org.apache.doris.fs.remote.dfs.DFSFileSystem
- * If the file system use the object storage's SDK, use ObjStorage
- * @see org.apache.doris.fs.remote.ObjFileSystem
- * Read and Write operation put in FileOperations
- * @see org.apache.doris.fs.operations.FileOperations
+ * Legacy file system interface using {@link Status}-based error reporting.
+ *
+ * @deprecated Use {@link FileSystem} instead. This interface will be removed 
in Phase 3
+ *             of the filesystem SPI refactoring. New code should implement or 
consume
+ *             the IOException-based {@link FileSystem} interface.
  */
-public interface FileSystem {
+@Deprecated
+public interface LegacyFileSystemApi {
     Map<String, String> getProperties();
 
     Status exists(String remotePath);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyToNewFsAdapter.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyToNewFsAdapter.java
new file mode 100644
index 00000000000..cf1e7e3b540
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/LegacyToNewFsAdapter.java
@@ -0,0 +1,92 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import org.apache.doris.backup.Status;
+import org.apache.doris.fs.io.DorisInputFile;
+import org.apache.doris.fs.io.DorisOutputFile;
+import org.apache.doris.fs.io.ParsedPath;
+import org.apache.doris.fs.remote.RemoteFile;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Adapts any old-style {@link LegacyFileSystemApi} implementation to the new
+ * {@link FileSystem} interface via {@link LegacyFileSystemAdapter}.
+ * <p>
+ * This avoids modifying existing class hierarchies in Phase 1.
+ * In Phase 3, when RemoteFileSystem is removed, direct subclassing of
+ * LegacyFileSystemAdapter will replace this adapter.
+ */
+public final class LegacyToNewFsAdapter extends LegacyFileSystemAdapter {
+
+    private final LegacyFileSystemApi delegate;
+
+    public LegacyToNewFsAdapter(LegacyFileSystemApi delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected Status legacyExists(String remotePath) {
+        return delegate.exists(remotePath);
+    }
+
+    @Override
+    protected Status legacyDelete(String remotePath) {
+        return delegate.delete(remotePath);
+    }
+
+    @Override
+    protected Status legacyRename(String orig, String dest) {
+        return delegate.rename(orig, dest);
+    }
+
+    @Override
+    protected Status legacyMakeDir(String remotePath) {
+        return delegate.makeDir(remotePath);
+    }
+
+    @Override
+    protected Status legacyListFiles(String remotePath, boolean recursive, 
List<RemoteFile> result) {
+        return delegate.listFiles(remotePath, recursive, result);
+    }
+
+    @Override
+    protected Status legacyListDirectories(String remotePath, Set<String> 
result) {
+        return delegate.listDirectories(remotePath, result);
+    }
+
+    @Override
+    protected DorisOutputFile legacyNewOutputFile(ParsedPath path) {
+        return delegate.newOutputFile(path);
+    }
+
+    @Override
+    protected DorisInputFile legacyNewInputFile(ParsedPath path, long length) {
+        return delegate.newInputFile(path, length);
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (delegate instanceof java.io.Closeable) {
+            ((java.io.Closeable) delegate).close();
+        }
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/LocalDfsFileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/LocalDfsFileSystem.java
index 93e79bf94b1..20277bb25be 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/LocalDfsFileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/LocalDfsFileSystem.java
@@ -36,7 +36,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-public class LocalDfsFileSystem implements FileSystem {
+public class LocalDfsFileSystem implements LegacyFileSystemApi {
 
     public LocalFileSystem fs = LocalFileSystem.getLocal(new Configuration());
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/Location.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/Location.java
new file mode 100644
index 00000000000..de2e38e694f
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/Location.java
@@ -0,0 +1,169 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Objects;
+
+/**
+ * Immutable value object representing a storage location (URI).
+ * <p>
+ * Replaces bare {@code String} path parameters and the thin {@link 
org.apache.doris.fs.io.ParsedPath}
+ * wrapper throughout the filesystem API. Does NOT include StorageProperties 
lookup logic
+ * (that remains in {@link org.apache.doris.common.util.LocationPath}).
+ * <p>
+ * Examples:
+ * <pre>
+ *   Location loc = Location.of("s3://my-bucket/path/to/file.parquet");
+ *   loc.scheme()    // "s3"
+ *   loc.authority() // "my-bucket"
+ *   loc.path()      // "/path/to/file.parquet"
+ *
+ *   Location child = loc.parent().resolve("other.parquet");
+ *   // s3://my-bucket/path/to/other.parquet
+ * </pre>
+ */
+public final class Location {
+
+    private final String location;
+
+    // Lazily parsed URI — avoids URI parsing cost for hot paths that only 
need toString()
+    private volatile URI parsedUri;
+
+    private Location(String location) {
+        Objects.requireNonNull(location, "location must not be null");
+        if (location.isEmpty()) {
+            throw new IllegalArgumentException("location must not be empty");
+        }
+        this.location = location;
+    }
+
+    /**
+     * Creates a Location from a raw URI string.
+     *
+     * @throws IllegalArgumentException if the string is null, empty, or 
malformed
+     */
+    public static Location of(String location) {
+        return new Location(location);
+    }
+
+    /** URI scheme, e.g., "s3", "hdfs", "file". Returns empty string if no 
scheme. */
+    public String scheme() {
+        URI uri = ensureParsed();
+        String s = uri.getScheme();
+        return s == null ? "" : s;
+    }
+
+    /** URI authority (host + optional port), e.g., "bucket-name" or 
"namenode:8020". */
+    public String authority() {
+        URI uri = ensureParsed();
+        String a = uri.getAuthority();
+        return a == null ? "" : a;
+    }
+
+    /** The path component of the URI, e.g., "/warehouse/db/table". */
+    public String path() {
+        return ensureParsed().getPath();
+    }
+
+    /**
+     * Returns the parent location (directory containing this location).
+     * <p>
+     * e.g., {@code s3://bucket/a/b/c} → {@code s3://bucket/a/b}
+     */
+    public Location parent() {
+        URI uri = ensureParsed();
+        String rawPath = uri.getRawPath();
+        if (rawPath == null || rawPath.isEmpty() || rawPath.equals("/")) {
+            throw new IllegalStateException("Location has no parent: " + 
location);
+        }
+        // Strip trailing slash before finding last separator
+        String normalized = rawPath.endsWith("/") ? rawPath.substring(0, 
rawPath.length() - 1) : rawPath;
+        int lastSlash = normalized.lastIndexOf('/');
+        String parentPath = lastSlash <= 0 ? "/" : normalized.substring(0, 
lastSlash);
+        try {
+            URI parentUri = new URI(uri.getScheme(), uri.getAuthority(), 
parentPath, null, null);
+            return new Location(parentUri.toString());
+        } catch (URISyntaxException e) {
+            throw new IllegalStateException("Cannot compute parent of: " + 
location, e);
+        }
+    }
+
+    /**
+     * Appends a relative path segment to this location, returning a new child 
Location.
+     * <p>
+     * e.g., {@code Location.of("s3://bucket/a").resolve("b/c")} → {@code 
s3://bucket/a/b/c}
+     */
+    public Location resolve(String relativePath) {
+        Objects.requireNonNull(relativePath, "relativePath must not be null");
+        String base = location.endsWith("/") ? location : location + "/";
+        String child = relativePath.startsWith("/") ? 
relativePath.substring(1) : relativePath;
+        return new Location(base + child);
+    }
+
+    /**
+     * Returns the last path component (filename or directory name).
+     */
+    public String name() {
+        String p = path();
+        if (p.isEmpty() || p.equals("/")) {
+            return authority(); // root: use authority as name
+        }
+        String trimmed = p.endsWith("/") ? p.substring(0, p.length() - 1) : p;
+        int lastSlash = trimmed.lastIndexOf('/');
+        return lastSlash < 0 ? trimmed : trimmed.substring(lastSlash + 1);
+    }
+
+    /** The original location string as provided. */
+    @Override
+    public String toString() {
+        return location;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof Location)) {
+            return false;
+        }
+        return location.equals(((Location) o).location);
+    }
+
+    @Override
+    public int hashCode() {
+        return location.hashCode();
+    }
+
+    private URI ensureParsed() {
+        if (parsedUri == null) {
+            synchronized (this) {
+                if (parsedUri == null) {
+                    try {
+                        parsedUri = new URI(location);
+                    } catch (URISyntaxException e) {
+                        throw new IllegalArgumentException("Invalid location 
URI: " + location, e);
+                    }
+                }
+            }
+        }
+        return parsedUri;
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/MemoryFileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/MemoryFileSystem.java
new file mode 100644
index 00000000000..9720b8f7825
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/MemoryFileSystem.java
@@ -0,0 +1,263 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.fs;
+
+import org.apache.doris.fs.io.DorisInput;
+import org.apache.doris.fs.io.DorisInputFile;
+import org.apache.doris.fs.io.DorisInputStream;
+import org.apache.doris.fs.io.DorisOutputFile;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+
+/**
+ * In-memory {@link FileSystem} implementation for unit testing.
+ * <p>
+ * File data is stored in a {@link ConcurrentHashMap}. Directories are implicit
+ * (any Location whose path ends with "/" is treated as a directory).
+ * Thread-safe for concurrent read/write operations.
+ */
+public class MemoryFileSystem implements FileSystem {
+
+    // Maps location string → file bytes (null entry = directory marker)
+    private final ConcurrentHashMap<String, byte[]> store = new 
ConcurrentHashMap<>();
+
+    @Override
+    public DorisInputFile newInputFile(Location location) {
+        return newInputFile(location, -1L);
+    }
+
+    @Override
+    public DorisInputFile newInputFile(Location location, long length) {
+        return new MemoryInputFile(location, length);
+    }
+
+    @Override
+    public DorisOutputFile newOutputFile(Location location) {
+        return new MemoryOutputFile(location);
+    }
+
+    @Override
+    public boolean exists(Location location) {
+        String key = location.toString();
+        if (store.containsKey(key)) {
+            return true;
+        }
+        String prefix = key.endsWith("/") ? key : key + "/";
+        return store.keySet().stream().anyMatch(k -> k.startsWith(prefix));
+    }
+
+    @Override
+    public void deleteFile(Location location) throws IOException {
+        String key = location.toString();
+        if (store.remove(key) == null) {
+            throw new IOException("File not found: " + location);
+        }
+    }
+
+    @Override
+    public void renameFile(Location source, Location target) throws 
IOException {
+        byte[] data = store.remove(source.toString());
+        if (data == null) {
+            throw new IOException("Source not found: " + source);
+        }
+        store.put(target.toString(), data);
+    }
+
+    @Override
+    public void deleteDirectory(Location location) throws IOException {
+        String prefix = location.toString();
+        String withSlash = prefix.endsWith("/") ? prefix : prefix + "/";
+        store.keySet().removeIf(k -> k.equals(prefix) || 
k.startsWith(withSlash));
+    }
+
+    @Override
+    public void createDirectory(Location location) {
+        store.putIfAbsent(location.toString() + "/", new byte[0]);
+    }
+
+    @Override
+    public void renameDirectory(Location source, Location target) throws 
IOException {
+        String srcPrefix = source.toString();
+        String dstPrefix = target.toString();
+        Map<String, byte[]> toMove = store.entrySet().stream()
+                .filter(e -> e.getKey().startsWith(srcPrefix))
+                .collect(Collectors.toMap(
+                        e -> dstPrefix + 
e.getKey().substring(srcPrefix.length()),
+                        Map.Entry::getValue));
+        if (toMove.isEmpty()) {
+            throw new IOException("Source directory not found: " + source);
+        }
+        store.keySet().removeIf(k -> k.startsWith(srcPrefix));
+        store.putAll(toMove);
+    }
+
+    @Override
+    public FileIterator listFiles(Location location, boolean recursive) {
+        String prefix = location.toString();
+        String withSlash = prefix.endsWith("/") ? prefix : prefix + "/";
+        List<FileEntry> entries = store.keySet().stream()
+                .filter(k -> k.startsWith(withSlash) && !k.equals(withSlash))
+                .filter(k -> {
+                    if (recursive) {
+                        return true;
+                    }
+                    String relative = k.substring(withSlash.length());
+                    return !relative.contains("/") || relative.endsWith("/");
+                })
+                .map(k -> {
+                    Location loc = Location.of(k);
+                    byte[] data = store.get(k);
+                    return FileEntry.builder(loc)
+                            .directory(k.endsWith("/"))
+                            .length(data == null ? 0 : data.length)
+                            .build();
+                })
+                .collect(Collectors.toList());
+        return FileIterator.ofList(entries);
+    }
+
+    @Override
+    public Set<Location> listDirectories(Location location) {
+        String prefix = location.toString();
+        String withSlash = prefix.endsWith("/") ? prefix : prefix + "/";
+        Set<Location> dirs = new HashSet<>();
+        for (String key : store.keySet()) {
+            if (!key.startsWith(withSlash)) {
+                continue;
+            }
+            String relative = key.substring(withSlash.length());
+            int slash = relative.indexOf('/');
+            if (slash >= 0) {
+                dirs.add(Location.of(withSlash + relative.substring(0, slash + 
1)));
+            }
+        }
+        return Collections.unmodifiableSet(dirs);
+    }
+
+    @Override
+    public void close() {
+        // No-op: in-memory, nothing to release
+    }
+
+    /** Writes data directly into this filesystem (test helper). */
+    public void put(Location location, byte[] data) {
+        store.put(location.toString(), data);
+    }
+
+    /** Reads raw bytes from this filesystem (test helper). */
+    public byte[] get(Location location) {
+        return store.get(location.toString());
+    }
+
+    private class MemoryInputFile implements DorisInputFile {
+        private final Location location;
+        private final long knownLength;
+
+        MemoryInputFile(Location location, long knownLength) {
+            this.location = location;
+            this.knownLength = knownLength;
+        }
+
+        @Override
+        public Location location() {
+            return location;
+        }
+
+        @Override
+        public long length() throws IOException {
+            if (knownLength >= 0) {
+                return knownLength;
+            }
+            byte[] data = store.get(location.toString());
+            if (data == null) {
+                throw new IOException("File not found: " + location);
+            }
+            return data.length;
+        }
+
+        @Override
+        public long lastModifiedTime() {
+            return 0L;
+        }
+
+        @Override
+        public boolean exists() {
+            return store.containsKey(location.toString());
+        }
+
+        @Override
+        public DorisInput newInput() throws IOException {
+            throw new UnsupportedOperationException("Use newStream() for 
MemoryFileSystem");
+        }
+
+        @Override
+        public DorisInputStream newStream() throws IOException {
+            byte[] data = store.get(location.toString());
+            if (data == null) {
+                throw new IOException("File not found: " + location);
+            }
+            throw new UnsupportedOperationException(
+                    "MemoryFileSystem.newStream() requires DorisInputStream 
wrapper — implement in Phase 2");
+        }
+    }
+
+    private class MemoryOutputFile implements DorisOutputFile {
+        private final Location location;
+
+        MemoryOutputFile(Location location) {
+            this.location = location;
+        }
+
+        @Override
+        public Location location() {
+            return location;
+        }
+
+        @Override
+        public OutputStream create() throws IOException {
+            if (store.containsKey(location.toString())) {
+                throw new IOException("File already exists: " + location);
+            }
+            return buildStream();
+        }
+
+        @Override
+        public OutputStream createOrOverwrite() {
+            return buildStream();
+        }
+
+        private OutputStream buildStream() {
+            return new ByteArrayOutputStream() {
+                @Override
+                public void close() throws IOException {
+                    super.close();
+                    store.put(location.toString(), toByteArray());
+                }
+            };
+        }
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/PersistentFileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/PersistentFileSystem.java
index 86981b559b9..472dc0000ab 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/PersistentFileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/PersistentFileSystem.java
@@ -29,7 +29,7 @@ import java.util.Map;
 /**
  * Use for persistence, Repository will persist properties of file system.
  */
-public abstract class PersistentFileSystem implements FileSystem {
+public abstract class PersistentFileSystem implements LegacyFileSystemApi {
     public static final String STORAGE_TYPE = "_DORIS_STORAGE_TYPE_";
     @SerializedName("prop")
     public Map<String, String> properties = Maps.newHashMap();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFileRemoteIterator.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFileRemoteIterator.java
index 6ac8eb3b0c6..e67cf7d3157 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFileRemoteIterator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFileRemoteIterator.java
@@ -23,6 +23,10 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Objects;
 
+/**
+ * @deprecated use {@link FileIterator} instead
+ */
+@Deprecated
 public class RemoteFileRemoteIterator
         implements RemoteIterator<RemoteFile> {
     private final List<RemoteFile> remoteFileList;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFiles.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFiles.java
index 761d988652f..a5ba09e5b28 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFiles.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFiles.java
@@ -21,6 +21,10 @@ import org.apache.doris.fs.remote.RemoteFile;
 
 import java.util.List;
 
+/**
+ * @deprecated use {@link FileIterator} instead
+ */
+@Deprecated
 public class RemoteFiles {
 
     private final List<RemoteFile> files;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/TransactionScopeCachingDirectoryLister.java
 
b/fe/fe-core/src/main/java/org/apache/doris/fs/TransactionScopeCachingDirectoryLister.java
index a6e141e4a81..11a9062f2d0 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/fs/TransactionScopeCachingDirectoryLister.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/fs/TransactionScopeCachingDirectoryLister.java
@@ -68,12 +68,13 @@ public class TransactionScopeCachingDirectoryLister 
implements DirectoryLister {
     }
 
     @Override
-    public RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean 
recursive, TableIf table, String location)
+    public RemoteIterator<RemoteFile> listFiles(LegacyFileSystemApi fs, 
boolean recursive,
+            TableIf table, String location)
             throws FileSystemIOException {
         return listInternal(fs, recursive, table, new 
TransactionDirectoryListingCacheKey(transactionId, location));
     }
 
-    private RemoteIterator<RemoteFile> listInternal(FileSystem fs, boolean 
recursive, TableIf table,
+    private RemoteIterator<RemoteFile> listInternal(LegacyFileSystemApi fs, 
boolean recursive, TableIf table,
                                                     
TransactionDirectoryListingCacheKey cacheKey)
             throws FileSystemIOException {
         FetchingValueHolder cachedValueHolder;
@@ -94,7 +95,7 @@ public class TransactionScopeCachingDirectoryLister 
implements DirectoryLister {
         return cachingRemoteIterator(cachedValueHolder, cacheKey);
     }
 
-    private RemoteIterator<RemoteFile> createListingRemoteIterator(FileSystem 
fs, boolean recursive,
+    private RemoteIterator<RemoteFile> 
createListingRemoteIterator(LegacyFileSystemApi fs, boolean recursive,
                                                                    TableIf 
table,
                                                                    
TransactionDirectoryListingCacheKey cacheKey)
             throws FileSystemIOException {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisInputFile.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisInputFile.java
index 5a7f003b6ed..e34739c1c28 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisInputFile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisInputFile.java
@@ -17,6 +17,8 @@
 
 package org.apache.doris.fs.io;
 
+import org.apache.doris.fs.Location;
+
 import java.io.IOException;
 
 /**
@@ -26,12 +28,22 @@ import java.io.IOException;
  * Implementations of this interface allow Doris to interact with various file 
systems in a unified way.
  */
 public interface DorisInputFile {
+    /**
+     * Returns the location of this file.
+     * Replaces the old {@link #path()} method.
+     */
+    Location location();
+
     /**
      * Returns the path of this file as a ParsedPath object.
      *
      * @return the ParsedPath representing the file location
+     * @deprecated use {@link #location()} instead
      */
-    ParsedPath path();
+    @Deprecated
+    default ParsedPath path() {
+        return new ParsedPath(location().toString());
+    }
 
     /**
      * Returns the length of the file in bytes.
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisOutputFile.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisOutputFile.java
index 0c23344637c..a5f3e84a047 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisOutputFile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/DorisOutputFile.java
@@ -17,6 +17,8 @@
 
 package org.apache.doris.fs.io;
 
+import org.apache.doris.fs.Location;
+
 import java.io.IOException;
 import java.io.OutputStream;
 
@@ -25,7 +27,7 @@ import java.io.OutputStream;
  * <p>
  * This interface provides methods to create output streams for writing file 
content,
  * either as a new file or by overwriting an existing file.
- * It also provides a method to retrieve the file's path.
+ * It also provides a method to retrieve the file's location.
  * Implementations of this interface allow Doris to interact with various file 
systems
  * in a unified way for output operations.
  */
@@ -50,10 +52,20 @@ public interface DorisOutputFile {
      */
     OutputStream createOrOverwrite() throws IOException;
 
+    /**
+     * Returns the location of this output file.
+     * Replaces the old {@link #path()} method.
+     */
+    Location location();
+
     /**
      * Returns the path of this output file as a ParsedPath object.
      *
      * @return the ParsedPath representing the file location
+     * @deprecated use {@link #location()} instead
      */
-    ParsedPath path();
+    @Deprecated
+    default ParsedPath path() {
+        return new ParsedPath(location().toString());
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/io/ParsedPath.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/ParsedPath.java
index 98b9c4017b7..6741efcb396 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/ParsedPath.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/ParsedPath.java
@@ -17,12 +17,16 @@
 
 package org.apache.doris.fs.io;
 
+import org.apache.doris.fs.Location;
+
 import org.apache.hadoop.fs.Path;
 
 /**
- * This is temporary class to isolate the path parsing logic from the rest of 
the codebase.
- * Maybe refactored later
+ * This is a temporary class to isolate the path parsing logic from the rest 
of the codebase.
+ *
+ * @deprecated use {@link Location} instead
  */
+@Deprecated
 public class ParsedPath {
     private String origPath;
 
@@ -38,4 +42,11 @@ public class ParsedPath {
     public Path toHadoopPath() {
         return new Path(origPath);
     }
+
+    /**
+     * Converts this ParsedPath to the new {@link Location} value type.
+     */
+    public Location toLocation() {
+        return Location.of(origPath);
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputFile.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputFile.java
index 050beae4769..03c6de985e8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputFile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputFile.java
@@ -18,10 +18,10 @@
 package org.apache.doris.fs.io.hdfs;
 
 import org.apache.doris.backup.Status;
+import org.apache.doris.fs.Location;
 import org.apache.doris.fs.io.DorisInput;
 import org.apache.doris.fs.io.DorisInputFile;
 import org.apache.doris.fs.io.DorisInputStream;
-import org.apache.doris.fs.io.ParsedPath;
 import org.apache.doris.fs.remote.dfs.DFSFileSystem;
 
 import org.apache.hadoop.fs.FileStatus;
@@ -32,11 +32,11 @@ import java.util.Objects;
 
 /**
  * HdfsInputFile provides an implementation of DorisInputFile for reading data 
from HDFS.
- * It wraps a ParsedPath and DFSFileSystem to open files and retrieve file 
metadata from HDFS.
+ * It wraps a Location and DFSFileSystem to open files and retrieve file 
metadata from HDFS.
  */
 public class HdfsInputFile implements DorisInputFile {
-    // The ParsedPath representing the file location in HDFS.
-    private final ParsedPath path;
+    // The Location representing the file location in HDFS.
+    private final Location location;
     // The Hadoop Path object corresponding to the file.
     private final Path hadoopPath;
     // The DFSFileSystem used to interact with HDFS.
@@ -48,16 +48,16 @@ public class HdfsInputFile implements DorisInputFile {
     private FileStatus status;
 
     /**
-     * Constructs a HdfsInputFile with the given ParsedPath, file length, and 
DFSFileSystem.
+     * Constructs a HdfsInputFile with the given Location, file length, and 
DFSFileSystem.
      *
-     * @param path the ParsedPath representing the file location
+     * @param location the Location representing the file location
      * @param length the length of the file, or -1 if unknown
      * @param dfs the DFSFileSystem used to interact with HDFS
      */
-    public HdfsInputFile(ParsedPath path, long length, DFSFileSystem dfs) {
-        this.path = Objects.requireNonNull(path, "path is null");
+    public HdfsInputFile(Location location, long length, DFSFileSystem dfs) {
+        this.location = Objects.requireNonNull(location, "location is null");
         this.dfs = Objects.requireNonNull(dfs, "hdfs file system is null");
-        this.hadoopPath = path.toHadoopPath();
+        this.hadoopPath = new Path(location.toString());
         this.length = length;
     }
 
@@ -80,7 +80,7 @@ public class HdfsInputFile implements DorisInputFile {
      */
     @Override
     public DorisInputStream newStream() throws IOException {
-        return new HdfsInputStream(path, dfs.openFile(hadoopPath));
+        return new HdfsInputStream(location.toString(), 
dfs.openFile(hadoopPath));
     }
 
     /**
@@ -116,18 +116,18 @@ public class HdfsInputFile implements DorisInputFile {
      */
     @Override
     public boolean exists() throws IOException {
-        Status status = dfs.exists(path.toString());
-        return status.ok();
+        Status existsStatus = dfs.exists(location.toString());
+        return existsStatus.ok();
     }
 
     /**
-     * Returns the ParsedPath associated with this input file.
+     * Returns the Location associated with this input file.
      *
-     * @return the ParsedPath
+     * @return the Location
      */
     @Override
-    public ParsedPath path() {
-        return path;
+    public Location location() {
+        return location;
     }
 
     /**
@@ -137,7 +137,7 @@ public class HdfsInputFile implements DorisInputFile {
      */
     @Override
     public String toString() {
-        return path().toString();
+        return location.toString();
     }
 
     /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputStream.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputStream.java
index 19d4d3510a2..48ab5ffb035 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputStream.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsInputStream.java
@@ -18,7 +18,6 @@
 package org.apache.doris.fs.io.hdfs;
 
 import org.apache.doris.fs.io.DorisInputStream;
-import org.apache.doris.fs.io.ParsedPath;
 
 import org.apache.hadoop.fs.FSDataInputStream;
 
@@ -28,24 +27,24 @@ import java.util.Objects;
 
 /**
  * HdfsInputStream provides an input stream implementation for reading data 
from HDFS
- * using ParsedPath and FSDataInputStream.
+ * using a path string and FSDataInputStream.
  * It extends DorisInputStream and wraps Hadoop's FSDataInputStream, providing 
additional checks and error handling.
  */
 public class HdfsInputStream extends DorisInputStream {
-    // The ParsedPath representing the file location in HDFS.
-    private final ParsedPath path;
+    // The file path string for error reporting.
+    private final String path;
     // The underlying Hadoop FSDataInputStream used for reading.
     private final FSDataInputStream stream;
     // Indicates whether the stream has been closed.
     private boolean closed;
 
     /**
-     * Constructs a HdfsInputStream with the given ParsedPath and 
FSDataInputStream.
+     * Constructs a HdfsInputStream with the given path string and 
FSDataInputStream.
      *
-     * @param path the ParsedPath representing the file location
+     * @param path the file path string for error reporting
      * @param stream the underlying Hadoop FSDataInputStream
      */
-    HdfsInputStream(ParsedPath path, FSDataInputStream stream) {
+    HdfsInputStream(String path, FSDataInputStream stream) {
         this.path = Objects.requireNonNull(path, "path is null");
         this.stream = Objects.requireNonNull(stream, "stream is null");
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsOutputFile.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsOutputFile.java
index 4fb9e526686..2d0d3233260 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsOutputFile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/io/hdfs/HdfsOutputFile.java
@@ -17,8 +17,8 @@
 
 package org.apache.doris.fs.io.hdfs;
 
+import org.apache.doris.fs.Location;
 import org.apache.doris.fs.io.DorisOutputFile;
-import org.apache.doris.fs.io.ParsedPath;
 import org.apache.doris.fs.remote.dfs.DFSFileSystem;
 
 import org.apache.hadoop.fs.Path;
@@ -29,25 +29,25 @@ import java.util.Objects;
 
 /**
  * HdfsOutputFile provides an implementation of DorisOutputFile for writing 
data to HDFS.
- * It wraps a ParsedPath and DFSFileSystem to create or overwrite files in 
HDFS.
+ * It wraps a Location and DFSFileSystem to create or overwrite files in HDFS.
  */
 public class HdfsOutputFile implements DorisOutputFile {
-    // The ParsedPath representing the file location in HDFS.
-    private final ParsedPath path;
+    // The Location representing the file location in HDFS.
+    private final Location location;
     // The Hadoop Path object corresponding to the file.
     private final Path hadoopPath;
     // The DFSFileSystem used to interact with HDFS.
     private final DFSFileSystem dfs;
 
     /**
-     * Constructs a HdfsOutputFile with the given ParsedPath and DFSFileSystem.
+     * Constructs a HdfsOutputFile with the given Location and DFSFileSystem.
      *
-     * @param path the ParsedPath representing the file location
+     * @param location the Location representing the file location
      * @param dfs the DFSFileSystem used to interact with HDFS
      */
-    public HdfsOutputFile(ParsedPath path, DFSFileSystem dfs) {
-        this.path = Objects.requireNonNull(path, "path is null");
-        this.hadoopPath = path.toHadoopPath();
+    public HdfsOutputFile(Location location, DFSFileSystem dfs) {
+        this.location = Objects.requireNonNull(location, "location is null");
+        this.hadoopPath = new Path(location.toString());
         this.dfs = Objects.requireNonNull(dfs, "dfs is null");
     }
 
@@ -74,13 +74,13 @@ public class HdfsOutputFile implements DorisOutputFile {
     }
 
     /**
-     * Returns the ParsedPath associated with this output file.
+     * Returns the Location associated with this output file.
      *
-     * @return the ParsedPath
+     * @return the Location
      */
     @Override
-    public ParsedPath path() {
-        return path;
+    public Location location() {
+        return location;
     }
 
     /**
@@ -90,6 +90,6 @@ public class HdfsOutputFile implements DorisOutputFile {
      */
     @Override
     public String toString() {
-        return path().toString();
+        return location.toString();
     }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/RemoteFile.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/RemoteFile.java
index 1f6f0225278..d7f9e9dfa9e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/RemoteFile.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/RemoteFile.java
@@ -17,11 +17,20 @@
 
 package org.apache.doris.fs.remote;
 
+import org.apache.doris.fs.FileEntry;
+import org.apache.doris.fs.Location;
+
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import org.apache.hadoop.fs.BlockLocation;
 import org.apache.hadoop.fs.Path;
 
+/**
+ * Represents a file or directory in remote storage.
+ *
+ * @deprecated use {@link FileEntry} instead, which has no Hadoop dependency
+ */
+@Deprecated
 // represent a file or a dir in remote storage
 public class RemoteFile {
     // Only file name, not full path
@@ -99,6 +108,54 @@ public class RemoteFile {
         return blockLocations;
     }
 
+    /**
+     * Converts this RemoteFile to a {@link FileEntry}.
+     *
+     * @return a new FileEntry representing the same file metadata
+     */
+    public FileEntry toFileEntry() {
+        FileEntry.Builder builder = FileEntry.builder(
+                        path != null ? Location.of(path.toString()) : 
Location.of(name))
+                .directory(isDirectory)
+                .length(size)
+                .blockSize(blockSize)
+                .modificationTime(modificationTime);
+        if (blockLocations != null) {
+            for (BlockLocation bl : blockLocations) {
+                try {
+                    builder.addBlock(new FileEntry.BlockInfo(
+                            bl.getOffset(), bl.getLength(), 
java.util.Arrays.asList(bl.getHosts())));
+                } catch (java.io.IOException e) {
+                    builder.addBlock(new FileEntry.BlockInfo(
+                            bl.getOffset(), bl.getLength(), 
java.util.Collections.emptyList()));
+                }
+            }
+        }
+        return builder.build();
+    }
+
+    /**
+     * Creates a RemoteFile from a {@link FileEntry}.
+     *
+     * @param entry the FileEntry to convert
+     * @return a new RemoteFile representing the same file metadata
+     */
+    public static RemoteFile fromFileEntry(FileEntry entry) {
+        Path hadoopPath = new Path(entry.location().toString());
+        BlockLocation[] bls = new BlockLocation[entry.blocks().size()];
+        for (int i = 0; i < bls.length; i++) {
+            FileEntry.BlockInfo bi = entry.blocks().get(i);
+            bls[i] = new BlockLocation(null, bi.hosts().toArray(new 
String[0]), bi.offset(), bi.length());
+        }
+        return new RemoteFile(
+                hadoopPath,
+                entry.isDirectory(),
+                entry.length(),
+                entry.blockSize(),
+                entry.modificationTime(),
+                bls.length == 0 ? null : bls);
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/SwitchingFileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/SwitchingFileSystem.java
index 93dbfae6b72..3d1a45975d9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/SwitchingFileSystem.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/SwitchingFileSystem.java
@@ -20,15 +20,15 @@ package org.apache.doris.fs.remote;
 import org.apache.doris.backup.Status;
 import org.apache.doris.common.util.LocationPath;
 import org.apache.doris.datasource.property.storage.StorageProperties;
-import org.apache.doris.fs.FileSystem;
 import org.apache.doris.fs.FileSystemCache;
 import org.apache.doris.fs.FileSystemLookup;
+import org.apache.doris.fs.LegacyFileSystemApi;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-public class SwitchingFileSystem implements FileSystem {
+public class SwitchingFileSystem implements LegacyFileSystemApi {
 
     private final FileSystemLookup lookup;
 
@@ -121,7 +121,7 @@ public class SwitchingFileSystem implements FileSystem {
         return fileSystem(remotePath).listDirectories(remotePath, result);
     }
 
-    public FileSystem fileSystem(String location) {
+    public LegacyFileSystemApi fileSystem(String location) {
         LocationPath path = LocationPath.of(location, storagePropertiesMap);
         FileSystemCache.FileSystemCacheKey fileSystemCacheKey = new 
FileSystemCache.FileSystemCacheKey(
                 path.getFsIdentifier(), path.getStorageProperties()
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/dfs/DFSFileSystem.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/dfs/DFSFileSystem.java
index 5d58edf343d..7af9081d639 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/remote/dfs/DFSFileSystem.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/remote/dfs/DFSFileSystem.java
@@ -25,6 +25,7 @@ import org.apache.doris.common.util.URI;
 import org.apache.doris.datasource.property.storage.HdfsCompatibleProperties;
 import org.apache.doris.datasource.property.storage.StorageProperties;
 import org.apache.doris.foundation.fs.FsStorageType;
+import org.apache.doris.fs.Location;
 import org.apache.doris.fs.io.DorisInputFile;
 import org.apache.doris.fs.io.DorisOutputFile;
 import org.apache.doris.fs.io.ParsedPath;
@@ -587,11 +588,11 @@ public class DFSFileSystem extends RemoteFileSystem {
 
     @Override
     public DorisOutputFile newOutputFile(ParsedPath path) {
-        return new HdfsOutputFile(path, this);
+        return new HdfsOutputFile(Location.of(path.toString()), this);
     }
 
     @Override
     public DorisInputFile newInputFile(ParsedPath path, long length) {
-        return new HdfsInputFile(path, length, this);
+        return new HdfsInputFile(Location.of(path.toString()), length, this);
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSTransactionPathTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSTransactionPathTest.java
index a1f7d146650..b8284c13200 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSTransactionPathTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSTransactionPathTest.java
@@ -18,8 +18,8 @@
 package org.apache.doris.datasource.hive;
 
 import org.apache.doris.backup.Status;
-import org.apache.doris.fs.FileSystem;
 import org.apache.doris.fs.FileSystemProvider;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.LocalDfsFileSystem;
 import org.apache.doris.fs.remote.RemoteFile;
 import org.apache.doris.fs.remote.SwitchingFileSystem;
@@ -161,27 +161,27 @@ public class HMSTransactionPathTest {
         Assert.assertFalse(Files.exists(otherFile));
     }
 
-    private static HMSTransaction createTransaction(FileSystem delegate) {
+    private static HMSTransaction createTransaction(LegacyFileSystemApi 
delegate) {
         SwitchingFileSystem switchingFs = new 
TestSwitchingFileSystem(delegate);
         FileSystemProvider provider = ctx -> switchingFs;
         return new HMSTransaction(null, provider, Runnable::run);
     }
 
     private static class TestSwitchingFileSystem extends SwitchingFileSystem {
-        private final FileSystem delegate;
+        private final LegacyFileSystemApi delegate;
 
-        TestSwitchingFileSystem(FileSystem delegate) {
+        TestSwitchingFileSystem(LegacyFileSystemApi delegate) {
             super(null, null);
             this.delegate = delegate;
         }
 
         @Override
-        public FileSystem fileSystem(String location) {
+        public LegacyFileSystemApi fileSystem(String location) {
             return delegate;
         }
     }
 
-    private static class FakeFileSystem implements FileSystem {
+    private static class FakeFileSystem implements LegacyFileSystemApi {
         private Status listDirectoriesStatus = Status.OK;
         private Status listFilesStatus = Status.OK;
         private Status makeDirStatus = Status.OK;
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HmsCommitTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HmsCommitTest.java
index 70bf0d95b84..7e946b5ae47 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HmsCommitTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HmsCommitTest.java
@@ -25,8 +25,8 @@ import 
org.apache.doris.common.security.authentication.ExecutionAuthenticator;
 import org.apache.doris.common.util.DebugUtil;
 import org.apache.doris.datasource.NameMapping;
 import org.apache.doris.datasource.TestHMSCachedClient;
-import org.apache.doris.fs.FileSystem;
 import org.apache.doris.fs.FileSystemProvider;
+import org.apache.doris.fs.LegacyFileSystemApi;
 import org.apache.doris.fs.LocalDfsFileSystem;
 import org.apache.doris.fs.remote.SwitchingFileSystem;
 import 
org.apache.doris.nereids.trees.plans.commands.insert.HiveInsertCommandContext;
@@ -75,7 +75,7 @@ public class HmsCommitTest {
     private static final String dbName = "test_db";
     private static final String tbWithPartition = "test_tb_with_partition";
     private static final String tbWithoutPartition = 
"test_tb_without_partition";
-    private static FileSystem fs;
+    private static LegacyFileSystemApi fs;
     private static LocalDfsFileSystem localDFSFileSystem;
     private static Executor fileSystemExecutor;
     static String dbLocation;
@@ -103,7 +103,7 @@ public class HmsCommitTest {
         localDFSFileSystem = new LocalDfsFileSystem();
         new MockUp<SwitchingFileSystem>(SwitchingFileSystem.class) {
             @Mock
-            public FileSystem fileSystem(String location) {
+            public LegacyFileSystemApi fileSystem(String location) {
                 return localDFSFileSystem;
             }
         };
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/fs/TransactionScopeCachingDirectoryListerTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/fs/TransactionScopeCachingDirectoryListerTest.java
index d6c6ed4b93b..8d1a737cf79 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/fs/TransactionScopeCachingDirectoryListerTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/fs/TransactionScopeCachingDirectoryListerTest.java
@@ -136,7 +136,8 @@ public class TransactionScopeCachingDirectoryListerTest {
         }
 
         @Override
-        public RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean 
recursive, TableIf table, String location)
+        public RemoteIterator<RemoteFile> listFiles(LegacyFileSystemApi fs, 
boolean recursive,
+                TableIf table, String location)
                 throws FileSystemIOException {
             // No specific recursive files-only listing implementation
             listCount++;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to