mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
compressor: added util for testing compression in DB.
This commit is contained in:
parent
cb45d49d11
commit
6dbc33abcf
41
utils/compressor/main.cpp
Normal file
41
utils/compressor/main.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <Poco/SharedPtr.h>
|
||||
|
||||
#include <DB/IO/WriteBufferFromOStream.h>
|
||||
#include <DB/IO/ReadBufferFromIStream.h>
|
||||
#include <DB/IO/CompressedWriteBuffer.h>
|
||||
#include <DB/IO/CompressedReadBuffer.h>
|
||||
#include <DB/IO/copyData.h>
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
if (argc > 2 || (argc == 2 && strcmp(argv[1], "-d")))
|
||||
{
|
||||
std::cerr << "Usage: " << argv[0] << " [-d] < in > out" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Poco::SharedPtr<DB::ReadBuffer> rb = new DB::ReadBufferFromIStream(std::cin);
|
||||
Poco::SharedPtr<DB::WriteBuffer> wb = new DB::WriteBufferFromOStream(std::cout);
|
||||
Poco::SharedPtr<DB::ReadBuffer> from;
|
||||
Poco::SharedPtr<DB::WriteBuffer> to;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
/// Сжатие
|
||||
from = rb;
|
||||
to = new DB::CompressedWriteBuffer(*wb);
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Разжатие
|
||||
from = new DB::CompressedReadBuffer(*rb);
|
||||
to = wb;
|
||||
}
|
||||
|
||||
DB::copyData(*from, *to);
|
||||
|
||||
return 0;
|
||||
}
|
5
utils/compressor/test.sh
Executable file
5
utils/compressor/test.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
./compressor < compressor > compressor.qlz
|
||||
./compressor -d < compressor.qlz > compressor2
|
||||
cmp compressor compressor2 && echo "Ok." || echo "Fail."
|
Loading…
Reference in New Issue
Block a user