1

I am using cassandra timeuuid in my project. But unable to create timeuuid due to integer limits.

$time = time();

$tS = new Cassandra\Timeuuid($time);
echo("Time Stamp : " . $time       . "</br>");
echo("Time UUID  : " . $tS         . "</br>");
echo("UUID TS    : " . $tS->time() . "</br>");

If I run above code I am getting following result.

Time Stamp : 1519110425
Time UUID : 07e0a090-2ba3-11b2-a264-4f5a3b4facaa
UUID TS : 1519110

This means that Timeuuid constructor expects timestamp in milliseconds. But if I try to pass the parameter in milliseconds, it is hitting the integer limit for my php (32bit).

$time = time();

$tS = new Cassandra\Timeuuid($time * 1000);
echo("Time Stamp : " . $time       . "</br>");
echo("Time UUID  : " . $tS         . "</br>");
echo("UUID TS    : " . $tS->time() . "</br>");

Getting following error for the above code.

Fatal error: Uncaught Cassandra\Exception\InvalidArgumentException: Invalid argument - integer or string expected in testFile.php:9 Stack trace: #0 testFile.php(9): Cassandra\Timeuuid->__construct(1519110640000) #1 {main} thrown in testFile.php on line 9

Since it is above the integer limit it is getting casted to float.

Any idea how can i solve this problem ?

Ligo George
  • 819
  • 2
  • 9
  • 21

1 Answers1

1

The documentation states that Cassandra\Timeuuid should receive integer that you get from time function. Looking into source code of driver it really looks that it expects the value in seconds, and all multiplication then happens inside the C++ driver.

For me it looks like the error in the driver, so please file the issue against it at JIRA.

Alex Ott
  • 80,552
  • 8
  • 87
  • 132