Skip to content

Instantly share code, notes, and snippets.

@nmmmnu
Created May 16, 2012 10:42
Show Gist options
  • Save nmmmnu/2709432 to your computer and use it in GitHub Desktop.
Save nmmmnu/2709432 to your computer and use it in GitHub Desktop.
Cassandra Iterator test on very long data set
<?
require_once(__DIR__.'/../lib/autoload.php');
use phpcassa\SystemManager;
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\Index\IndexExpression;
use phpcassa\Index\IndexClause;
$sys = new SystemManager('127.0.0.1');
$pool = new ConnectionPool('DEMO', array('127.0.0.1'));
$users = new ColumnFamily($pool, 'urls');
$x = $users->get_range(new IndexClause(new IndexExpression('type', 1984)), 0, 1000000 );
$i = 0;
$mem = 0;
foreach($x as $key => $value) {
$i++;
$mem = $mem + strlen(serialize(array($key, $value)));
if ($i % 1000 == 0)
printf("%10d | %6.3f | %s\n", $i, $mem / 1024 / 1024, $key);
}
@nmmmnu
Copy link
Author

nmmmnu commented May 17, 2012

Tested and works well. PHP does NOT run out of memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment