-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ea7dea
commit 74572a2
Showing
20 changed files
with
370 additions
and
87 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
ydb/core/config/validation/column_shard_config_validator.cpp
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,54 @@ | ||
#include "validators.h" | ||
|
||
#include <ydb/core/formats/arrow/serializer/parsing.h> | ||
#include <ydb/core/formats/arrow/serializer/utils.h> | ||
#include <ydb/core/protos/config.pb.h> | ||
|
||
#include <util/generic/string.h> | ||
#include <util/string/builder.h> | ||
|
||
#include <vector> | ||
|
||
namespace NKikimr::NConfig { | ||
namespace { | ||
|
||
EValidationResult ValidateDefaultCompression(const NKikimrConfig::TColumnShardConfig& columnShardConfig, std::vector<TString>& msg) { | ||
if (!columnShardConfig.HasDefaultCompression() && !columnShardConfig.HasDefaultCompression()) { | ||
return EValidationResult::Ok; | ||
} | ||
std::optional<arrow::Compression::type> codec = NArrow::CompressionFromProto(columnShardConfig.GetDefaultCompression()); | ||
if (!codec.has_value()) { | ||
msg.push_back("ColumnShardConfig: Unknown compression"); | ||
return EValidationResult::Error; | ||
} | ||
if (columnShardConfig.HasDefaultCompressionLevel()) { | ||
if (!NArrow::SupportsCompressionLevel(codec.value())) { | ||
TString messageErr = TStringBuilder() << "ColumnShardConfig: compression `" << NArrow::CompressionToString(codec.value()) | ||
<< "` is not support compression level"; | ||
msg.push_back(messageErr); | ||
return EValidationResult::Error; | ||
} else if (!NArrow::SupportsCompressionLevel(codec.value(), columnShardConfig.GetDefaultCompressionLevel())) { | ||
TString messageErr = TStringBuilder() | ||
<< "ColumnShardConfig: compression `" << NArrow::CompressionToString(codec.value()) | ||
<< "` is not support compression level = " << std::to_string(columnShardConfig.GetDefaultCompressionLevel()); | ||
msg.push_back(messageErr); | ||
return EValidationResult::Error; | ||
} | ||
} | ||
return EValidationResult::Ok; | ||
} | ||
|
||
} // namespace | ||
|
||
EValidationResult ValidateColumnShardConfig(const NKikimrConfig::TColumnShardConfig& columnShardConfig, std::vector<TString>& msg) { | ||
EValidationResult validatePasswordComplexityResult = ValidateDefaultCompression(columnShardConfig, msg); | ||
if (validatePasswordComplexityResult == EValidationResult::Error) { | ||
return EValidationResult::Error; | ||
} | ||
if (msg.size() > 0) { | ||
return EValidationResult::Warn; | ||
} | ||
return EValidationResult::Ok; | ||
} | ||
|
||
} // namespace NKikimr::NConfig |
87 changes: 87 additions & 0 deletions
87
...e/config/validation/column_shard_config_validator_ut/column_shard_config_validator_ut.cpp
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,87 @@ | ||
#include <ydb/core/config/validation/validators.h> | ||
#include <ydb/core/protos/config.pb.h> | ||
#include <ydb/core/protos/flat_scheme_op.pb.h> | ||
|
||
#include <library/cpp/testing/unittest/registar.h> | ||
|
||
#include <vector> | ||
|
||
using namespace NKikimr::NConfig; | ||
|
||
Y_UNIT_TEST_SUITE(ColumnShardConfigValidation) { | ||
Y_UNIT_TEST(AcceptDefaultCompression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
} | ||
|
||
Y_UNIT_TEST(CorrectPlainCompression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecPlain); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
} | ||
|
||
Y_UNIT_TEST(NotCorrectPlainCompression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecPlain); | ||
CSConfig.SetDefaultCompressionLevel(1); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Error); | ||
UNIT_ASSERT_VALUES_EQUAL(error.size(), 1); | ||
UNIT_ASSERT_STRINGS_EQUAL(error.front(), "ColumnShardConfig: compression `uncompressed` is not support compression level"); | ||
} | ||
|
||
Y_UNIT_TEST(CorrectLZ4Compression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecLZ4); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
} | ||
|
||
Y_UNIT_TEST(NotCorrectLZ4Compression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecLZ4); | ||
CSConfig.SetDefaultCompressionLevel(1); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Error); | ||
UNIT_ASSERT_VALUES_EQUAL(error.size(), 1); | ||
UNIT_ASSERT_STRINGS_EQUAL(error.front(), "ColumnShardConfig: compression `lz4` is not support compression level"); | ||
} | ||
|
||
Y_UNIT_TEST(CorrectZSTDCompression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecZSTD); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
CSConfig.SetDefaultCompressionLevel(0); | ||
result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
CSConfig.SetDefaultCompressionLevel(-100); | ||
result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Ok); | ||
UNIT_ASSERT_C(error.empty(), "Should not be errors"); | ||
} | ||
|
||
Y_UNIT_TEST(NotCorrectZSTDCompression) { | ||
NKikimrConfig::TColumnShardConfig CSConfig; | ||
std::vector<TString> error; | ||
CSConfig.SetDefaultCompression(NKikimrSchemeOp::EColumnCodec::ColumnCodecZSTD); | ||
CSConfig.SetDefaultCompressionLevel(100); | ||
EValidationResult result = ValidateColumnShardConfig(CSConfig, error); | ||
UNIT_ASSERT_EQUAL(result, EValidationResult::Error); | ||
UNIT_ASSERT_VALUES_EQUAL(error.size(), 1); | ||
UNIT_ASSERT_STRINGS_EQUAL(error.front(), "ColumnShardConfig: compression `zstd` is not support compression level = 100"); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
ydb/core/config/validation/column_shard_config_validator_ut/ya.make
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,9 @@ | ||
UNITTEST_FOR(ydb/core/config/validation) | ||
|
||
SRC( | ||
column_shard_config_validator_ut.cpp | ||
) | ||
|
||
YQL_LAST_ABI_VERSION() | ||
|
||
END() |
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
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.