get_time() публичный статический Метод

Time
public static get_time ( )
Пример #1
0
 private function array_to_columns($array, $timestamp = null, $ttl = null)
 {
     if (empty($timestamp)) {
         $timestamp = CassandraUtil::get_time();
     }
     $ret = null;
     foreach ($array as $name => $value) {
         $column = new cassandra_Column();
         $column->name = $this->pack_name($name, false);
         $column->value = $this->pack_value($value, $name);
         $column->timestamp = $timestamp;
         $column->ttl = $ttl;
         $ret[] = $column;
     }
     return $ret;
 }
Пример #2
0
 public function array_to_columns($array, $timestamp = null)
 {
     if (empty($timestamp)) {
         $timestamp = CassandraUtil::get_time();
     }
     $ret = null;
     foreach ($array as $name => $value) {
         $column = new cassandra_Column();
         $column->name = $this->unparse_column_name($name, false);
         $column->value = $this->to_column_value($value);
         $column->timestamp = $timestamp;
         $ret[] = $column;
     }
     return $ret;
 }
Пример #3
0
 protected static function mintTime($node = NULL, $time_arg = NULL)
 {
     /* Generates a Version 1 UUID.  
        These are derived from the time at which they were generated. */
     // Get time since Gregorian calendar reform in 100ns intervals
     // This is exceedingly difficult because of PHP's (and pack()'s)
     //  integer size limits.
     // Note that this will never be more accurate than to the microsecond.
     if ($time_arg == NULL) {
         $time = CassandraUtil::get_time() * 10 + self::interval;
     } else {
         $time = $time_arg * 10 + self::interval;
     }
     // Convert to a string representation
     $time = sprintf("%F", $time);
     preg_match("/^\\d+/", $time, $time);
     //strip decimal point
     // And now to a 64-bit binary representation
     $time = base_convert($time[0], 10, 16);
     $time = pack("H*", str_pad($time, 16, "0", STR_PAD_LEFT));
     // Reorder bytes to their proper locations in the UUID
     $uuid = $time[4] . $time[5] . $time[6] . $time[7] . $time[2] . $time[3] . $time[0] . $time[1];
     // Generate a random clock sequence
     $uuid .= self::randomBytes(2);
     // set variant
     $uuid[8] = chr(ord($uuid[8]) & self::clearVar | self::varRFC);
     // set version
     $uuid[6] = chr(ord($uuid[6]) & self::clearVer | self::version1);
     // Set the final 'node' parameter, a MAC address
     if ($node) {
         $node = self::makeBin($node, 6);
     }
     if (!$node) {
         // If no node was provided or if the node was invalid,
         //  generate a random MAC address and set the multicast bit
         $node = self::randomBytes(6);
         $node[0] = pack("C", ord($node[0]) | 1);
     }
     $uuid .= $node;
     return $uuid;
 }
Пример #4
0
 /**
  * 生成mutation
  * @param $array
  * @param $timestamp
  * @return unknown_type
  */
 protected static function array_to_mutations(&$array, $is_super = false, $timestamp = null, $type = CassandraCF::CT_BytesType, $subtype = CassandraCF::CT_BytesType)
 {
     if (empty($timestamp)) {
         $timestamp = CassandraUtil::get_time();
     }
     $ret = array();
     foreach ($array as $name => $value) {
         $mutation = new cassandra_Mutation();
         $c_or_sc =& $mutation->column_or_supercolumn;
         $c_or_sc = new cassandra_ColumnOrSuperColumn();
         if ($is_super && is_array($value)) {
             $c_or_sc->super_column = new cassandra_SuperColumn();
             $c_or_sc->super_column->name = self::unparse_column_name($name, $type);
             $c_or_sc->super_column->columns = self::array_to_columns($value, $timestamp, $subtype);
             $c_or_sc->super_column->timestamp = $timestamp;
         } else {
             $c_or_sc->column = new cassandra_Column();
             self::to_column_value($c_or_sc->column, $name, $value, $type);
             $c_or_sc->column->timestamp = $timestamp;
         }
         $ret[] = $mutation;
     }
     return $ret;
 }