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; }
public function unpack($data, $handle_serialize = true) { $value = UUID::import($data); if ($handle_serialize) { return serialize($value); } else { return $value; } }
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); }
public function test_default_validated_columns() { $time = UUID::mint(); $this->cf_def_valid = new ColumnFamily($this->client, 'DefaultValidator'); $col_cf = array('aaaaaa' => 222222222222); $col_cm = array('subcol' => $time); # Both of these inserts work, as cf allows # longs and cm for 'subcol' allows TimeUUIDs $this->cf_def_valid->insert(self::$KEYS[0], $col_cf); $this->cf_def_valid->insert(self::$KEYS[0], $col_cm); $this->assertEquals($this->cf_def_valid->get(self::$KEYS[0]), array('aaaaaa' => 222222222222, 'subcol' => $time)); }
public function setUp() { $this->client = new ConnectionPool(self::$KS); $this->cf_suplong_subfloat = new SuperColumnFamily($this->client, 'SuperLongSubFloat'); $this->cf_suplong_subdouble = new SuperColumnFamily($this->client, 'SuperLongSubDouble'); $this->cf_suplong_subtime = new SuperColumnFamily($this->client, 'SuperLongSubTime'); $this->cf_suplong_sublex = new SuperColumnFamily($this->client, 'SuperLongSubLex'); $this->cf_suplong_subcomposite = new SuperColumnFamily($this->client, 'SuperLongSubComposite'); $this->cfs = array($this->cf_suplong_subfloat, $this->cf_suplong_subdouble, $this->cf_suplong_subtime, $this->cf_suplong_sublex, $this->cf_suplong_subcomposite); $this->TIME1 = UUID::mint(); $this->TIME2 = UUID::mint(); $this->TIME3 = UUID::mint(); $this->LEX1 = UUID::import('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); $this->LEX2 = UUID::import('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); $this->LEX3 = UUID::import('cccccccccccccccccccccccccccccccc'); }
public function setUp() { $this->client = new ConnectionPool(self::$KS); $this->cf_supfloat = new SuperColumnFamily($this->client, 'SuperFloat'); $this->cf_supdouble = new SuperColumnFamily($this->client, 'SuperDouble'); $this->cf_suptime = new SuperColumnFamily($this->client, 'SuperTime'); $this->cf_suplex = new SuperColumnFamily($this->client, 'SuperLex'); // $this->cf_supcomposite = new SuperColumnFamily($this->client, 'SuperComposite'); $this->cfs = array($this->cf_supfloat, $this->cf_supdouble, $this->cf_suptime, $this->cf_suplex); // $this->cf_supcomposite); $this->TIME1 = UUID::mint(); $this->TIME2 = UUID::mint(); $this->TIME3 = UUID::mint(); $this->LEX1 = UUID::import('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); $this->LEX2 = UUID::import('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); $this->LEX3 = UUID::import('cccccccccccccccccccccccccccccccc'); }
/** * Generate a v5 UUID * @return string a byte[] representation of a UUID */ public static function uuid5($node, $namespace = null) { return UUID::mint(5, $node, $namespace); }
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)); }
$column_family = new ColumnFamily($pool, $columnfamily_name, $autopack_names); } $no_column = 1; $data = array(); $no_scf = 1; while (isset($_POST['column_key_' . $no_scf]) || $no_scf == 1) { $column_key_name = ''; if (isset($_POST['column_key_' . $no_scf])) { $column_key_name = $_POST['column_key_' . $no_scf]; } $no_column = 1; while (isset($_POST['column_name_' . $no_scf . '_' . $no_column]) && isset($_POST['column_value_' . $no_scf . '_' . $no_column])) { $column_name = $_POST['column_name_' . $no_scf . '_' . $no_column]; switch ($cf_def->comparator_type) { case 'org.apache.cassandra.db.marshal.TimeUUIDType': $uuid = UUID::import($column_name); $column_name = $uuid->bytes; break; } $column_value = $_POST['column_value_' . $no_scf . '_' . $no_column]; if ($_POST['column_name_' . $no_scf . '_' . $no_column] != '' && $_POST['column_value_' . $no_scf . '_' . $no_column] != '') { // CF if ($column_key_name == '') { $data[$column_name] = $column_value; } else { $data[$column_key_name][$column_name] = $column_value; } } $no_column++; } $no_scf++;
public function setUp() { parent::setUp(); $this->cols = array(array(UUID::uuid1(), 'val1'), array(UUID::uuid1(), 'val2')); }
$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);