mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
fix
This commit is contained in:
parent
675509ed23
commit
c4ff7eec01
@ -1,14 +1,15 @@
|
|||||||
#include <Columns/ColumnString.h>
|
#include <Functions/IFunctionImpl.h>
|
||||||
#include <DataTypes/DataTypeString.h>
|
|
||||||
#include <Functions/FunctionFactory.h>
|
#include <Functions/FunctionFactory.h>
|
||||||
#include <Functions/FunctionHelpers.h>
|
#include <Functions/FunctionHelpers.h>
|
||||||
#include <Functions/IFunctionImpl.h>
|
#include <Columns/ColumnString.h>
|
||||||
|
#include <DataTypes/DataTypeString.h>
|
||||||
#include <pcg_random.hpp>
|
#include <pcg_random.hpp>
|
||||||
#include <Common/randomSeed.h>
|
#include <Common/randomSeed.h>
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace ErrorCodes
|
namespace ErrorCodes
|
||||||
{
|
{
|
||||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||||
@ -26,7 +27,10 @@ public:
|
|||||||
static constexpr auto name = "randomPrintableASCII";
|
static constexpr auto name = "randomPrintableASCII";
|
||||||
static FunctionPtr create(const Context &) { return std::make_shared<FunctionRandomPrintableASCII>(); }
|
static FunctionPtr create(const Context &) { return std::make_shared<FunctionRandomPrintableASCII>(); }
|
||||||
|
|
||||||
String getName() const override { return name; }
|
String getName() const override
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
bool isVariadic() const override { return true; }
|
bool isVariadic() const override { return true; }
|
||||||
size_t getNumberOfArguments() const override { return 0; }
|
size_t getNumberOfArguments() const override { return 0; }
|
||||||
@ -34,13 +38,11 @@ public:
|
|||||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||||
{
|
{
|
||||||
if (arguments.empty())
|
if (arguments.empty())
|
||||||
throw Exception(
|
throw Exception("Function " + getName() + " requires at least one argument: the size of resulting string",
|
||||||
"Function " + getName() + " requires at least one argument: the size of resulting string",
|
|
||||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||||
|
|
||||||
if (arguments.size() > 2)
|
if (arguments.size() > 2)
|
||||||
throw Exception(
|
throw Exception("Function " + getName() + " requires at most two arguments: the size of resulting string and optional disambiguation tag",
|
||||||
"Function " + getName() + " requires at most two arguments: the size of resulting string and optional disambiguation tag",
|
|
||||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||||
|
|
||||||
const IDataType & length_type = *arguments[0];
|
const IDataType & length_type = *arguments[0];
|
||||||
@ -76,8 +78,7 @@ public:
|
|||||||
offsets_to[row_num] = next_offset;
|
offsets_to[row_num] = next_offset;
|
||||||
|
|
||||||
auto * data_to_ptr = data_to.data(); /// avoid assert on array indexing after end
|
auto * data_to_ptr = data_to.data(); /// avoid assert on array indexing after end
|
||||||
for (size_t pos = offset, end = offset + length; pos < end;
|
for (size_t pos = offset, end = offset + length; pos < end; pos += 4) /// We have padding in column buffers that we can overwrite.
|
||||||
pos += 4) /// We have padding in column buffers that we can overwrite.
|
|
||||||
{
|
{
|
||||||
UInt64 rand = rng();
|
UInt64 rand = rng();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user