2010-03-04 19:20:28 +00:00
|
|
|
#include <Poco/SharedPtr.h>
|
|
|
|
|
|
|
|
#include <DB/Core/Exception.h>
|
|
|
|
#include <DB/Core/ErrorCodes.h>
|
2010-03-12 18:25:35 +00:00
|
|
|
#include <DB/Columns/ColumnsNumber.h>
|
2010-03-05 17:38:01 +00:00
|
|
|
#include <DB/DataTypes/DataTypesNumberFixed.h>
|
2010-03-04 19:20:28 +00:00
|
|
|
#include <DB/Storages/StorageSystemNumbers.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
using Poco::SharedPtr;
|
|
|
|
|
|
|
|
|
|
|
|
NumbersBlockInputStream::NumbersBlockInputStream(size_t block_size_) : block_size(block_size_), next(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Block NumbersBlockInputStream::read()
|
|
|
|
{
|
|
|
|
Block res;
|
2011-08-14 00:49:30 +00:00
|
|
|
|
|
|
|
ColumnWithNameAndType column_with_name_and_type;
|
2010-03-12 20:44:25 +00:00
|
|
|
|
2010-03-04 19:20:28 +00:00
|
|
|
column_with_name_and_type.name = "number";
|
2010-03-05 17:38:01 +00:00
|
|
|
column_with_name_and_type.type = new DataTypeUInt64();
|
2010-03-12 18:25:35 +00:00
|
|
|
ColumnUInt64 * column = new ColumnUInt64(block_size);
|
|
|
|
ColumnUInt64::Container_t & vec = column->getData();
|
|
|
|
column_with_name_and_type.column = column;
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < block_size; ++i)
|
|
|
|
vec[i] = next++;
|
2011-08-14 00:49:30 +00:00
|
|
|
|
|
|
|
res.insert(column_with_name_and_type);
|
2010-03-12 20:44:25 +00:00
|
|
|
|
2010-03-04 19:20:28 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 20:33:20 +00:00
|
|
|
StorageSystemNumbers::StorageSystemNumbers(const std::string & name_)
|
|
|
|
: name(name_)
|
2010-03-04 19:20:28 +00:00
|
|
|
{
|
2011-08-15 02:24:44 +00:00
|
|
|
columns["number"] = new DataTypeUInt64;
|
|
|
|
}
|
2010-03-04 19:20:28 +00:00
|
|
|
|
|
|
|
|
2011-08-15 02:24:44 +00:00
|
|
|
SharedPtr<IBlockInputStream> StorageSystemNumbers::read(
|
|
|
|
const Names & column_names, ASTPtr query, size_t max_block_size)
|
|
|
|
{
|
|
|
|
check(column_names);
|
2010-03-04 19:20:28 +00:00
|
|
|
return new NumbersBlockInputStream(max_block_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|