ClickHouse/dbms/IO/tests/limit_read_buffer.cpp
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

42 lines
881 B
C++

#include <string>
#include <IO/ReadBufferFromFileDescriptor.h>
#include <IO/LimitReadBuffer.h>
#include <IO/WriteBufferFromFileDescriptor.h>
#include <IO/copyData.h>
#include <IO/WriteHelpers.h>
int main(int argc, char ** argv)
{
using namespace DB;
if (argc < 2)
{
std::cerr << "Usage: program limit < in > out\n";
return 1;
}
UInt64 limit = std::stol(argv[1]);
ReadBufferFromFileDescriptor in(STDIN_FILENO);
WriteBufferFromFileDescriptor out(STDOUT_FILENO);
writeCString("--- first ---\n", out);
{
LimitReadBuffer limit_in(in, limit, false);
copyData(limit_in, out);
}
writeCString("\n--- second ---\n", out);
{
LimitReadBuffer limit_in(in, limit, false);
copyData(limit_in, out);
}
writeCString("\n--- the rest ---\n", out);
copyData(in, out);
return 0;
}