fork(2) download
  1. std::shared_ptr<arrow::Table> generate_table()
  2. {
  3. std::shared_ptr<arrow::DataType> static_facts_type(new arrow::StructType(
  4. {
  5. arrow::field("str", arrow::utf8(), false)
  6. }
  7. ));
  8.  
  9. arrow::StringBuilder strbuilder;
  10. PARQUET_THROW_NOT_OK(strbuilder.Append("some"));
  11. PARQUET_THROW_NOT_OK(strbuilder.Append("string"));
  12. PARQUET_THROW_NOT_OK(strbuilder.Append("content"));
  13. PARQUET_THROW_NOT_OK(strbuilder.Append("in"));
  14. PARQUET_THROW_NOT_OK(strbuilder.Append("rows"));
  15. std::shared_ptr<arrow::Array> strarray;
  16. PARQUET_THROW_NOT_OK(strbuilder.Finish(&strarray));
  17.  
  18. std::shared_ptr<arrow::Array> struct_array(new arrow::StructArray(static_facts_type, 5, {strarray}));
  19.  
  20. std::shared_ptr<arrow::Schema> schema = arrow::schema(
  21. {
  22. arrow::field("MyStruct", static_facts_type)
  23. });
  24.  
  25. return arrow::Table::Make(schema, {struct_array});
  26. }
  27.  
  28. // #1 Write out the data as a Parquet file
  29. void write_parquet_file(const arrow::Table& table) {
  30. std::shared_ptr<arrow::io::FileOutputStream> outfile;
  31. PARQUET_THROW_NOT_OK(
  32. arrow::io::FileOutputStream::Open("test.parquet", &outfile));
  33. // The last argument to the function call is the size of the RowGroup in
  34. // the parquet file. Normally you would choose this to be rather large but
  35. // for the example, we use a small value to have multiple RowGroups.
  36. PARQUET_THROW_NOT_OK(
  37. parquet::arrow::WriteTable(table, arrow::default_memory_pool(), outfile, 1));
  38. }
  39.  
  40. int main(int argc, char** argv) {
  41. std::shared_ptr<arrow::Table> table = generate_table();
  42. write_parquet_file(*table);
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:6: error: ‘shared_ptr’ in namespace ‘std’ does not name a template type
 std::shared_ptr<arrow::Table> generate_table()
      ^~~~~~~~~~
prog.cpp:29:31: error: ‘arrow’ does not name a type
 void write_parquet_file(const arrow::Table& table) {
                               ^~~~~
prog.cpp:29:43: error: expected unqualified-id before ‘&’ token
 void write_parquet_file(const arrow::Table& table) {
                                           ^
prog.cpp:29:43: error: expected ‘)’ before ‘&’ token
prog.cpp:29:45: error: expected initializer before ‘table’
 void write_parquet_file(const arrow::Table& table) {
                                             ^~~~~
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:41:3: error: ‘shared_ptr’ is not a member of ‘std’
   std::shared_ptr<arrow::Table> table = generate_table();
   ^~~
prog.cpp:41:19: error: ‘arrow’ has not been declared
   std::shared_ptr<arrow::Table> table = generate_table();
                   ^~~~~
prog.cpp:41:33: error: ‘table’ was not declared in this scope
   std::shared_ptr<arrow::Table> table = generate_table();
                                 ^~~~~
prog.cpp:41:56: error: ‘generate_table’ was not declared in this scope
   std::shared_ptr<arrow::Table> table = generate_table();
                                                        ^
prog.cpp:42:28: error: ‘write_parquet_file’ was not declared in this scope
   write_parquet_file(*table);
                            ^
stdout
Standard output is empty