EDB delete multiple records question

new topic     » topic index » view thread      » older message » newer message

If anyone has had much experience with the EDB system I would like to know
something:

I am keeping a large list of files in an EDB and scan them every few minutes
to add new ones, or remove missing ones.

The adding part is OK, but when it comes to deleting missing files the code
is terribly inefficient (though not too bad as I don't expect lots to go missing
at once...but you never know)

The deleting code snippet is:
-- check missing files
    msg("Checking missing...")
    bad_carts = {}                 --this is what I'm thinking, NOT USED
    go_again = 1 -- prime loop
    while go_again do
            rec_count = db_table_size()
	    for i = 1 to rec_count do
	    	rec = db_record_data(i)
	    	de = dir(rec[TRK_KEY]) -- TRK_KEY is the full path to the file
                                       -- I do store the key as well
	    	if atom(de) then   -- it'a an error code, not a record (sequence)
                                   -- that is, this file is missing or invalid
	    		msg(sprintf("Deleting record %s", {rec[TRK_NAME]}))
	    		db_delete_record(i)
	    		go_again = 1 -- loop again, 
	    		exit         -- since subsequent record numbers are invalid
	    	else
	    	    go_again = 0 -- ok till now, keep loop condition valid
	    	end if
	    end for    	
    end while
    files = db_table_size()
    tt = time() - t0
    msg(sprintf("Done. %d files, %4.2f seconds", {files, tt}))


My question(s) is/are:

Is it possible to use the "bad_cart" sequence to collect bad entries then
delete them all at once (my feeling is not, since you'll still be looping
through them with the same problem of subsequent record no.s being invalid)?

Is this the most efficient way of doing this?  With anything more than a few
hundred missing files this can take upwards of 20 seconds.

I'm not too worried about this since each scan will be 5 mins apart, but it
seems to me to be a missing feature of the EDB system, 
eg db_delete_multiple(sequence_of_ids)

Gary

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu