evseevnn-zz / php-cassandra-binary

PHP library for Cassandra database via a binary protocol.
http://evseevnn.github.io/php-cassandra-binary/
MIT License
69 stars 33 forks source link

Reading while at end of stream error #27

Open aslubsky opened 10 years ago

aslubsky commented 10 years ago

Hi

CREATE TABLE users_log (
  session_token ascii,
  user_id int,
  site_id int,
  role_id int,
  user_name varchar,
  date_start timestamp,
  date_stop timestamp,
  ip varchar,
  agent text,
  tags list<text>,
  PRIMARY KEY (session_token)
);

SELECT * FROM "users_log" WHERE "site_id" = 3 ALLOW FILTERING ;

in cqlsh - OK by php-cassandra-binary - "Reading while at end of stream"

file "/vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/Rows.php"
line 65
trace:

#0 vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/DataStream.php(59): evseevnn\Cassandra\Protocol\Response\DataStream->read(2)
#1 vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/DataStream.php(142): evseevnn\Cassandra\Protocol\Response\DataStream->readShort()
#2 vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/DataStream.php(261): evseevnn\Cassandra\Protocol\Response\DataStream->readList(Array)
#3 vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/Rows.php(63): evseevnn\Cassandra\Protocol\Response\DataStream->readByType(Array)
#4 vendor/evseevnn/php-cassandra-binary/src/Protocol/Response/Rows.php(132): evseevnn\Cassandra\Protocol\Response\Rows->current()
#5 vendor/evseevnn/php-cassandra-binary/src/Database.php(182): evseevnn\Cassandra\Protocol\Response\Rows->asArray()
#6 src/Base/Cassandra/Collection.php(98): evseevnn\Cassandra\Database->query('SELECT * FROM "...', Array)

Thanks

ghost commented 10 years ago

It's happening to me as well. Please help. Thanks.

It happens when you have a column like this: tags list,

But you never set a value to such column (of list type)

penfold45 commented 10 years ago

Hi I am getting this too.

I have columns that do not always have data and in these circumstances I get this error.

Would love to see a fix for this soon ish otherwise not sure I can release this into production as it casuses no end of notice errors for me.

Thanks

aslubsky commented 10 years ago

I fixed it in my fork https://github.com/aslubsky/php-cassandra-binary Fix is not very good (dirty try cath) but work and may be used as temporary solution

evseevnn-zz commented 10 years ago

ok, I'll try to fix it tomorrow during the day

penfold45 commented 10 years ago

Hi did get around to looking at this?

steambao commented 10 years ago

Can confirm this occurs when reading NULL'ed MAP<><> column types as: readShort() is trying to get a count from an empty $this->data string (len = 0).

Like aslubsky, did a temp fix in my fork 344ae09d1c856717337f4c9491bf2e46f77d1d88

teanooki commented 10 years ago

There is a general problem with NULL values. I used the development branch and added all the ($isCollectionElement = false) parameters in DataStream.php from the master branch. That fixed the Problem with the maps. The most important change was adding this:

    public function readByType(array $type, $isCollectionElement = false) {
        if (strlen($this->data) <= 0){
            return null;
        }