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

55 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
Block readImpl();
String getName() const { return "NumbersBlockInputStream"; }
2011-10-24 12:10:59 +00:00
BlockInputStreamPtr clone() { return new NumbersBlockInputStream(block_size); }
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:
2011-08-18 20:33:20 +00:00
StorageSystemNumbers(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,
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;
2010-03-04 19:20:28 +00:00
};
}