Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/zm_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define ZM_SCALE_BASE 100 // The factor by which we bump up 'scale' to simulate FP
#define ZM_RATE_BASE 100 // The factor by which we bump up 'rate' to simulate FP

#define ZM_SQL_BATCH_SIZE 50 // Limit the size of multi-row SQL statements
#define ZM_SQL_SML_BUFSIZ 256 // Size of SQL buffer
#define ZM_SQL_MED_BUFSIZ 1024 // Size of SQL buffer
#define ZM_SQL_LGE_BUFSIZ 8192 // Size of SQL buffer
Expand Down
9 changes: 8 additions & 1 deletion src/zm_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,18 @@ void Event::updateNotes( const StringSetMap &newNoteSetMap )
}

void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps )
{
for (int i = 0; i < n_frames; i += ZM_SQL_BATCH_SIZE) {
AddFramesInternal(n_frames, i, images, timestamps);
}
}

void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps )
{
static char sql[ZM_SQL_LGE_BUFSIZ];
strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) );
int frameCount = 0;
for ( int i = 0; i < n_frames; i++ )
for ( int i = start_frame; i < n_frames && i - start_frame < ZM_SQL_BATCH_SIZE; i++ )
{
if ( !timestamps[i]->tv_sec )
{
Expand Down
3 changes: 3 additions & 0 deletions src/zm_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ friend class EventStream;
void AddFrames( int n_frames, Image **images, struct timeval **timestamps );
void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL );

private:
void AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps );

public:
static const char *getSubPath( struct tm *time )
{
Expand Down