Removed old ZSTD test

This commit is contained in:
Alexey Milovidov 2020-01-10 21:41:09 +03:00
parent 5e29fe3425
commit 91e0d79007
2 changed files with 0 additions and 80 deletions

View File

@ -1,17 +1,5 @@
find_package (Threads)
add_executable (zstd_test zstd_test.cpp)
if(ZSTD_LIBRARY)
target_link_libraries(zstd_test PRIVATE ${ZSTD_LIBRARY})
endif()
target_link_libraries (zstd_test PRIVATE common)
add_executable (mutator mutator.cpp)
target_link_libraries(mutator PRIVATE clickhouse_common_io)
add_executable (decompress_perf decompress_perf.cpp)
target_link_libraries(decompress_perf PRIVATE dbms ${LZ4_LIBRARY})
if (NOT USE_INTERNAL_ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR)
target_include_directories (zstd_test BEFORE PRIVATE ${ZSTD_INCLUDE_DIR})
endif ()

View File

@ -1,68 +0,0 @@
#include <port/unistd.h>
#include <zstd.h>
#include <vector>
#include <stdexcept>
#include <sys/types.h>
int main(int argc, char ** argv)
{
bool compress = argc == 1;
const size_t size = 1048576;
std::vector<char> src_buf(size);
std::vector<char> dst_buf;
size_t pos = 0;
while (true)
{
ssize_t read_res = read(STDIN_FILENO, &src_buf[pos], size - pos);
if (read_res < 0)
throw std::runtime_error("Cannot read from stdin");
if (read_res == 0)
break;
pos += read_res;
}
src_buf.resize(pos);
size_t zstd_res;
if (compress)
{
dst_buf.resize(ZSTD_compressBound(src_buf.size()));
zstd_res = ZSTD_compress(
&dst_buf[0],
dst_buf.size(),
&src_buf[0],
src_buf.size(),
1);
}
else
{
dst_buf.resize(size);
zstd_res = ZSTD_decompress(
&dst_buf[0],
dst_buf.size(),
&src_buf[0],
src_buf.size());
}
if (ZSTD_isError(zstd_res))
throw std::runtime_error(ZSTD_getErrorName(zstd_res));
dst_buf.resize(zstd_res);
pos = 0;
while (pos < dst_buf.size())
{
ssize_t write_res = write(STDOUT_FILENO, &dst_buf[pos], dst_buf.size());
if (write_res <= 0)
throw std::runtime_error("Cannot write to stdout");
pos += write_res;
}
return 0;
}