ClickHouse/dbms/include/DB/DataStreams/LimitBlockInputStream.h

41 lines
711 B
C
Raw Normal View History

2011-09-04 21:23:19 +00:00
#pragma once
2010-03-12 18:25:35 +00:00
#include <Poco/SharedPtr.h>
2011-09-04 21:23:19 +00:00
#include <DB/DataStreams/IProfilingBlockInputStream.h>
2010-03-12 18:25:35 +00:00
namespace DB
{
using Poco::SharedPtr;
/** Реализует реляционную операцию LIMIT.
*/
2011-09-04 21:23:19 +00:00
class LimitBlockInputStream : public IProfilingBlockInputStream
2010-03-12 18:25:35 +00:00
{
public:
2011-08-28 02:22:23 +00:00
LimitBlockInputStream(BlockInputStreamPtr input_, size_t limit_, size_t offset_ = 0);
2012-10-20 02:10:47 +00:00
2011-09-04 21:23:19 +00:00
String getName() const { return "LimitBlockInputStream"; }
2010-03-12 18:25:35 +00:00
String getID() const
{
std::stringstream res;
res << "Limit(" << input->getID() << ", " << limit << ", " << offset << ")";
return res.str();
}
2012-10-20 02:10:47 +00:00
protected:
Block readImpl();
2010-03-12 18:25:35 +00:00
private:
2013-05-04 04:05:15 +00:00
IBlockInputStream * input;
2010-03-12 18:25:35 +00:00
size_t limit;
size_t offset;
size_t pos;
};
}