Skip to content

Commit

Permalink
sw
Browse files Browse the repository at this point in the history
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
  • Loading branch information
Lloyd-Pottiger committed May 10, 2024
1 parent 530b134 commit 582242f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
17 changes: 17 additions & 0 deletions dbms/src/IO/Compression/CompressionCodecIntegerLightweight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ UInt32 CompressionCodecIntegerLightweight::getMaxCompressedDataSize(UInt32 uncom
return 1 + 1 + LZ4_COMPRESSBOUND(uncompressed_size);
}

CompressionCodecIntegerLightweight::~CompressionCodecIntegerLightweight()
{
LOG_INFO(Logger::get(), "lightweight codec: {}", ctx.toDebugString());
}

template <typename T>
size_t CompressionCodecIntegerLightweight::compressDataForType(const char * source, UInt32 source_size, char * dest)
const
Expand Down Expand Up @@ -166,6 +171,18 @@ void CompressionCodecIntegerLightweight::decompressDataForType(
}
}

String CompressionCodecIntegerLightweight::CompressContext::toDebugString() const
{
return fmt::format(
"lz4: {} times, {} -> {}, lightweight: {} times, {} -> {}",
lz4_counter,
lz4_uncompressed_size,
lz4_compressed_size,
lw_counter,
lw_uncompressed_size,
lw_compressed_size);
}

void CompressionCodecIntegerLightweight::CompressContext::update(size_t uncompressed_size, size_t compressed_size)
{
if (mode == Mode::LZ4)
Expand Down
4 changes: 4 additions & 0 deletions dbms/src/IO/Compression/CompressionCodecIntegerLightweight.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class CompressionCodecIntegerLightweight : public ICompressionCodec

UInt8 getMethodByte() const override;

~CompressionCodecIntegerLightweight() override;

protected:
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)
Expand Down Expand Up @@ -93,6 +95,8 @@ class CompressionCodecIntegerLightweight : public ICompressionCodec

void update(size_t uncompressed_size, size_t compressed_size);

String toDebugString() const;

Mode mode = Mode::LZ4;

private:
Expand Down
19 changes: 18 additions & 1 deletion dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,26 @@ class DMFileWriter
/*flags*/ -1,
/*mode*/ 0666,
max_compress_block_size))
, compressed_buf(CompressedWriteBuffer<>::build(*plain_file, compression_settings, !dmfile->configuration))
, minmaxes(do_index ? std::make_shared<MinMaxIndex>(*type) : nullptr)
{
// TODO: better, now only for test
if (type->isInteger())
{
assert(compression_settings.settings.size() == 1);
// init only once
static CompressionSettings settings(CompressionMethod::Lightweight);
auto & setting = settings.settings[0];
setting.type_bytes_size = type->getSizeOfValueInMemory();
compressed_buf = CompressedWriteBuffer<>::build(*plain_file, settings, !dmfile->configuration);
}
else
{
compressed_buf = CompressedWriteBuffer<>::build( //
*plain_file,
compression_settings,
!dmfile->configuration);
}

if (!dmfile->useMetaV2())
{
mark_file = ChecksumWriteBufferBuilder::
Expand Down

0 comments on commit 582242f

Please sign in to comment.