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);
|
2010-03-12 18:25:35 +00:00
|
|
|
|
2015-06-08 20:22:02 +00:00
|
|
|
String getName() const override { return "Limit"; }
|
2014-11-08 23:52:18 +00:00
|
|
|
|
|
|
|
String getID() const override
|
2013-05-03 10:20:53 +00:00
|
|
|
{
|
|
|
|
std::stringstream res;
|
2013-05-04 05:20:07 +00:00
|
|
|
res << "Limit(" << children.back()->getID() << ", " << limit << ", " << offset << ")";
|
2013-05-03 10:20:53 +00:00
|
|
|
return res.str();
|
|
|
|
}
|
|
|
|
|
2012-10-20 02:10:47 +00:00
|
|
|
protected:
|
2014-11-08 23:52:18 +00:00
|
|
|
Block readImpl() override;
|
2012-10-20 02:10:47 +00:00
|
|
|
|
2010-03-12 18:25:35 +00:00
|
|
|
private:
|
|
|
|
size_t limit;
|
|
|
|
size_t offset;
|
|
|
|
size_t pos;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|