15 runtime(struct timeval *st)
19 double dt = (tv.tv_sec - st->tv_sec) +
20 (tv.tv_usec - st->tv_usec) / 1000000.;
24 int del_clip_set(theDb *db, int clip_id)
26 printf("del clip %d\n",clip_id);
27 if( db->clip_set.FindId(clip_id) ) return 1;
28 db->clip_set.Destruct();
29 db->clip_set.Deallocate();
31 if( Clip_viewsLoc::ikey_Clip_access(db->clip_views,clip_id).Find() ) return 1;
32 db->clip_views.Destruct();
33 db->clip_views.Deallocate();
35 while( !TimelineLoc::ikey_Sequences(db->timeline,clip_id,0).Locate() ) {
36 if( clip_id != (int)db->timeline.Clip_id() ) break;
37 int frame_id = db->timeline.Frame_id();
38 db->timeline.Destruct();
39 db->timeline.Deallocate();
40 if( !TimelineLoc::ikey_Timelines(db->timeline, frame_id).Locate() &&
41 frame_id == (int)db->timeline.Frame_id() ) continue;
42 if( db->video_frame.FindId(frame_id) ) continue;
43 db->video_frame.Destruct();
44 db->video_frame.Deallocate();
50 int main(int ac, char **av)
57 if( ac < 3 ) { printf("usage: %s in.db out.db\n",av[0]); exit(1); }
58 const char *ifn = av[1];
59 if( idb.open(ifn) ) { perror(ifn); exit(1); }
60 const char *ofn = av[2];
62 int ofd = open(ofn,O_RDWR+O_CREAT+O_TRUNC,0666);
63 if( ofd < 0 ) { perror(ofn); return 1; }
64 if( odb.make(ofd) ) { perror(ofn); exit(1); }
70 while( !idb.clip_set.LocateId(Db::keyGE,next_id) ) {
71 next_id = idb.clip_set.id() + 1;
72 if( Clip_viewsLoc::ikey_Clip_access(idb.clip_views,idb.clip_set.id()).Find() ) {
73 printf("clip %d, missed\n", idb.clip_set.id()); continue;
75 time_t t = (time_t) idb.clip_views.Access_time();
76 long dt = st.tv_sec - t;
77 // 3 weeks + access count days
78 if( dt < 3*7*24*60*60 + (long)(idb.clip_views.Access_count()*24*60*60) )
80 del_clip_set(&idb, idb.clip_set.id());
84 odb.copy(&idb,idb.objects);
90 double secs = runtime(&st);
91 printf("%f secs\n",secs);