@@ -108,13 +108,12 @@ struct ObjectMetadata
108108};
109109
110110
111- struct DataFileInfo ;
112111class DataFileMetaInfo ;
113112using DataFileMetaInfoPtr = std::shared_ptr<DataFileMetaInfo>;
114113
115114struct DataLakeObjectMetadata ;
116115
117- struct RelativePathWithMetadata
116+ struct PathWithMetadata
118117{
119118 class CommandInTaskResponse
120119 {
@@ -143,28 +142,35 @@ struct RelativePathWithMetadata
143142 std::optional<DataFileMetaInfoPtr> file_meta_info;
144143 // / Retry request after short pause
145144 CommandInTaskResponse command;
145+ std::optional<String> absolute_path;
146+ ObjectStoragePtr object_storage_to_use = nullptr ;
146147
147- RelativePathWithMetadata () = default ;
148+ PathWithMetadata () = default ;
148149
149- explicit RelativePathWithMetadata (String command_or_path, std::optional<ObjectMetadata> metadata_ = std::nullopt )
150+ explicit PathWithMetadata (
151+ const String & command_or_path,
152+ std::optional<ObjectMetadata> metadata_ = std::nullopt ,
153+ std::optional<String> absolute_path_ = std::nullopt ,
154+ ObjectStoragePtr object_storage_to_use_ = nullptr )
150155 : relative_path(std::move(command_or_path))
151156 , metadata(std::move(metadata_))
152157 , command(relative_path)
158+ , absolute_path((absolute_path_.has_value() && !absolute_path_.value().empty()) ? absolute_path_ : std::nullopt)
159+ , object_storage_to_use(object_storage_to_use_)
153160 {
154161 if (command.is_parsed ())
155162 relative_path = " " ;
156163 }
157164
158- explicit RelativePathWithMetadata (const DataFileInfo & info, std::optional<ObjectMetadata> metadata_ = std:: nullopt ) ;
165+ PathWithMetadata (const PathWithMetadata & other) = default ;
159166
160- RelativePathWithMetadata (const RelativePathWithMetadata & other) = default ;
161-
162- virtual ~RelativePathWithMetadata () = default ;
167+ virtual ~PathWithMetadata () = default ;
163168
164169 virtual std::string getFileName () const { return std::filesystem::path (relative_path).filename (); }
165170 virtual std::string getFileNameWithoutExtension () const { return std::filesystem::path (relative_path).stem (); }
166171
167172 virtual std::string getPath () const { return relative_path; }
173+ virtual std::optional<std::string> getAbsolutePath () const { return absolute_path; }
168174 virtual bool isArchive () const { return false ; }
169175 virtual std::string getPathToArchive () const { throw Exception (ErrorCodes::LOGICAL_ERROR, " Not an archive" ); }
170176 virtual size_t fileSizeInArchive () const { throw Exception (ErrorCodes::LOGICAL_ERROR, " Not an archive" ); }
@@ -176,6 +182,8 @@ struct RelativePathWithMetadata
176182 const CommandInTaskResponse & getCommand () const { return command; }
177183
178184 void loadMetadata (ObjectStoragePtr object_storage, bool ignore_non_existent_file = true );
185+
186+ ObjectStoragePtr getObjectStorage () const { return object_storage_to_use; }
179187};
180188
181189struct ObjectKeyWithMetadata
@@ -191,8 +199,8 @@ struct ObjectKeyWithMetadata
191199 {}
192200};
193201
194- using RelativePathWithMetadataPtr = std::shared_ptr<RelativePathWithMetadata >;
195- using RelativePathsWithMetadata = std::vector<RelativePathWithMetadataPtr >;
202+ using PathWithMetadataPtr = std::shared_ptr<PathWithMetadata >;
203+ using PathsWithMetadata = std::vector<PathWithMetadataPtr >;
196204using ObjectKeysWithMetadata = std::vector<ObjectKeyWithMetadata>;
197205
198206class IObjectStorageIterator ;
@@ -233,7 +241,7 @@ class IObjectStorage
233241 virtual bool existsOrHasAnyChild (const std::string & path) const ;
234242
235243 // / List objects recursively by certain prefix.
236- virtual void listObjects (const std::string & path, RelativePathsWithMetadata & children, size_t max_keys) const ;
244+ virtual void listObjects (const std::string & path, PathsWithMetadata & children, size_t max_keys) const ;
237245
238246 // / List objects recursively by certain prefix. Use it instead of listObjects, if you want to list objects lazily.
239247 virtual ObjectStorageIteratorPtr iterate(const std::string & path_prefix, size_t max_keys) const ;
0 commit comments