wjones127 commented on a change in pull request #166:
URL: https://github.com/apache/arrow-cookbook/pull/166#discussion_r831242717
##########
File path: cpp/source/basic.rst
##########
@@ -48,3 +48,58 @@ boilerplate for you. It will run the contained expression
and check the resulti
.. recipe:: ../code/basic_arrow.cc ReturnNotOk
:caption: Using ARROW_RETURN_NOT_OK to check the status
:dedent: 2
+
+
+Using the Visitor Pattern
+=========================
+
+Arrow classes DataType, Scalar, and Array have specialized subclasses for
+each Arrow type. In order to specialize logic for each subclass, you the
visitor
+pattern. Arrow provides the macros:
+
+ * `arrow::VisitTypeInline`
+ * `arrow::VisitScalarInline`
+ * `arrow::VisitArrayInline`
+
+To implement a TypeVisitor we have to implement a Visit method for every
possible
+DataType we wish to handle. Fortunately, we can often use templates and type
+traits to make this less verbose.
+
+Generate Random Data for Given Schema
+-------------------------------------
+
+To generate random data for a given schema, a type visitor is helpful.
+
+
+.. literalinclude:: ../code/basic_arrow.cc
+ :language: cpp
+ :linenos:
+ :start-at: class RandomBatchGenerator
+ :end-at: }; // RandomBatchGenerator
+ :caption: Using visitor pattern to generate random record batches
+
+
+.. recipe:: ../code/basic_arrow.cc GenerateRandomData
+ :dedent: 2
+
+
+Convert Arbitrary Scalars to Variants
+-------------------------------------
+
+.. TODO: Implement converter from rows to values
Review comment:
I'll delete this. I was initially thinking of doing three examples, but
I think the two I've done seem fine.
--
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]