Skip to content

Commit

Permalink
add rubbish code for reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Sep 14, 2023
1 parent 17a4922 commit 18c6657
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 2 additions & 3 deletions cpp/examples/arrow/dataset_parquet_scan_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ struct Configuration {

// Indicates to the Scan operator which columns are requested. This
// optimization avoid deserializing unneeded columns.
std::vector<std::string> projected_columns = {"pickup_at", "dropoff_at",
"total_amount"};
std::vector<std::string> projected_columns = {"t"};

// Indicates the filter by which rows will be filtered. This optimization can
// make use of partition information and/or file metadata if possible.
cp::Expression filter = cp::greater(cp::field_ref("total_amount"), cp::literal(100.0f));
cp::Expression filter = cp::greater(cp::field_ref("t"), cp::literal(arrow::DurationScalar{1, arrow::TimeUnit::NANO}));

ds::InspectOptions inspect_options{};
ds::FinishOptions finish_options{};
Expand Down
16 changes: 10 additions & 6 deletions cpp/examples/parquet/parquet_arrow/reader_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,20 @@ void read_whole_file() {
std::cout << "Reading parquet-arrow-example.parquet at once" << std::endl;
std::shared_ptr<arrow::io::ReadableFile> infile;
PARQUET_ASSIGN_OR_THROW(infile,
arrow::io::ReadableFile::Open("parquet-arrow-example.parquet",
arrow::io::ReadableFile::Open("/Users/fuxuwei/workspace/CMakeLibs/arrow/test.parquet",
arrow::default_memory_pool()));

std::unique_ptr<parquet::arrow::FileReader> reader;
PARQUET_THROW_NOT_OK(
parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), &reader));
std::shared_ptr<::arrow::Schema> schema_ptr;
PARQUET_THROW_NOT_OK(reader->GetSchema(&schema_ptr));
std::cout << schema_ptr->ToString(true) << std::endl;
std::shared_ptr<arrow::Table> table;
PARQUET_THROW_NOT_OK(reader->ReadTable(&table));
std::cout << "Loaded " << table->num_rows() << " rows in " << table->num_columns()
<< " columns." << std::endl;
std::cout << table->ToString() << std::endl;
}

// #3: Read only a single RowGroup of the parquet file
Expand Down Expand Up @@ -131,10 +135,10 @@ void read_single_column_chunk() {
}

int main(int argc, char** argv) {
std::shared_ptr<arrow::Table> table = generate_table();
write_parquet_file(*table);
// std::shared_ptr<arrow::Table> table = generate_table();
// write_parquet_file(*table);
read_whole_file();
read_single_rowgroup();
read_single_column();
read_single_column_chunk();
// read_single_rowgroup();
// read_single_column();
// read_single_column_chunk();
}

0 comments on commit 18c6657

Please sign in to comment.