ClickHouse/dbms/include/DB/Storages/StorageSystemNumbers.h

59 lines
1.4 KiB
C
Raw Normal View History

2011-08-27 22:43:31 +00:00
#pragma once
2010-03-04 19:20:28 +00:00
#include <Poco/SharedPtr.h>
#include <DB/Storages/IStorage.h>
2011-09-04 21:23:19 +00:00
#include <DB/DataStreams/IProfilingBlockInputStream.h>
2010-03-04 19:20:28 +00:00
namespace DB
{
using Poco::SharedPtr;
2011-09-04 21:23:19 +00:00
class NumbersBlockInputStream : public IProfilingBlockInputStream
2010-03-04 19:20:28 +00:00
{
public:
NumbersBlockInputStream(size_t block_size_);
2011-09-04 21:23:19 +00:00
String getName() const { return "NumbersBlockInputStream"; }
String getID() const { return "Numbers"; }
2012-10-20 02:10:47 +00:00
protected:
Block readImpl();
2010-03-04 19:20:28 +00:00
private:
size_t block_size;
UInt64 next;
};
/** Реализует хранилище для системной таблицы Numbers.
* Таблица содержит единственный столбец number UInt64.
* Из этой таблицы можно прочитать все натуральные числа, начиная с 0 (до 2^64 - 1, а потом заново).
*/
class StorageSystemNumbers : public IStorage
{
public:
static StoragePtr create(const std::string & name_);
2011-08-15 02:24:44 +00:00
2010-03-04 19:20:28 +00:00
std::string getName() const { return "SystemNumbers"; }
2012-05-08 11:19:00 +00:00
std::string getTableName() const { return name; }
2011-08-15 02:24:44 +00:00
2011-11-01 17:12:11 +00:00
const NamesAndTypesList & getColumnsList() const { return columns; }
2010-03-04 19:20:28 +00:00
2012-01-09 19:20:48 +00:00
BlockInputStreams read(
2011-08-09 15:57:33 +00:00
const Names & column_names,
2011-08-15 01:12:57 +00:00
ASTPtr query,
const Settings & settings,
2012-05-22 18:32:45 +00:00
QueryProcessingStage::Enum & processed_stage,
2012-01-09 19:20:48 +00:00
size_t max_block_size = DEFAULT_BLOCK_SIZE,
2012-05-30 04:45:49 +00:00
unsigned threads = 1);
2011-08-15 02:24:44 +00:00
private:
2011-08-18 20:33:20 +00:00
const std::string name;
2011-11-01 17:12:11 +00:00
NamesAndTypesList columns;
StorageSystemNumbers(const std::string & name_);
2010-03-04 19:20:28 +00:00
};
}