Skip to content

Commit 329cc45

Browse files
committed
tmp
1 parent 1d0e94a commit 329cc45

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

src/Storages/ObjectStorage/StorageObjectStorageSource.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ StorageObjectStorageSource::ReadTaskIterator::ReadTaskIterator(
12831283
continue;
12841284
}
12851285

1286+
/// Sometimes, raw is {"retry_after_us":499871}. Then skip?????
12861287
std::cerr << "\npath: " << raw << "\n";
12871288
if (object_storage)
12881289
std::cerr << "\nstorage: " << object_storage->getName() << ", " << object_storage->getObjectsNamespace() << "\n";
@@ -1294,7 +1295,10 @@ StorageObjectStorageSource::ReadTaskIterator::ReadTaskIterator(
12941295
getContext()
12951296
);
12961297

1297-
buffer.emplace_back(std::make_shared<ObjectInfo>(key, std::nullopt, raw, storage_to_use));
1298+
if (key.empty()) /// Not a valid key/path, maybe it is "retry_after_us". Store as is.
1299+
buffer.emplace_back(std::make_shared<ObjectInfo>(raw, std::nullopt));
1300+
else
1301+
buffer.emplace_back(std::make_shared<ObjectInfo>(key, std::nullopt, raw, storage_to_use));
12981302
}
12991303
}
13001304

src/Storages/ObjectStorage/Utils.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,30 +258,53 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
258258
const DB::ContextPtr & context)
259259
{
260260
if (isRelativePath(path))
261+
{
262+
if (base_storage)
263+
std::cerr << "\nRelative path: " << base_storage->getName() << ", " << base_storage->getObjectsNamespace() << "\n";
264+
else
265+
std::cerr << "\nRelative, returning base, which is: NULL\n";
261266
return {base_storage, path}; // Relative path definitely goes to base storage
267+
}
262268

263269
SchemeAuthorityKey base{table_location};
264270
SchemeAuthorityKey target{path};
265271

266272
if (target.scheme.empty())
273+
{
274+
if (base_storage)
275+
std::cerr << "\nNo scheme, returning base, which is: " << base_storage->getName() << ", " << base_storage->getObjectsNamespace() << "\n";
276+
else
277+
278+
std::cerr << "\nNo scheme, returning base, which is: NULL\n";
267279
return {base_storage, target.key};
280+
}
268281

269282
const std::string base_norm = normalizeSchema(base.scheme);
270283
const std::string target_norm = normalizeSchema(target.scheme);
271284

272285
// Reuse base storage if scheme and authority (bucket) matches
273-
if (!base.scheme.empty()
274-
&& base_norm == target_norm
275-
&& base.authority == target.authority)
286+
if (base_norm == target_norm && base.authority == target.authority)
276287
{
288+
if (base_storage)
289+
std::cerr << "\nSame location, returning base, which is: " << base_storage->getName() << ", " << base_storage->getObjectsNamespace() << "\n";
290+
else
291+
std::cerr << "\nSame location, returning base, which is: NULL\n";
277292
return {base_storage, target.key};
278293
}
279294

280295
const std::string cache_key = endpoint_cache_key(target_norm, target.authority);
281296
if (auto it = secondary_storages.find(cache_key); it != secondary_storages.end())
297+
{
298+
if (it->second)
299+
std::cerr << "\nfound in cache: " << it->second->getName() << ", " << it->second->getObjectsNamespace() << "\n";
300+
else
301+
std::cerr << "\nfound in cache: NULL\n";
282302
return {it->second, target.key};
303+
}
304+
305+
/// TODO: maybe do not invent new configuration. Use old one and clean up later
306+
Poco::AutoPtr<Poco::Util::MapConfiguration> cfg(new Poco::Util::MapConfiguration);
283307

284-
Poco::AutoPtr<Poco::Util::MapConfiguration> cfg;
285308
const std::string type_for_factory = factoryTypeForScheme(target_norm);
286309
if (type_for_factory.empty())
287310
throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Unsupported storage scheme '{}' in path '{}'", target_norm, path);
@@ -292,12 +315,12 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
292315

293316
if (target_norm == "s3" || target_norm == "abfs")
294317
{
295-
cfg->setString(config_prefix + ".endpoint", target.authority);
318+
cfg->setString(config_prefix + ".endpoint", target_norm + "://" + target.authority);
296319
}
297320
else if (target_norm == "hdfs")
298321
{
299322
// HDFS endpoint must end with '/'
300-
auto endpoint = target.authority;
323+
auto endpoint = target_norm + "://" + target.authority;
301324
if (!endpoint.empty() && endpoint.back() != '/')
302325
endpoint.push_back('/');
303326
cfg->setString(config_prefix + ".endpoint", endpoint);
@@ -310,6 +333,10 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
310333
DB::ObjectStoragePtr storage = factory.create(cache_key, *cfg, config_prefix, context, /*skip_access_check*/ true);
311334

312335
secondary_storages.emplace(cache_key, storage);
336+
if (storage)
337+
std::cerr << "\ncreated new storage: " << storage->getName() << ", " << storage->getObjectsNamespace() << "\n";
338+
else
339+
std::cerr << "\ncreated new storage: it is NULL\n";
313340
return {storage, target.key};
314341
}
315342

0 commit comments

Comments
 (0)