the design pattern explained here: http://www.tutorialspoint.com/design_pattern/filter_pattern.htm
i'm working on software similar adobe lightroom or acdsee different purposes. user (photographer) able import thousands of images hard drive (it wouldn't weird have on 100k/200k images).
we have side panel users can create custom "filters" expressions like:
does contain keyword: "car" , not contain keyword "woods" , ( camera model "nikon d300s" or camera model "canon 7d mark ii" ) , not directory "c:\today_pictures" you can idea above example.
we have sqlite database image information stored. question is, should load photo objects memory database first time program loaded , implement criteria/filter design pattern explained in website cited above our criteria classes filter objects or better criteria classes generate sql query executed in order retrieve what's needed database?
we developing program c++ (qt).
tl;dr: it's implemented in sqlite3, , @ how long took. you'll face same burden.
it'd horrible case of data duplication read data database , store again in data structure. use database queries implement query user gave you. let database execute query. that's databases for.
by reimplementing search/query system ~500k records, you'll rewriting large chunks of bog-standard database yourself. it'd pointless exercise. sqlite3 very tested , foolproof. it'll cost thousands of hours of work reimplement small fraction of capabilities and reliability/resiliency. if doesn't scream "reinventing wheel", don't know does.
the database allows implement lookahead/dropdowns aid user in writing query. example, you're typing out "camera model is", user can have option of autocompletion or dropdown select 1 or more models from.
you paid "price" of database, it'd shame go waste. so, use it. it'll give lots of leverage, , allow implement features 2 orders of magnitude faster otherwise.
the pattern you've linked pattern. doesn't mean it's exact blueprint of how design application perform on real data. you'll be, eventually, fighting things such concurrency (a file scanning thread running update metadata), indexing, resiliency in face of crashes, etc. in end you'll end big chunks of sqlite reimplemented particular application. 500k metadata records nothing much, if design query translator , support proper indexes, it'll work well.
Comments
Post a Comment