Skip to content

Commit

Permalink
Added FixedSizeString as one of the types that can be read/written fr…
Browse files Browse the repository at this point in the history
…om/to files
  • Loading branch information
hosseinmoein committed Oct 17, 2024
1 parent d7a0097 commit eda95ce
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 22 deletions.
1 change: 1 addition & 0 deletions docs/HTML/DateTime.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<H2 ID="0"><font color="blue">Summary <font size="+4">&#9730;</font></font></font></H2>
<font size="+1">Since DataFrame is a statistical library, it often deals with time-series data. So, it needs to keep track of time.<BR>
The most efficient way of indexing DataFrame by time is to use an index type of time_t for second precision or double or long long integer for more precision. DateTime class provides a more elaborate handling of time. Also, it is a general handy DateTime object. DateTime is a cool and handy object to manipulate date/time with nanosecond precision and multi timezone capability. It has a very simple and intuitive interface that allows you to break date/time to their components, reassemble date/time from their components, advance or pullback date/time with different granularities, and more.</font><BR>
<I>DateTime</I> is one of the types that <I>DataFrame</I> library can read/write from/to files and serialization.<BR>

<BR><HR COLOR="Gray" SIZE="5">

Expand Down
4 changes: 2 additions & 2 deletions docs/HTML/VirtualString.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
</td>
<td>
<I>FixedSizeString</I> is a fixed-size and null-terminated string. Since the size is a template parameter, each different size is a different object type. But since <I>FixedSizeString</I> is derived from <I>VirtualString</I> (which is not a templated object), different size instances can be interchanged through references to <I>VirtualString</I>. <I>VirtualString</I> implements almost all of std::string functionalities.<BR>
There is no dynamic memory allocation and deallocation involved here.<BR>
<I>FixedSizeString</I> is the type of column names in DataFrame and could be used by users for their other purposes.
<I>FixedSizeString</I> does not do any dynamic memory allocation/deallocation.<BR>
<I>FixedSizeString</I> "Convenient typedefs" are among the types that <I>DataFrame</I> library can read/write from/to files and serialization<BR>

</td>
</tr>
Expand Down
10 changes: 8 additions & 2 deletions docs/HTML/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@
string -- std::string
string -- const char *
string -- char *
vstr32 -- Fixed-size string of 31 char length
vstr64 -- Fixed-size string of 63 char length
vstr128 -- Fixed-size string of 127 char length
vstr512 -- Fixed-size string of 511 char length
vstr1K -- Fixed-size string of 1023 char length
vstr2K -- Fixed-size string of 2047 char length
bool -- bool
DateTime -- DateTime data in format of
&lt;Epoch seconds&gt;.&lt;nanoseconds&gt;
(1516179600.874123908)
&lt;Epoch seconds&gt;.&lt;nanoseconds&gt;
(1516179600.874123908)
</PRE>
In case of io_format::csv2, io_format::csv, and io_format::binary the following additional types are also supported:
<PRE>
Expand Down
10 changes: 8 additions & 2 deletions docs/HTML/write.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,16 @@
string -- std::string
string -- const char *
string -- char *
vstr32 -- Fixed-size string of 31 char length
vstr64 -- Fixed-size string of 63 char length
vstr128 -- Fixed-size string of 127 char length
vstr512 -- Fixed-size string of 511 char length
vstr1K -- Fixed-size string of 1023 char length
vstr2K -- Fixed-size string of 2047 char length
bool -- bool
DateTime -- DateTime data in format of
&lt;Epoch seconds&gt;.&lt;nanoseconds&gt;
(1516179600.874123908)
&lt;Epoch seconds&gt;.&lt;nanoseconds&gt;
(1516179600.874123908)
</PRE>
In case of io_format::csv2, io_format::csv, and io_format::binary the following additional types are also supported:
<PRE>
Expand Down
8 changes: 7 additions & 1 deletion include/DataFrame/Internals/DataFrame_misc.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ DataFrame<I, H>::print_binary_functor_<Ts ...>::operator() (const T &vec) {
const long local_start_row = std::min (long(vec.size()), start_row);
const long local_end_row = std::min (long(vec.size()), end_row);

if constexpr (std::is_same_v<ValueType, std::string>)
if constexpr (std::is_same_v<ValueType, std::string> ||
std::is_same_v<ValueType, String32> ||
std::is_same_v<ValueType, String64> ||
std::is_same_v<ValueType, String128> ||
std::is_same_v<ValueType, String512> ||
std::is_same_v<ValueType, String1K> ||
std::is_same_v<ValueType, String2K>)
_write_binary_string_(os, vec, local_start_row, local_end_row);
else if constexpr (std::is_same_v<ValueType, DateTime>)
_write_binary_datetime_(os, vec, local_start_row, local_end_row);
Expand Down
3 changes: 2 additions & 1 deletion include/DataFrame/Internals/DataFrame_private_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1373,8 +1373,9 @@ struct ColVectorPushBack_<DateTime, StlVecType<DateTime>, Dummy> {

// ----------------------------------------------------------------------------

template<typename STR>
inline static void
json_str_col_vector_push_back_(StlVecType<std::string> &vec,
json_str_col_vector_push_back_(StlVecType<STR> &vec,
std::istream &file) {

char value[2048];
Expand Down
Loading

0 comments on commit eda95ce

Please sign in to comment.