cyb70289 commented on a change in pull request #11864: URL: https://github.com/apache/arrow/pull/11864#discussion_r762867813
########## File path: cpp/src/arrow/compute/kernels/random.cc ########## @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "arrow/util/random.h" +#include "arrow/compute/kernel.h" +#include "arrow/compute/kernels/common.h" +#include "arrow/compute/registry.h" + +#include <random> + +namespace arrow { +namespace compute { +namespace internal { +namespace { + +Status ExecRandom(KernelContext* ctx, const ExecBatch& batch, Datum* out) { + std::random_device rd; + std::mt19937 gen(rd()); + float value = random::generate_canonical<float>(gen); + BoxScalar<FloatType>::Box(value, out->scalar().get()); + return Status::OK(); Review comment: I know it's still a draft, but it's better to agree on some requirements early. Which RNG to use? I prefer PCG which is already vendored [1]. Shall we use our own `random::generate_canonical` which is to workaround performance issue on Arm [2], or functions provided by STL, or something else? I'm not sure. @pitrou [1] https://github.com/apache/arrow/tree/master/cpp/src/arrow/vendored/pcg [2] https://issues.apache.org/jira/browse/ARROW-12533 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org