compressor: added util for testing compression in DB.

This commit is contained in:
Alexey Milovidov 2011-05-16 16:39:55 +00:00
parent cb45d49d11
commit 6dbc33abcf
2 changed files with 46 additions and 0 deletions

41
utils/compressor/main.cpp Normal file
View 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
View File

@ -0,0 +1,5 @@
#!/bin/sh
./compressor < compressor > compressor.qlz
./compressor -d < compressor.qlz > compressor2
cmp compressor compressor2 && echo "Ok." || echo "Fail."