MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / executeImpl

Method executeImpl

src/Functions/array/arrayShuffle.cpp:111–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110template <typename Traits>
111ColumnPtr FunctionArrayShuffleImpl<Traits>::executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t) const
112{
113 auto col = arguments[0].column->convertToFullColumnIfConst();
114 const ColumnArray * array = checkAndGetColumn<ColumnArray>(col.get());
115 if (!array)
116 throw Exception(
117 ErrorCodes::ILLEGAL_COLUMN, "Illegal column {} of first argument of function {}", arguments[0].column->getName(), getName());
118
119 const auto seed = [&]() -> uint64_t
120 {
121 // If present, seed comes as the last argument
122 if (arguments.size() != Traits::max_num_params)
123 return randomSeed();
124 const auto * val = arguments[Traits::seed_param_idx].column.get();
125 return val->getUInt(0);
126 }();
127 pcg64_fast rng(seed);
128
129 size_t limit = [&]() -> size_t
130 {
131 if constexpr (Traits::has_limit)
132 {
133 if (arguments.size() > 1)
134 {
135 const auto * val = arguments[1].column.get();
136 return val->getUInt(0);
137 }
138 }
139 return 0;
140 }();
141
142 return executeGeneric(*array, rng, limit);
143}
144
145template <typename Traits>
146ColumnPtr FunctionArrayShuffleImpl<Traits>::executeGeneric(const ColumnArray & array, pcg64_fast & rng, size_t limit [[maybe_unused]])

Callers

nothing calls this directly

Calls 9

randomSeedFunction · 0.85
executeGenericFunction · 0.70
ExceptionClass · 0.50
getNameFunction · 0.50
getMethod · 0.45
getNameMethod · 0.45
sizeMethod · 0.45
getUIntMethod · 0.45

Tested by

no test coverage detected