Skip to content

Commit

Permalink
Adjusted hello world with serialize()
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinmoein committed May 29, 2024
1 parent fb652a2 commit ac3df3b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions examples/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,13 @@ int main(int, char *[]) {
ul_df2.write<std::ostream, std::string, double>(std::cout, io_format::csv2);
ibm_df.write<double, long>("/tmp/test.json", io_format::json);

// You can convert a DataFrame to a string and from a string back into a DataFrame. This could be used to transmit a
// DataFrame from one place to another or store a DataFrame in databases, caches, ...
// You can serialize and deserialize the DataFrame both in string and binary formats.
// This could be used to transmit a DataFrame from one node to another or store a DataFrame in databases, caches, ...
//
const std::string ibm_df_as_str = ibm_df.to_string<double, long>();
const std::string ibm_df_serialized = ibm_df.serialize<double, long>();
StrDataFrame ibm_df_2;

// Since we convert from native type to string and back, if you have floating point numbers with long precisions, you may
// run into precision mismatches. to_string() has a precision parameter you can adjust. The default is 12 which is a
// relatively high precision.
//
ibm_df_2.from_string(ibm_df_as_str.c_str());
ibm_df_2.deserialize(ibm_df_serialized);
// std::cout << ibm_df_as_str << std::endl; // Large output

using ul_idx_t = ULDataFrame::IndexType; // This is just unsigned long.
Expand Down

0 comments on commit ac3df3b

Please sign in to comment.