File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -289,13 +289,27 @@ Then try to restart Plume
289289 }
290290
291291 pub fn fill ( & self , conn : & Connection ) -> Result < ( ) > {
292- for post in posts:: table
293- . filter ( posts:: published. eq ( true ) )
294- . load :: < Post > ( conn) ?
295- {
296- self . update_document ( conn, & post) ?
292+ let mut writer = self . writer . lock ( ) . unwrap ( ) ;
293+ let writer = writer. as_mut ( ) . unwrap ( ) ;
294+ writer. delete_all_documents ( ) . unwrap ( ) ;
295+
296+ const PAGE_SIZE : i64 = 8192 ;
297+ let mut cursor = -1 ;
298+ loop {
299+ let posts = posts:: table
300+ . filter ( posts:: published. eq ( true ) )
301+ . filter ( posts:: id. gt ( cursor) )
302+ . order ( posts:: id. asc ( ) )
303+ . limit ( PAGE_SIZE )
304+ . load :: < Post > ( conn) ?;
305+ for post in posts. iter ( ) {
306+ self . add_document ( conn, post) ?;
307+ cursor = post. id ;
308+ }
309+ if posts. len ( ) < PAGE_SIZE as usize {
310+ break Ok ( ( ) )
311+ }
297312 }
298- Ok ( ( ) )
299313 }
300314
301315 pub fn commit ( & self ) {
You can’t perform that action at this time.
0 commit comments