[jira] [Commented] (PARQUET-1196) [C++] Provide a parquet_arrow example project incl. CMake setup

2018-02-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/PARQUET-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16362538#comment-16362538
 ] 

ASF GitHub Bot commented on PARQUET-1196:
-

wesm commented on a change in pull request #436: PARQUET-1196: Example 
parquet_arrow project
URL: https://github.com/apache/parquet-cpp/pull/436#discussion_r167908497
 
 

 ##
 File path: examples/parquet-arrow/src/reader-writer.cc
 ##
 @@ -0,0 +1,134 @@
+// 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 
+#include 
+#include 
+#include 
+#include 
+
+// #0 Build dummy data to pass around
+// To have some input data, we first create an Arrow Table that holds
+// some data.
+std::shared_ptr generate_table() {
+  arrow::Int64Builder i64builder;
+  PARQUET_THROW_NOT_OK(i64builder.Append({1, 2, 3, 4, 5}));
+  std::shared_ptr i64array;
+  PARQUET_THROW_NOT_OK(i64builder.Finish());
+
+  arrow::StringBuilder strbuilder;
+  PARQUET_THROW_NOT_OK(strbuilder.Append("some"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("string"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("content"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("in"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("rows"));
+  std::shared_ptr strarray;
+  PARQUET_THROW_NOT_OK(strbuilder.Finish());
+
+  std::shared_ptr schema = arrow::schema(
+  {arrow::field("int", arrow::int64()), arrow::field("str", 
arrow::utf8())});
+
+  return arrow::Table::Make(schema, {i64array, strarray});
+}
+
+// #1 Write out the data as a Parquet file
+void write_parquet_file(const arrow::Table& table) {
+  std::shared_ptr outfile;
+  PARQUET_THROW_NOT_OK(
+  arrow::io::FileOutputStream::Open("parquet-arrow-example.parquet", 
));
+  // The last argument to the function call is the size of the RowGroup in
+  // the parquet file. Normally you would choose this to be rather large but
+  // for the example, we use a small value to have multiple RowGroups.
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::WriteTable(table, arrow::default_memory_pool(), outfile, 
3));
+}
+
+// #2: Fully read in the file
+void read_whole_file() {
+  std::cout << "Reading parquet-arrow-example.parquet at once" << std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr table;
+  PARQUET_THROW_NOT_OK(reader->ReadTable());
+  std::cout << "Loaded " << table->num_rows() << " rows in " << 
table->num_columns()
+<< " columns." << std::endl;
+}
+
+// #3: Read only a single RowGroup of the parquet file
+void read_single_rowgroup() {
+  std::cout << "Reading first RowGroup of parquet-arrow-example.parquet" << 
std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr table;
+  PARQUET_THROW_NOT_OK(reader->RowGroup(0)->ReadTable());
+  std::cout << "Loaded " << table->num_rows() << " rows in " << 
table->num_columns()
+<< " columns." << std::endl;
+}
+
+// #4: Read only a single column of the whole parquet file
+void read_single_column() {
+  std::cout << "Reading first column of parquet-arrow-example.parquet" << 
std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr array;
+  PARQUET_THROW_NOT_OK(reader->ReadColumn(0, ));
+  arrow::PrettyPrint(*array, 4, ::cout);
 
 Review comment:
   Check status?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific 

[jira] [Commented] (PARQUET-1196) [C++] Provide a parquet_arrow example project incl. CMake setup

2018-02-13 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/PARQUET-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16362537#comment-16362537
 ] 

ASF GitHub Bot commented on PARQUET-1196:
-

wesm commented on a change in pull request #436: PARQUET-1196: Example 
parquet_arrow project
URL: https://github.com/apache/parquet-cpp/pull/436#discussion_r167908530
 
 

 ##
 File path: examples/parquet-arrow/src/reader-writer.cc
 ##
 @@ -0,0 +1,134 @@
+// 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 
+#include 
+#include 
+#include 
+#include 
+
+// #0 Build dummy data to pass around
+// To have some input data, we first create an Arrow Table that holds
+// some data.
+std::shared_ptr generate_table() {
+  arrow::Int64Builder i64builder;
+  PARQUET_THROW_NOT_OK(i64builder.Append({1, 2, 3, 4, 5}));
+  std::shared_ptr i64array;
+  PARQUET_THROW_NOT_OK(i64builder.Finish());
+
+  arrow::StringBuilder strbuilder;
+  PARQUET_THROW_NOT_OK(strbuilder.Append("some"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("string"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("content"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("in"));
+  PARQUET_THROW_NOT_OK(strbuilder.Append("rows"));
+  std::shared_ptr strarray;
+  PARQUET_THROW_NOT_OK(strbuilder.Finish());
+
+  std::shared_ptr schema = arrow::schema(
+  {arrow::field("int", arrow::int64()), arrow::field("str", 
arrow::utf8())});
+
+  return arrow::Table::Make(schema, {i64array, strarray});
+}
+
+// #1 Write out the data as a Parquet file
+void write_parquet_file(const arrow::Table& table) {
+  std::shared_ptr outfile;
+  PARQUET_THROW_NOT_OK(
+  arrow::io::FileOutputStream::Open("parquet-arrow-example.parquet", 
));
+  // The last argument to the function call is the size of the RowGroup in
+  // the parquet file. Normally you would choose this to be rather large but
+  // for the example, we use a small value to have multiple RowGroups.
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::WriteTable(table, arrow::default_memory_pool(), outfile, 
3));
+}
+
+// #2: Fully read in the file
+void read_whole_file() {
+  std::cout << "Reading parquet-arrow-example.parquet at once" << std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr table;
+  PARQUET_THROW_NOT_OK(reader->ReadTable());
+  std::cout << "Loaded " << table->num_rows() << " rows in " << 
table->num_columns()
+<< " columns." << std::endl;
+}
+
+// #3: Read only a single RowGroup of the parquet file
+void read_single_rowgroup() {
+  std::cout << "Reading first RowGroup of parquet-arrow-example.parquet" << 
std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr table;
+  PARQUET_THROW_NOT_OK(reader->RowGroup(0)->ReadTable());
+  std::cout << "Loaded " << table->num_rows() << " rows in " << 
table->num_columns()
+<< " columns." << std::endl;
+}
+
+// #4: Read only a single column of the whole parquet file
+void read_single_column() {
+  std::cout << "Reading first column of parquet-arrow-example.parquet" << 
std::endl;
+  std::shared_ptr infile;
+  PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(
+  "parquet-arrow-example.parquet", arrow::default_memory_pool(), ));
+
+  std::unique_ptr reader;
+  PARQUET_THROW_NOT_OK(
+  parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), ));
+  std::shared_ptr array;
+  PARQUET_THROW_NOT_OK(reader->ReadColumn(0, ));
+  arrow::PrettyPrint(*array, 4, ::cout);
+  std::cout << std::endl;
+}
+
+// #5: Read only a single column of a RowGroup (this is known as ColumnChunk)
+// from the Parquet file.
+void read_single_column_chunk() {
+  std::cout << "Reading first ColumnChunk of the first RowGroup of "
+  

[jira] [Commented] (PARQUET-1196) [C++] Provide a parquet_arrow example project incl. CMake setup

2018-02-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/PARQUET-1196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16361283#comment-16361283
 ] 

ASF GitHub Bot commented on PARQUET-1196:
-

xhochy commented on issue #436: PARQUET-1196: Example parquet_arrow project
URL: https://github.com/apache/parquet-cpp/pull/436#issuecomment-365026617
 
 
   @lorenzhs another one for you!


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [C++] Provide a parquet_arrow example project incl. CMake setup
> ---
>
> Key: PARQUET-1196
> URL: https://issues.apache.org/jira/browse/PARQUET-1196
> Project: Parquet
>  Issue Type: Improvement
>  Components: parquet-cpp
>Reporter: Uwe L. Korn
>Assignee: Uwe L. Korn
>Priority: Major
> Fix For: cpp-1.4.0
>
>
> Currently we only provide a simple example for the low-level interface, we 
> should also provide an example for the prefered high-level parquet_arrow 
> interface. Additionally, we should provide a CMake project that shows how to 
> use parquet as a lib. This can then also be used in CI



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)