-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backward compatibility for template remote keys
- Loading branch information
Showing
43 changed files
with
737 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "ObjectStorageKey.h" | ||
|
||
#include <Common/Exception.h> | ||
|
||
#include <filesystem> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
namespace DB | ||
{ | ||
|
||
namespace ErrorCodes | ||
{ | ||
extern const int LOGICAL_ERROR; | ||
} | ||
|
||
const String & ObjectStorageKey::getPrefix() const | ||
{ | ||
if (!is_relative) | ||
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "object key has no prefix, key: {}", key); | ||
|
||
return prefix; | ||
} | ||
|
||
const String & ObjectStorageKey::getSuffix() const | ||
{ | ||
if (!is_relative) | ||
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "object key has no suffix, key: {}", key); | ||
return suffix; | ||
} | ||
|
||
const String & ObjectStorageKey::serialize() const | ||
{ | ||
return key; | ||
} | ||
|
||
ObjectStorageKey ObjectStorageKey::createAsRelativeAnyway(String key_) | ||
{ | ||
ObjectStorageKey object_key; | ||
object_key.suffix = std::move(key_); | ||
object_key.key = object_key.suffix; | ||
object_key.is_relative = true; | ||
return object_key; | ||
} | ||
|
||
ObjectStorageKey ObjectStorageKey::createAsRelative(String prefix_, String suffix_) | ||
{ | ||
ObjectStorageKey object_key; | ||
object_key.prefix = std::move(prefix_); | ||
object_key.suffix = std::move(suffix_); | ||
|
||
if (object_key.prefix.empty()) | ||
object_key.key = object_key.suffix; | ||
else | ||
object_key.key = fs::path(object_key.prefix) / object_key.suffix; | ||
|
||
object_key.is_relative = true; | ||
return object_key; | ||
} | ||
|
||
ObjectStorageKey ObjectStorageKey::createAsAbsolute(String key_) | ||
{ | ||
ObjectStorageKey object_key; | ||
object_key.key = std::move(key_); | ||
object_key.is_relative = true; | ||
return object_key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include <base/types.h> | ||
|
||
#include <memory> | ||
|
||
namespace DB | ||
{ | ||
struct ObjectStorageKey | ||
{ | ||
ObjectStorageKey() = default; | ||
|
||
bool hasPrefix() const { return is_relative; } | ||
const String & getPrefix() const; | ||
const String & getSuffix() const; | ||
const String & serialize() const; | ||
|
||
static ObjectStorageKey createAsRelative(String prefix_, String suffix_); | ||
static ObjectStorageKey createAsRelativeAnyway(String key_); | ||
static ObjectStorageKey createAsAbsolute(String key_); | ||
|
||
private: | ||
String prefix; | ||
String suffix; | ||
String key; | ||
bool is_relative = false; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.