[llvm] [llvm/CAS] Add file-based APIs to `OnDiskGraphDB` (PR #179782)

Argyrios Kyrtzidis via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 14:49:53 PST 2026


================
@@ -315,6 +327,31 @@ class OnDiskGraphDB {
     return make_range(Refs.begin(), Refs.end());
   }
 
+  /// Encapsulates file info for an underlying object node.
+  struct FileBackedData {
+    /// The data of the object node.
+    ArrayRef<char> Data;
+
+    struct FileInfoTy {
+      /// The file path of the object node.
+      std::string FilePath;
+      /// Whether the file of the object leaf node has an extra nul appended at
+      /// the end. If the file is copied the extra nul needs to be removed.
+      bool IsFileNulTerminated;
+    };
+    /// File information for the object, if available.
+    std::optional<FileInfoTy> FileInfo;
+  };
+
+  /// Provides access to the underlying file path, that represents an object
+  /// leaf node, when available.
+  ///
+  /// This enables reducing I/O and disk space consumption, i.e. instead of
+  /// loading the data in memory and then writing it to a file, the client could
+  /// clone the underlying file directly. The client *must not* write to or
+  /// delete the underlying file, the path is provided only for reading/copying.
+  FileBackedData getInternalFileBackedObjectData(ObjectHandle Node) const;
----------------
akyrtzi wrote:

It is useful if the caller wants to pass the file path to an operation that just reads the file, and doesn't need to copy it to another path.
Note I intend to keep this only on `OnDiskGraphDB` and not expose something similar to other CAS APIs, other CAS APIs will get a "copy/clone file" operation as you suggested.

https://github.com/llvm/llvm-project/pull/179782


More information about the llvm-commits mailing list