Save/load sum of values in plots.

This commit is contained in:
Bartosz Taudul 2021-10-17 13:14:44 +02:00
parent 0b190b1a69
commit 8f6a911f1e
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 62 additions and 21 deletions

View File

@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 7 };
enum { Patch = 9 };
enum { Patch = 10 };
}
}

View File

@ -1084,34 +1084,74 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
{
m_data.plots.Data().reserve( sz );
s_loadProgress.subTotal.store( sz, std::memory_order_relaxed );
for( uint64_t i=0; i<sz; i++ )
if( fileVer >= FileVersion( 0, 7, 10 ) )
{
s_loadProgress.subProgress.store( i, std::memory_order_relaxed );
auto pd = m_slab.AllocInit<PlotData>();
uint64_t psz;
f.Read6( pd->type, pd->format, pd->name, pd->min, pd->max, psz );
pd->data.reserve_exact( psz, m_slab );
auto ptr = pd->data.data();
int64_t refTime = 0;
for( uint64_t j=0; j<psz; j++ )
for( uint64_t i=0; i<sz; i++ )
{
int64_t t;
f.Read2( t, ptr->val );
refTime += t;
ptr->time = refTime;
ptr++;
s_loadProgress.subProgress.store( i, std::memory_order_relaxed );
auto pd = m_slab.AllocInit<PlotData>();
uint64_t psz;
f.Read7( pd->type, pd->format, pd->name, pd->min, pd->max, pd->sum, psz );
pd->data.reserve_exact( psz, m_slab );
auto ptr = pd->data.data();
int64_t refTime = 0;
for( uint64_t j=0; j<psz; j++ )
{
int64_t t;
f.Read2( t, ptr->val );
refTime += t;
ptr->time = refTime;
ptr++;
}
m_data.plots.Data().push_back_no_space_check( pd );
}
}
else
{
for( uint64_t i=0; i<sz; i++ )
{
s_loadProgress.subProgress.store( i, std::memory_order_relaxed );
auto pd = m_slab.AllocInit<PlotData>();
uint64_t psz;
f.Read6( pd->type, pd->format, pd->name, pd->min, pd->max, psz );
pd->sum = 0;
pd->data.reserve_exact( psz, m_slab );
auto ptr = pd->data.data();
int64_t refTime = 0;
for( uint64_t j=0; j<psz; j++ )
{
int64_t t;
f.Read2( t, ptr->val );
pd->sum += ptr->val;
refTime += t;
ptr->time = refTime;
ptr++;
}
m_data.plots.Data().push_back_no_space_check( pd );
}
m_data.plots.Data().push_back_no_space_check( pd );
}
}
else
{
for( uint64_t i=0; i<sz; i++ )
if( fileVer >= FileVersion( 0, 7, 10 ) )
{
f.Skip( sizeof( PlotData::name ) + sizeof( PlotData::min ) + sizeof( PlotData::max ) + sizeof( PlotData::type ) + sizeof( PlotData::format ) );
uint64_t psz;
f.Read( psz );
f.Skip( psz * ( sizeof( uint64_t ) + sizeof( double ) ) );
for( uint64_t i=0; i<sz; i++ )
{
f.Skip( sizeof( PlotData::name ) + sizeof( PlotData::min ) + sizeof( PlotData::max ) + sizeof( PlotData::sum ) + sizeof( PlotData::type ) + sizeof( PlotData::format ) );
uint64_t psz;
f.Read( psz );
f.Skip( psz * ( sizeof( uint64_t ) + sizeof( double ) ) );
}
}
else
{
for( uint64_t i=0; i<sz; i++ )
{
f.Skip( sizeof( PlotData::name ) + sizeof( PlotData::min ) + sizeof( PlotData::max ) + sizeof( PlotData::type ) + sizeof( PlotData::format ) );
uint64_t psz;
f.Read( psz );
f.Skip( psz * ( sizeof( uint64_t ) + sizeof( double ) ) );
}
}
}
@ -7579,6 +7619,7 @@ void Worker::Write( FileWrite& f, bool fiDict )
f.Write( &plot->name, sizeof( plot->name ) );
f.Write( &plot->min, sizeof( plot->min ) );
f.Write( &plot->max, sizeof( plot->max ) );
f.Write( &plot->sum, sizeof( plot->sum ) );
int64_t refTime = 0;
sz = plot->data.size();
f.Write( &sz, sizeof( sz ) );