php-cassandra-binary icon indicating copy to clipboard operation
php-cassandra-binary copied to clipboard

Reading while at end of stream error

Open aslubsky opened this issue 10 years ago • 7 comments

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

aslubsky avatar Sep 26 '14 07:09 aslubsky

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)

ghost avatar Sep 29 '14 08:09 ghost

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

penfold45 avatar Oct 14 '14 14:10 penfold45

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

aslubsky avatar Oct 14 '14 14:10 aslubsky

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

evseevnn-zz avatar Oct 14 '14 14:10 evseevnn-zz

Hi did get around to looking at this?

penfold45 avatar Oct 21 '14 09:10 penfold45

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

steambao avatar Nov 18 '14 19:11 steambao

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;
        }

teanooki avatar Dec 03 '14 20:12 teanooki