mjpearson / Pandra

Cassandra abstraction layer and keyspace scaffolder for PHP developers --- ABANDONED.
GNU Lesser General Public License v3.0
93 stars 11 forks source link

TException: A long is exactly 8 bytes #37

Closed beiercai closed 14 years ago

beiercai commented 14 years ago

Maybe I'm missing something here, but I can't seem to save a column defined as LongType

              <ColumnFamily Name="MyTest"
                ColumnType="Super"
                CompareWith="LongType"
                KeyCached="0.1"
                CompareSubcolumnsWith="BytesType" />

Here is the PHP code:

if (!PandraCore::auto('192.168.1.1.')) {
die(PandraCore::$lastError);
}

//super column name is a timestamp, and compare with longtype, so column names are sorted by time
$superName = time();
$keyId = '101';
$cfName = 'testCF';
$sc = new PandraSuperColumn($superName, $keyId, $cfName);
$sc->setColumnFamilyName('MyTest');
$sc->addColumn('http://facebook.com')->setValue('37');
$sc->addColumn('http://google.com')->setValue('42');
$sc->save();

I got this error back:

Array ( [0] => TException: A long is exactly 8 bytes )

Does Pandra convert an integer to long type Thrift expects?

mjpearson commented 14 years ago

No it's not implemented yet, but depending on your architecture it can be set via pack() ...

eg: 32-bit big-endian : $time = pack("NN", time(), 0);

and then to extract, the converse 32-bit unpack... $timeUnpacked = array_pop(unpack('N', $time));

http://au.php.net/manual/en/function.pack.php

Sorry there's not a patch yet for this.

beiercai commented 14 years ago

Thanks, that worked!

Any plan to support it in the future? it's just a bit strange to deal with byte stream on a high layer.

mjpearson commented 14 years ago

There will be a solution in place for the 0.3 release, it's currently only stubbed in the column container class