1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
--TEST--
MongoInsertBatch: Batch Splitting, overflowing maxWriteBatchSize (32bit)
--SKIPIF--
<?php $needs = "2.5.5"; ?>
<?php if ( ! class_exists('MongoWriteBatch')) { exit('skip This test requires MongoWriteBatch classes'); } ?>
<?php require_once "tests/utils/standalone.inc" ?>
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?>
--FILE--
<?php
require_once "tests/utils/server.inc";
$host = MongoShellServer::getStandaloneInfo();
$mc = new MongoClient($host);
$collection = $mc->selectCollection(dbname(), collname(__FILE__));
$collection->drop();
$batch = new MongoInsertBatch($collection);
for ($i=1; $i<=3001; $i++) {
$retval = $batch->add(array("document" => $i));
}
echo "Executing the batch now\n";
var_dump($batch->getItemCount(), $batch->getBatchInfo());
$retval = $batch->execute(array("w" => 1));
var_dump($batch->getItemCount(), $batch->getBatchInfo());
var_dump($retval);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Executing the batch now
int(3001)
array(4) {
[0]=>
array(2) {
["count"]=>
int(1000)
["size"]=>
int(%d)
}
[1]=>
array(2) {
["count"]=>
int(1000)
["size"]=>
int(%d)
}
[2]=>
array(2) {
["count"]=>
int(1000)
["size"]=>
int(%d)
}
[3]=>
array(2) {
["count"]=>
int(1)
["size"]=>
int(%d)
}
}
int(0)
array(0) {
}
array(2) {
["nInserted"]=>
int(3001)
["ok"]=>
bool(true)
}
===DONE===
|