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

52 lines
1.1 KiB
C
Raw Normal View History

2010-03-04 19:20:28 +00:00
#ifndef DBMS_STORAGES_STORAGE_SYSTEM_NUMBERS_H
#define DBMS_STORAGES_STORAGE_SYSTEM_NUMBERS_H
#include <Poco/SharedPtr.h>
#include <DB/Storages/IStorage.h>
namespace DB
{
using Poco::SharedPtr;
class NumbersBlockInputStream : public IBlockInputStream
{
public:
NumbersBlockInputStream(size_t block_size_);
Block read();
private:
size_t block_size;
UInt64 next;
};
/** Реализует хранилище для системной таблицы Numbers.
* Таблица содержит единственный столбец number UInt64.
* Из этой таблицы можно прочитать все натуральные числа, начиная с 0 (до 2^64 - 1, а потом заново).
*/
class StorageSystemNumbers : public IStorage
{
public:
2011-08-15 02:24:44 +00:00
StorageSystemNumbers();
2010-03-04 19:20:28 +00:00
std::string getName() const { return "SystemNumbers"; }
2011-08-15 02:24:44 +00:00
std::string getTableName() const { return "Numbers"; }
const NamesAndTypes & getColumns() const { return columns; }
2010-03-04 19:20:28 +00:00
SharedPtr<IBlockInputStream> read(
2011-08-09 15:57:33 +00:00
const Names & column_names,
2011-08-15 01:12:57 +00:00
ASTPtr query,
2010-03-04 19:20:28 +00:00
size_t max_block_size = DEFAULT_BLOCK_SIZE);
2011-08-15 02:24:44 +00:00
private:
NamesAndTypes columns;
2010-03-04 19:20:28 +00:00
};
}
#endif