| Signature | Description | Parameters |
|---|---|---|
bool from_string(const char *data_frame); |
This is a convenient function (simple implementation) to restore a DataFrame from a string that was previously generated by calling to_string(). It utilizes the read() member function of DataFrame. These functions could be used to transmit a DataFrame from one place to another or store a DataFrame in databases, caches, ... NOTE: The choice between to_string() and serialize() depends on the dataset. Some datasets (i.e. US Options market data) mostly contain small floating-point/integer numbers such as '.5', '.75' or '123' and so on. These set of numbers will produce a smaller buffer size in string form compared with binary form, especially if there are billions of them. But generally, in most cases binary form is more efficient. |
data_frame: A null terminated string that was generated by calling to_string(). It must contain a complete DataFrame |
std::future<bool> from_string_async(const char *data_frame); |
Same as from_string() above, but executed asynchronously | |
bool deserialize(const std::string &data_frame); |
This is a convenient function (conceptually similar to from_string()) to restore a DataFrame from a binary buffer that was previously generated by calling serialize(). It utilizes the read() member function of DataFrame. These functions could be used to transmit a DataFrame from one place to another or store a DataFrame in databases, caches, ... NOTE: The choice between to_string() and serialize() depends on the dataset. Some datasets (i.e. US Options market data) mostly contain small floating-point/integer numbers such as '.5', '.75' or '123' and so on. These set of numbers will produce a smaller buffer size in string form compared with binary form, especially if there are billions of them. But generally, in most cases binary form is more efficient. |
data_frame: A std::string that was generated by calling serialize(). It must contain a complete DataFrame in binary format |
std::future<bool> deserialize_async(const std::string &data_frame); |
Same as deserialize() above, but executed asynchronously |
static void test_to_from_string() { std::cout << "\nTesting to_from_string() ..." << std::endl; StlVecType<unsigned long> idx = { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123457, 123458, 123459, 123460, 123461, 123462, 123466 }; StlVecType<double> d1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; StlVecType<double> d2 = { 8, 9, 10, 11, 12, 13, 14, 20, 22, 23, 30, 31, 32, 1.89 }; StlVecType<double> d3 = { 15, 16, 17, 18, 19, 20, 21, 0.34, 1.56, 0.34, 2.3, 0.1, 0.89, 0.45 }; StlVecType<int> i1 = { 22, 23, 24, 25, 99, 100, 101, 3, 2 }; StlVecType<std::string> strvec = { "zz", "bb", "cc", "ww", "ee", "ff", "gg", "hh", "ii", "jj", "kk", "ll", "mm", "nn" }; MyDataFrame df; df.load_data(std::move(idx), std::make_pair("col_1", d1), std::make_pair("col_2", d2), std::make_pair("col_3", d3), std::make_pair("col_4", i1), std::make_pair("str_col", strvec)); auto vw = df.get_view<double, int, std::string>({ "col_1", "col_2", "col_3", "col_4", "str_col" }); std::future<std::string> f = df.to_string_async<double, int, std::string>(); const std::string str_dump = f.get(); const std::string str_dump_from_vw = vw.to_string<double, int, std::string>(); MyDataFrame df2; df2.from_string(str_dump.c_str()); assert((df.is_equal<double, int, std::string>(df2))); assert(str_dump == str_dump_from_vw); } // ---------------------------------------------------------------------------- static void test_serialize() { std::cout << "\nTesting test_serialize() ..." << std::endl; StlVecType<unsigned long> idx = { 123450, 123451, 123452, 123453, 123454, 123455, 123456, 123457, 123458, 123459, 123460, 123461, 123462, 123466 }; StlVecType<double>. d1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; StlVecType<double> d2 = { 8, 9, 10, 11, 12, 13, 14, 20, 22, 23, 30, 31, 32, 1.89 }; StlVecType<double> d3 = { 15, 16, 17, 18, 19, 20, 21, 0.34, 1.56, 0.34, 2.3, 0.1, 0.89, 0.45 }; StlVecType<int> i1 = { 22, 23, 24, 25, 99, 100, 101, 3, 2 }; StlVecType<std::string> strvec = { "zz", "bb", "cc", "ww", "ee", "ff", "gg", "hh", "ii", "jj", "kk", "ll", "mm", "nn" }; MyDataFrame df; df.load_data(std::move(idx), std::make_pair("col_1", d1), std::make_pair("col_2", d2), std::make_pair("col_3", d3), std::make_pair("col_4", i1), std::make_pair("str_col", strvec)); std::future<std::string> ser_fut = df.serialize_async<double, int, std::string>(); const std::string ser = ser_fut.get(); MyDataFrame df2; std::future<bool> deser_fut = df2.deserialize_async(ser); deser_fut.get(); assert((df.is_equal<double, int, std::string>(df2))); }