55namespace Nyxus {
66
77#ifdef USE_ARROW
8- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::create_arrow_file (const Nyxus::SaveOption& arrow_file_type,
9- const std::string& output_path,
10- const std::vector<std::string>& header) {
118
12- if (output_path == " " ){
13- return {false , " No path provided for Arrow file." };
9+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::create_arrow_file (
10+ const Nyxus::SaveOption& arrow_file_type,
11+ const std::string& output_path,
12+ const std::vector<std::string>& header) {
13+
14+ if (output_path == " " ) {
15+ return { false , " No path provided for Arrow file." };
1416 }
1517
1618 this ->arrow_file_path_ = output_path;
17- if (auto parent_path = fs::path (output_path).parent_path ();
18- !parent_path.empty () && !fs::is_directory (parent_path)){
19+ if (auto parent_path = fs::path (output_path).parent_path ();
20+ !parent_path.empty () && !fs::is_directory (parent_path)) {
1921 try {
2022 fs::create_directory (parent_path);
21- } catch (std::exception& e) {
22- return {false , e.what ()};
2323 }
24- }
24+ catch (std::exception& e) {
25+ return { false , e.what () };
26+ }
27+ }
2528
2629 std::optional<std::string> error_msg;
2730 std::tie (writer_, error_msg) = WriterFactory::create_writer (arrow_file_path_, header);
2831 if (writer_) {
29- return {true , std::nullopt };
30- } else {
31- return {false , error_msg};
32+ return { true , std::nullopt };
33+ }
34+ else {
35+ return { false , error_msg };
3236 }
3337 }
3438
35-
36- std::string ArrowOutputStream::get_arrow_path () {
39+ std::string ArrowOutputStream::get_arrow_path ()
40+ {
3741 return arrow_file_path_;
3842 }
3943
40- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::write_arrow_file (const std::vector<std::tuple<std::vector<std::string>, int , std::vector<double >>>& features){
41- if (writer_){
44+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::write_arrow_file (
45+ const std::vector<FTABLE_RECORD>& features) {
46+ if (writer_) {
4247 auto status = writer_->write (features);
4348 if (status.ok ()) {
44- return {true , std::nullopt };
49+ return { true , std::nullopt };
4550 }
4651 else {
47- return {false , status.ToString ()};
52+ return { false , status.ToString () };
4853 }
4954 }
50- return {false , " Arrow Writer is not initialized." };
55+ return { false , " Arrow Writer is not initialized." };
5156 }
52- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::close_arrow_file () {
53- if (writer_){
57+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::close_arrow_file () {
58+ if (writer_) {
5459 auto status = writer_->close ();
5560 if (status.ok ()) {
56- return {true , std::nullopt };
61+ return { true , std::nullopt };
5762 }
5863 else {
59- return {false , status.ToString ()};
64+ return { false , status.ToString () };
6065 }
6166 }
62- return {false , " Arrow Writer is not initialized." };
67+ return { false , " Arrow Writer is not initialized." };
6368 }
6469
65- #else
66- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::create_arrow_file (const Nyxus::SaveOption& arrow_file_type,
67- const std::string& arrow_file_path,
68- const std::vector<std::string>& header) {
69-
70- std::cerr << " Apache Arrow functionality is not available. Please install Nyxus with Arrow enabled to use this functionality." << std::endl;
70+ #else
7171
72- return {false , " Apache Arrow functionality is not available." };
72+ // stubs
73+
74+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::create_arrow_file (
75+ const Nyxus::SaveOption& arrow_file_type,
76+ const std::string& arrow_file_path,
77+ const std::vector<std::string>& header)
78+ {
79+ std::cerr << " Apache Arrow functionality is not available. Please install Nyxus with Arrow enabled to use this functionality." << std::endl;
80+ return { false , " Apache Arrow functionality is not available." };
7381 }
7482
75- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::write_arrow_file (const std::vector<std::tuple<std::vector<std::string>, int , std::vector<double >>>& features){
83+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::write_arrow_file (const std::vector<FTABLE_RECORD>& features)
84+ {
7685 std::cerr << " Apache Arrow functionality is not available. Please install Nyxus with Arrow enabled to use this functionality." << std::endl;
77- return {false , " Apache Arrow functionality is not available." };
86+ return { false , " Apache Arrow functionality is not available." };
7887 }
79- std::tuple<bool , std::optional<std::string>> ArrowOutputStream::close_arrow_file (){
88+ std::tuple<bool , std::optional<std::string>> ArrowOutputStream::close_arrow_file ()
89+ {
8090 std::cerr << " Apache Arrow functionality is not available. Please install Nyxus with Arrow enabled to use this functionality." << std::endl;
81- return {false , " Apache Arrow functionality is not available." };
91+ return { false , " Apache Arrow functionality is not available." };
8292 }
8393
94+ #endif
95+ };
8496
85- #endif
86- };
0 commit comments