Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "FAQ" page has been changed by JuhoMakinen. The comment on this change is: Added faq entry: Insert operation throws InvalidRequestException with message "A long is exactly 8 bytes". http://wiki.apache.org/cassandra/FAQ?action=diff&rev1=65&rev2=66 -------------------------------------------------- * [[#iter_world|How can I iterate over all the rows in a ColumnFamily?]] * [[#no_keyspaces|Why were none of the keyspaces described in storage-conf.xml loaded?]] * [[#gui|Is there a GUI admin tool for Cassandra?]] + * [[#a_long_is_exactly_8_bytes|Insert operation throws InvalidRequestException with message "A long is exactly 8 bytes"]] <<Anchor(cant_listen_on_ip_any)>> @@ -252, +253 @@ == Is there a GUI admin tool for Cassandra? == The closest is [[http://github.com/driftx/chiton|chiton]], a GTK data browser. + <<Anchor(a_long_is_exactly_8_bytes)>> + + == Insert operation throws InvalidRequestException with message "A long is exactly 8 bytes" == + + You are propably using LongType column sorter in your column family. LongType assumes that the numbers stored into column names are exactly 64bit (8 bytes) long and in big endian format. Example code how to pack and unpack an integer for storing into cassandra and unpacking it for php: + + {{{ + /** + * Takes php integer and packs it to 64bit (8 bytes) long big endian binary representation. + * @param $x integer + * @return string eight bytes long binary repersentation of the integer in big endian order. + */ + public static function pack_longtype($x) { + return pack('C8', ($x >> 56) & 0xff, ($x >> 48) & 0xff, ($x >> 40) & 0xff, ($x >> 32) & 0xff, + ($x >> 24) & 0xff, ($x >> 16) & 0xff, ($x >> 8) & 0xff, $x & 0xff); + } + + /** + * Takes eight bytes long big endian binary representation of an integer and unpacks it to a php integer. + * @param $x + * @return php integer + */ + public static function unpack_longtype($x) { + $a = unpack('C8', $x); + return ($a[1] << 56) + ($a[2] << 48) + ($a[3] << 40) + ($a[4] << 32) + ($a[5] << 24) + ($a[6] << 16) + ($a[7] << 8) + $a[8]; + } + }}} +
