duoshuo / php-cassandra

php Cassandra driver which support Protocol v3 (Cassandra 2.1) and asynchronous requests
MIT License
153 stars 53 forks source link

Question about blob size inserted at the beginning of a blob #50

Closed andreassolberg closed 9 years ago

andreassolberg commented 9 years ago

We're having issues with inserting and retrieving blobs.

When blobs are inserted, the data size is added as a prefix in form of an 4 byte integer value is. This can be found here:

return pack('N', strlen($this->_value)) . $this->_value;

When data is retrieved from cassandra, this 4 bytes is present, and to make the content identical to what I insert, I will need to strip away the content substr($data, 4).

It seems likely to us that the correct behaviour should be to not prefix the data with the length, at least when we insert blobs with other (non-php) libraries the content is not prefixed.

I can send a pull request, but I wanted to ask about it first. Looking forwards to hear others opinions / experiences with this.

shen2 commented 9 years ago

Thanks for your issue. I've fixed this bug in the latest revision. Have a try.

andreassolberg commented 9 years ago

Thanks. I have verified this now, and it works as expected.