Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming support #18

Closed
jorgebay opened this issue Aug 21, 2013 · 2 comments
Closed

Streaming support #18

jorgebay opened this issue Aug 21, 2013 · 2 comments

Comments

@jorgebay
Copy link
Owner

Provide streaming support to avoid storing in memory large buffers when retrieving info from Cassandra.

Use cases

  • Retrieve large blobs and stream it.
  • Retrieve large sets of rows and use them before the all the rows had been received.

The resulting stream is readable and buffers if no consumer is pulling data from it.

Sample

//with Express
app.get('/img/big.png', function(req, res) {
  var query = 'SELECT id, big_blob FROM table1 WHERE ID=1';
  //pass the stream as an argument
  client.executeToStream(query, function (err, row, blobStream) {
    //you can access the row values
    var id = row.get('id');
    //you can access the stream.Readable that streams data of big_blob column 
    //as soon as is received
    blobStream.pipe(res);
  });
})

Use cases: queries to stream

//one *BIG* field in one row
query = 'SELECT id, big_blog FROM table1 WHERE ID=?'

//some "context" non binary fields, multiple rows
query = 'SELECT id, key, text, big_blob FROM table1';

//stream just rows (added Sep 11th)
query = 'SELECT * FROM table1';
@ottes
Copy link

ottes commented Sep 11, 2013

I'm interested too! Have to receive a lot complete rows and that would blow out my memory

jorgebay added a commit that referenced this issue Sep 12, 2013
jorgebay added a commit that referenced this issue Sep 13, 2013
* Read streaming column.
* New unit test for delayed reading of the stream.
@jorgebay
Copy link
Owner Author

It took a while but its finished!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants