@@ -101,7 +101,7 @@ struct ObjectMetadata
101
101
ObjectAttributes attributes;
102
102
};
103
103
104
- struct RelativePathWithMetadata
104
+ struct PathWithMetadata
105
105
{
106
106
class CommandInTaskResponse
107
107
{
@@ -124,21 +124,26 @@ struct RelativePathWithMetadata
124
124
String relative_path;
125
125
std::optional<ObjectMetadata> metadata;
126
126
CommandInTaskResponse command;
127
+ String absolute_path;
127
128
128
- RelativePathWithMetadata () = default ;
129
+ PathWithMetadata () = default ;
129
130
130
- explicit RelativePathWithMetadata (const String & task_string, std::optional<ObjectMetadata> metadata_ = std::nullopt )
131
+ explicit PathWithMetadata (const String & task_string, std::optional<ObjectMetadata> metadata_ = std::nullopt , String absolute_path_ = " " )
131
132
: metadata(std::move(metadata_))
132
133
, command(task_string)
133
134
{
134
135
if (!command.is_parsed ())
136
+ {
135
137
relative_path = task_string;
138
+ absolute_path = absolute_path_;
139
+ }
136
140
}
137
141
138
- virtual ~RelativePathWithMetadata () = default ;
142
+ virtual ~PathWithMetadata () = default ;
139
143
140
144
virtual std::string getFileName () const { return std::filesystem::path (relative_path).filename (); }
141
145
virtual std::string getPath () const { return relative_path; }
146
+ virtual std::string getAbsolutePath () const { return absolute_path; }
142
147
virtual bool isArchive () const { return false ; }
143
148
virtual std::string getPathToArchive () const { throw Exception (ErrorCodes::LOGICAL_ERROR, " Not an archive" ); }
144
149
virtual size_t fileSizeInArchive () const { throw Exception (ErrorCodes::LOGICAL_ERROR, " Not an archive" ); }
@@ -160,8 +165,8 @@ struct ObjectKeyWithMetadata
160
165
{}
161
166
};
162
167
163
- using RelativePathWithMetadataPtr = std::shared_ptr<RelativePathWithMetadata >;
164
- using RelativePathsWithMetadata = std::vector<RelativePathWithMetadataPtr >;
168
+ using PathWithMetadataPtr = std::shared_ptr<PathWithMetadata >;
169
+ using PathsWithMetadata = std::vector<PathWithMetadataPtr >;
165
170
using ObjectKeysWithMetadata = std::vector<ObjectKeyWithMetadata>;
166
171
167
172
class IObjectStorageIterator ;
@@ -202,7 +207,7 @@ class IObjectStorage
202
207
virtual bool existsOrHasAnyChild (const std::string & path) const ;
203
208
204
209
// / List objects recursively by certain prefix.
205
- virtual void listObjects (const std::string & path, RelativePathsWithMetadata & children, size_t max_keys) const ;
210
+ virtual void listObjects (const std::string & path, PathsWithMetadata & children, size_t max_keys) const ;
206
211
207
212
// / List objects recursively by certain prefix. Use it instead of listObjects, if you want to list objects lazily.
208
213
virtual ObjectStorageIteratorPtr iterate(const std::string & path_prefix, size_t max_keys) const ;
@@ -284,6 +289,11 @@ class IObjectStorage
284
289
// / buckets in S3. If object storage doesn't have any namepaces return empty string.
285
290
virtual String getObjectsNamespace () const = 0;
286
291
292
+ virtual std::unique_ptr<IObjectStorage> cloneObjectStorage (
293
+ const std::string & new_namespace,
294
+ const Poco::Util::AbstractConfiguration & config,
295
+ const std::string & config_prefix, ContextPtr context) = 0;
296
+
287
297
// / Generate blob name for passed absolute local path.
288
298
// / Path can be generated either independently or based on `path`.
289
299
virtual ObjectStorageKey generateObjectKeyForPath (const std::string & path, const std::optional<std::string> & key_prefix) const = 0;
0 commit comments