aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libtmi8/include/tmi8/kv6_parquet.hpp
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-05-02 20:27:40 +0200
committerLibravatar Rutger Broekhoff2024-05-02 20:27:40 +0200
commit17a3ea880402338420699e03bcb24181e4ff3924 (patch)
treeda666ef91e0b60d20aa0b01529644c136fd1f4ab /lib/libtmi8/include/tmi8/kv6_parquet.hpp
downloadoeuf-17a3ea880402338420699e03bcb24181e4ff3924.tar.gz
oeuf-17a3ea880402338420699e03bcb24181e4ff3924.zip
Initial commit
Based on dc4ba6a
Diffstat (limited to 'lib/libtmi8/include/tmi8/kv6_parquet.hpp')
-rw-r--r--lib/libtmi8/include/tmi8/kv6_parquet.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/libtmi8/include/tmi8/kv6_parquet.hpp b/lib/libtmi8/include/tmi8/kv6_parquet.hpp
new file mode 100644
index 0000000..33b57ca
--- /dev/null
+++ b/lib/libtmi8/include/tmi8/kv6_parquet.hpp
@@ -0,0 +1,46 @@
1// vim:set sw=2 ts=2 sts et:
2
3#ifndef OEUF_LIBTMI8_KV6_PARQUET_HPP
4#define OEUF_LIBTMI8_KV6_PARQUET_HPP
5
6#include <filesystem>
7
8#include <arrow/api.h>
9#include <arrow/io/api.h>
10#include <parquet/arrow/writer.h>
11
12static const size_t MAX_PARQUET_CHUNK = 10000;
13
14struct ParquetBuilder {
15 ParquetBuilder();
16 arrow::Result<std::shared_ptr<arrow::Table>> getTable();
17
18 std::shared_ptr<arrow::Schema> schema;
19
20 arrow::StringBuilder types;
21 arrow::StringBuilder data_owner_codes;
22 arrow::StringBuilder line_planning_numbers;
23 arrow::Date32Builder operating_days;
24 arrow::UInt32Builder journey_numbers;
25 arrow::UInt8Builder reinforcement_numbers;
26 arrow::TimestampBuilder timestamps{arrow::timestamp(arrow::TimeUnit::SECOND), arrow::default_memory_pool()};
27 arrow::StringBuilder sources;
28 arrow::Int16Builder punctualities;
29 arrow::StringBuilder user_stop_codes;
30 arrow::UInt16Builder passage_sequence_numbers;
31 arrow::UInt32Builder vehicle_numbers;
32 arrow::UInt32Builder block_codes;
33 arrow::StringBuilder wheelchair_accessibles;
34 arrow::UInt8Builder number_of_coaches;
35 arrow::Int32Builder rd_ys;
36 arrow::Int32Builder rd_xs;
37 arrow::UInt32Builder distance_since_last_user_stops;
38};
39
40[[nodiscard]]
41arrow::Status writeArrowRecordsAsParquetFile(arrow::RecordBatchReader &rbr, std::filesystem::path filename);
42
43[[nodiscard]]
44arrow::Status writeArrowTableAsParquetFile(const arrow::Table &table, std::filesystem::path filename);
45
46#endif // OEUF_LIBTMI8_KV6_PARQUET_HPP