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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-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"; }
|
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
|
|
|
|
|
2011-08-28 02:22:23 +00:00
|
|
|
|
BlockInputStreamPtr 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:
|
2011-08-18 20:33:20 +00:00
|
|
|
|
const std::string name;
|
2011-08-15 02:24:44 +00:00
|
|
|
|
NamesAndTypes columns;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|