58 const SelectivityVector& rows,
59 std::vector<VectorPtr>& args,
61 exec::EvalCtx& context,
62 VectorPtr& output)
const override {
63 std::random_device rd;
64 std::mt19937 gen(rd());
65 std::bernoulli_distribution bernoulli(p_);
67 BaseVector::ensureWritable(rows, type, context.pool(), output);
69 auto inputFeatures = args[0]->as<ArrayVector>()->elements();
70 float* inputValues = inputFeatures->values()->asMutable<
float>();
72 int inputSize = inputFeatures->size();
73 int numInput = args[0]->size();
74 int numFeatures = inputSize / numInput;
77 std::vector<std::vector<float>> result(
78 numInput, std::vector<float>(numFeatures));
80 for (
int i = 0; i < numInput; i++) {
81 for (
int j = 0; j < numFeatures; j++) {
82 bool outcome = bernoulli(gen);
86 result[i][j] = inputValues[i * numFeatures + j];
91 VectorMaker maker{context.pool()};
92 output = maker.arrayVector<
float>(result, REAL());