save-buffer commented on a change in pull request #12537:
URL: https://github.com/apache/arrow/pull/12537#discussion_r824980006
##########
File path: cpp/src/arrow/compute/exec/tpch_node.cc
##########
@@ -0,0 +1,3836 @@
+#include "arrow/compute/exec/tpch_node.h"
+#include "arrow/util/make_unique.h"
+#include "arrow/util/future.h"
+#include "arrow/util/unreachable.h"
+
+#include <algorithm>
+#include <bitset>
+#include <cstring>
+#include <random>
+#include <vector>
+#include <memory>
+#include <mutex>
+#include <queue>
+#include <unordered_set>
+
+namespace arrow
+{
+ using internal::checked_cast;
+
+ namespace compute
+ {
+ class TpchText
+ {
+ public:
+ Status InitIfNeeded(random::pcg32_fast &rng);
+ Result<Datum> GenerateComments(
+ size_t num_comments,
+ size_t min_length,
+ size_t max_length,
+ random::pcg32_fast &rng);
+
+ private:
+ bool GenerateWord(int64_t &offset, random::pcg32_fast &rng, char
*arr, const char **words, size_t num_choices);
+ bool GenerateNoun(int64_t &offset, random::pcg32_fast &rng, char
*arr);
+ bool GenerateVerb(int64_t &offset, random::pcg32_fast &rng, char
*arr);
+ bool GenerateAdjective(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+ bool GenerateAdverb(int64_t &offset, random::pcg32_fast &rng, char
*arr);
+ bool GeneratePreposition(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+ bool GenerateAuxiliary(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+ bool GenerateTerminator(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+
+ bool GenerateNounPhrase(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+ bool GenerateVerbPhrase(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+ bool GeneratePrepositionalPhrase(int64_t &offset,
random::pcg32_fast &rng, char *arr);
+
+ bool GenerateSentence(int64_t &offset, random::pcg32_fast &rng,
char *arr);
+
+ std::atomic<bool> done_ = { false };
+ int64_t generated_offset_ = 0;
+ std::mutex text_guard_;
+ std::unique_ptr<Buffer> text_;
+ static constexpr int64_t kChunkSize = 8192;
+ static constexpr int64_t kTextBytes = 300 * 1024 * 1024; // 300 MB
+ };
+
+ class TpchTableGenerator
+ {
+ public:
+ using OutputBatchCallback = std::function<void(ExecBatch)>;
Review comment:
This is how the hash join node does it, so I copied it.
As a general note, I like the style of passing functions around is _much_
more than these objects because a) it's way more boilerplate code to define
these classes and b) semantically it feels like objects should be for bundling
state with operations. This type of stuff just feels like a hack to pass a
v-table around implicitly.
Also I'd argue this is more Java-vs-functional-style
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]