inline void load(iarchive& iarc) { /* * The old datetime representation is simply 56 bits for the timestamp * and 8 bits for the timezone at 1/2 hour increments, and no microsecond. * for a total of 64 bits. * * To ensure backward compatibility, we have to some tricks. * - We shift the timezone value to EXCLUDE the timezone range the old * format allowed. (this will be [-24, 24] since at 1/2 hour offsets, * 24 is the maximum value possible). * * This allows us to simply by inspection of the * timezone value, determine if it was an old format or a new format * timezone. * * - So to deserialize, we first deserialize 8 bytes, check the timezone * value, to determine if it is old format or new format. If it is new * format, deserialize a further 4 bytes. * * If it is old format, scale up the timezone value by 2 (to get it to * 15 minute increments, and clear the microsecond value. */ iarc.read(reinterpret_cast<char*>(this), 8); if (m_tz_15min_offset > - _LEGACY_TIMEZONE_SHIFT && m_tz_15min_offset < _LEGACY_TIMEZONE_SHIFT ) { // old format set_time_zone_offset(m_tz_15min_offset * 2); m_microsecond = 0; } else { // new format iarc.read(reinterpret_cast<char*>(&m_microsecond), sizeof(m_microsecond)); } }
void unity_sgraph::load(iarchive& iarc) { log_func_entry(); std::lock_guard<mutex> lock(dag_access_mutex); char buf[256] = ""; size_t magic_header_size = strlen(GRAPH_MAGIC_HEADER); iarc.read(buf, magic_header_size); if (strcmp(buf, GRAPH_MAGIC_HEADER)) { log_and_throw(std::string("Invalid graph file.")); } size_t num_partitions = 0; iarc >> num_partitions; sgraph* g = new sgraph(num_partitions); iarc >> *g; m_graph.reset(unity_sgraph::get_dag()->add_value(g)); }