Skip to content

Commit

Permalink
Merge efcd701 into 0a19242
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-gogov authored Oct 29, 2024
2 parents 0a19242 + efcd701 commit bdf0e09
Show file tree
Hide file tree
Showing 30 changed files with 2,455 additions and 490 deletions.
9 changes: 5 additions & 4 deletions ydb/core/formats/arrow/serializer/native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ NKikimr::TConclusion<std::shared_ptr<arrow::util::Codec>> TNativeSerializer::Bui
const int levelMin = codec->minimum_compression_level();
const int levelMax = codec->maximum_compression_level();
if (levelDef < levelMin || levelMax < levelDef) {
return TConclusionStatus::Fail(
TStringBuilder() << "incorrect level for codec. have to be: [" << levelMin << ":" << levelMax << "]"
);
return TConclusionStatus::Fail(TStringBuilder() << "incorrect level for codec `" << arrow::util::Codec::GetCodecAsString(cType)
<< "`. have to be: [" << levelMin << ":" << levelMax << "]");
}
std::shared_ptr<arrow::util::Codec> codecPtr = std::move(NArrow::TStatusValidator::GetValid(arrow::util::Codec::Create(cType, levelDef)));
return codecPtr;
Expand Down Expand Up @@ -182,7 +181,9 @@ NKikimr::TConclusionStatus TNativeSerializer::DoDeserializeFromProto(const NKiki
void TNativeSerializer::DoSerializeToProto(NKikimrSchemeOp::TOlapColumn::TSerializer& proto) const {
if (Options.codec) {
proto.MutableArrowCompression()->SetCodec(NArrow::CompressionToProto(Options.codec->compression_type()));
proto.MutableArrowCompression()->SetLevel(Options.codec->compression_level());
if (arrow::util::Codec::SupportsCompressionLevel(Options.codec->compression_type())) {
proto.MutableArrowCompression()->SetLevel(Options.codec->compression_level());
}
} else {
proto.MutableArrowCompression()->SetCodec(NArrow::CompressionToProto(arrow::Compression::UNCOMPRESSED));
}
Expand Down
14 changes: 14 additions & 0 deletions ydb/core/formats/arrow/serializer/native.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ class TNativeSerializer: public ISerializer {
Options.use_threads = false;
Options.memory_pool = pool;
}

arrow::Compression::type GetCodecType() const {
if (Options.codec) {
return Options.codec->compression_type();
}
return arrow::Compression::type::UNCOMPRESSED;
}

std::optional<i32> GetCodecLevel() const {
if (Options.codec && arrow::util::Codec::SupportsCompressionLevel(Options.codec->compression_type())) {
return Options.codec->compression_level();
}
return {};
}
};

}
12 changes: 12 additions & 0 deletions ydb/core/formats/arrow/serializer/parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ std::string CompressionToString(const arrow::Compression::type compression) {
return arrow::util::Codec::GetCodecAsString(compression);
}

std::string CompressionToString(const NKikimrSchemeOp::EColumnCodec compression) {
switch (compression) {
case NKikimrSchemeOp::EColumnCodec::ColumnCodecPlain:
return "off";
case NKikimrSchemeOp::EColumnCodec::ColumnCodecZSTD:
return "zstd";
case NKikimrSchemeOp::EColumnCodec::ColumnCodecLZ4:
return "lz4";
}
return "";
}

std::optional<arrow::Compression::type> CompressionFromString(const std::string& compressionStr) {
auto result = arrow::util::Codec::GetCompressionType(compressionStr);
if (!result.ok()) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/formats/arrow/serializer/parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace NKikimr::NArrow {

std::string CompressionToString(const arrow::Compression::type compression);
std::string CompressionToString(const NKikimrSchemeOp::EColumnCodec compression);
std::optional<arrow::Compression::type> CompressionFromString(const std::string& compressionStr);

NKikimrSchemeOp::EColumnCodec CompressionToProto(const arrow::Compression::type compression);
std::optional<arrow::Compression::type> CompressionFromProto(const NKikimrSchemeOp::EColumnCodec compression);

}
Loading

0 comments on commit bdf0e09

Please sign in to comment.