Пример #1
0
 public function testNodeAndSequenceAreNotRandom()
 {
     $time = time();
     $obUuid1 = UUID::uuid1(UUID::NODE_MAX, $time * self::MICROSECONDS, UUID::SEQ_MAX);
     $obUuid2 = UUID::uuid1(UUID::NODE_MAX, $time * self::MICROSECONDS, UUID::SEQ_MAX);
     $this->assertEquals($obUuid1, $obUuid2);
 }
 public function setUp()
 {
     $this->subcols = array(array(UUID::uuid1(), 'val1'), array(UUID::uuid1(), 'val2'));
     $this->pool = new ConnectionPool(self::$KS);
     $this->cf = new SuperColumnFamily($this->pool, self::$CF);
     $this->cf->insert_format = ColumnFamily::ARRAY_FORMAT;
     $this->cf->return_format = ColumnFamily::OBJECT_FORMAT;
 }
Пример #3
0
 public function test_uuid1_generation()
 {
     if (PHP_INT_MAX === 2147483647) {
         $this->markTestSkipped();
     }
     $micros = 1293769171436849.0;
     $uuid = UUID::import(UUID::uuid1(null, $micros));
     $t = (int) ($uuid->time * 1000000);
     $this->assertEquals($micros, $t, '', 100);
 }
Пример #4
0
 public function test_get_indexed_slices_serialized()
 {
     $this->require_opp();
     $this->uuid_cf->truncate();
     $uuid1 = UUID::uuid1();
     $uuid2 = UUID::uuid1();
     $uuid3 = UUID::uuid1();
     $uuid4 = UUID::uuid1();
     $this->uuid_cf->insert($uuid1, array("subcol" => 0));
     $this->uuid_cf->insert($uuid2, array("subcol" => 1));
     $this->uuid_cf->insert($uuid3, array("subcol" => 1));
     $this->uuid_cf->insert($uuid4, array("subcol" => 1));
     $this->uuid_cf->buffer_size = 2;
     $expected = array(serialize($uuid2) => array("subcol" => 1), serialize($uuid3) => array("subcol" => 1), serialize($uuid4) => array("subcol" => 1));
     $expr = new IndexExpression("subcol", 1);
     $clause = new IndexClause(array($expr));
     $res = iterator_to_array($this->uuid_cf->get_indexed_slices($clause));
     $this->assertEquals($expected, $res);
     // supply a start key
     $clause = new IndexClause(array($expr), $uuid1);
     $res = iterator_to_array($this->uuid_cf->get_indexed_slices($clause));
     $this->assertEquals($expected, $res);
     $expr = new IndexExpression("subcol", 0);
     $clause = new IndexClause(array($expr));
     $res = iterator_to_array($this->uuid_cf->get_indexed_slices($clause));
     $this->assertEquals(array(serialize($uuid1) => array("subcol" => 0)), $res);
 }
 public function setUp()
 {
     parent::setUp();
     $this->cols = array(array(UUID::uuid1(), 1), array(UUID::uuid1(), 2));
 }
 public function setUp()
 {
     parent::setUp();
     $this->cols = array(array(UUID::uuid1(), 'val1'), array(UUID::uuid1(), 'val2'));
 }
Пример #7
0
$sys->create_column_family('Keyspace1', 'UserLogs', array("comparator_type" => "TimeUUIDType", "key_validation_class" => "LexicalUUIDType"));
// Start a connection pool, create our ColumnFamily instance
$pool = new ConnectionPool('Keyspace1', array('127.0.0.1'));
$user_logs = new ColumnFamily($pool, 'UserLogs');
// Don't use dictionary-style arrays for data
$user_logs->insert_format = ColumnFamily::ARRAY_FORMAT;
$user_logs->return_format = ColumnFamily::ARRAY_FORMAT;
// Make a couple of user IDs with non-Time UUIDs
$user1_id = UUID::uuid4();
$user2_id = UUID::uuid4();
// Insert some log messages
$user1_logs = array();
$user2_logs = array();
for ($i = 0; $i < 5; $i++) {
    $user1_logs[] = array(UUID::uuid1(), "message{$i}");
    $user2_logs[] = array(UUID::uuid1(), "message{$i}");
}
$user_logs->batch_insert(array(array($user1_id, $user1_logs), array($user2_id, $user2_logs)));
echo "Using ColumnFamily::ARRAY_FORMAT\n";
echo "================================\n\n";
// Pull the first two logs back out
$slice = new ColumnSlice('', '', $count = 2);
$logs = $user_logs->get($user1_id, $slice);
echo "First two logs for user1: \n";
list($uuid, $message) = $logs[0];
echo "    " . $uuid->time . ", " . $message . "\n";
list($uuid, $message) = $logs[1];
echo "    " . $uuid->time . ", " . $message . "\n\n";
// Fetch the last log for both users at once
$slice = new ColumnSlice('', '', $count = 1, $reversed = true);
$rows = $user_logs->multiget(array($user1_id, $user2_id), $slice);