c# - How to stream reads in Couchbase -


i want stream set of documents query in couchbase using single query. problem return a couple of million of documents , want them gradually couchbase, light processing , write result file stream, saving me loading whole result set memory. know if possible in couchbase?

edit: sorry, forgot i'm trying in c#

currently, way directly use paging on query retrieve results in chunks. comes obvious downside of result set (potentially) changing between page retrievals, if have other process continues change data in background. in c# (typing memory, apologies if doesn't compile straightaway):

var pagesize = 100; var pageindex = 0 iqueryresult<dynamic> result = null;  {     var query = string.format("select mybucket.* mybucket limit {0} offset {1}", pagesize, pageindex);     result = await bucket.queryasync<dynamic>(query);      pageindex += result.rows != null ? result.rows.count : 0; } while(result.success && result.rows.count > 0); 

your other option copy result of desired query another, presumably empty, bucket , query/page through them @ leisure, because copy not affected changes original bucket:

insert otherbucket (key _k, value _v)  select meta().id _k, _v mybucket _v <your conditions here>; 

follow paging code described earlier.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -