Fix bad dependencies in code

This commit is contained in:
Alexey Milovidov 2021-05-23 04:03:42 +03:00
parent 77414b50e6
commit deb68b15da
5 changed files with 14 additions and 19 deletions

View File

@ -25,8 +25,8 @@ protected:
void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override; void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;
bool isCompression() const override { return true; } bool isCompression() const override { return true; }
bool isGenericCompression() const override { return true; } bool isGenericCompression() const override { return true; }
bool isExperimental() const override { return true; }
private: private:
const DENSITY_ALGORITHM algo; const DENSITY_ALGORITHM algo;

View File

@ -20,6 +20,7 @@ protected:
void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override; void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;
bool isCompression() const override { return true; } bool isCompression() const override { return true; }
bool isGenericCompression() const override { return true; } bool isGenericCompression() const override { return true; }
bool isExperimental() const override { return true; }
private: private:
const UInt32 type; const UInt32 type;

View File

@ -20,12 +20,11 @@ public:
protected: protected:
UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override; UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override; void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;
bool isCompression() const override { return true; } bool isCompression() const override { return true; }
bool isGenericCompression() const override { return true; } bool isGenericCompression() const override { return true; }
bool isExperimental() const override { return true; }
private: private:
const int level; const int level;

View File

@ -93,7 +93,7 @@ ASTPtr CompressionCodecFactory::validateCodecAndGetPreprocessedAST(
std::optional<size_t> generic_compression_codec_pos; std::optional<size_t> generic_compression_codec_pos;
bool can_substitute_codec_arguments = true; bool can_substitute_codec_arguments = true;
for (size_t i = 0; i < func->arguments->children.size(); ++i) for (size_t i = 0, size = func->arguments->children.size(); i < size; ++i)
{ {
const auto & inner_codec_ast = func->arguments->children[i]; const auto & inner_codec_ast = func->arguments->children[i];
String codec_family_name; String codec_family_name;
@ -111,21 +111,6 @@ ASTPtr CompressionCodecFactory::validateCodecAndGetPreprocessedAST(
else else
throw Exception("Unexpected AST element for compression codec", ErrorCodes::UNEXPECTED_AST_STRUCTURE); throw Exception("Unexpected AST element for compression codec", ErrorCodes::UNEXPECTED_AST_STRUCTURE);
if (!allow_experimental_codecs)
{
if (codec_family_name == "Lizard" ||
codec_family_name == "Density" ||
codec_family_name == "LZSSE2" ||
codec_family_name == "LZSSE4" ||
codec_family_name == "LZSSE8")
{
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Codec {} is experimental and not meant to be used in production."
" You can enable it with the 'allow_experimental_codecs' setting.",
codec_family_name);
}
}
/// Default codec replaced with current default codec which may depend on different /// Default codec replaced with current default codec which may depend on different
/// settings (and properties of data) in runtime. /// settings (and properties of data) in runtime.
CompressionCodecPtr result_codec; CompressionCodecPtr result_codec;
@ -169,6 +154,12 @@ ASTPtr CompressionCodecFactory::validateCodecAndGetPreprocessedAST(
result_codec = getImpl(codec_family_name, codec_arguments, nullptr); result_codec = getImpl(codec_family_name, codec_arguments, nullptr);
} }
if (!allow_experimental_codecs && result_codec->isExperimental())
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Codec {} is experimental and not meant to be used in production."
" You can enable it with the 'allow_experimental_codecs' setting.",
codec_family_name);
codecs_descriptions->children.emplace_back(result_codec->getCodecDesc()); codecs_descriptions->children.emplace_back(result_codec->getCodecDesc());
} }

View File

@ -73,6 +73,10 @@ public:
/// Is it a generic compression algorithm like lz4, zstd. Usually it does not make sense to apply generic compression more than single time. /// Is it a generic compression algorithm like lz4, zstd. Usually it does not make sense to apply generic compression more than single time.
virtual bool isGenericCompression() const = 0; virtual bool isGenericCompression() const = 0;
/// It is a codec available only for evaluation purposes and not meant to be used in production.
/// It will not be allowed to use unless the user will turn off the safety switch.
virtual bool isExperimental() const { return false; }
/// If it does nothing. /// If it does nothing.
virtual bool isNone() const { return false; } virtual bool isNone() const { return false; }