Example #1
0
 /**
  * (re) Parition the union of existing partitions.
  *
  * The closure should return a unique key which will be used
  * as the discriminator for dividing partitions.
  *
  * @param \Closure $closure
  */
 public function partition(\Closure $closure)
 {
     $unifiedParition = $this->getElements();
     $lastDiscriminator = null;
     $currentPartition = new Partition();
     $partitions = array();
     foreach ($unifiedParition as $key => $element) {
         $discriminator = $closure($element);
         if (null === $lastDiscriminator) {
             $lastDiscriminator = $discriminator;
         }
         if ($lastDiscriminator != $discriminator) {
             $partitions[] = $currentPartition;
             $currentPartition = new Partition();
         }
         $currentPartition->set($key, $element);
         $lastDiscriminator = $discriminator;
     }
     $partitions[] = $currentPartition;
     $this->partitions = $partitions;
     return $this;
 }
Example #2
0
 /**
  * returns the partition method used by the table.
  *
  * @param string $db    database name
  * @param string $table table name
  *
  * @return string partition method
  */
 public static function getPartitionMethod($db, $table)
 {
     if (Partition::havePartitioning()) {
         $partition_method = $GLOBALS['dbi']->fetchResult("SELECT `PARTITION_METHOD` FROM `information_schema`.`PARTITIONS`" . " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db) . "'" . " AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'");
         if (!empty($partition_method)) {
             return $partition_method[0];
         }
     }
     return null;
 }
 public function __construct($vals = null)
 {
     if (!isset(self::$_TSPEC)) {
         self::$_TSPEC = array(1 => array('var' => 'values', 'type' => TType::LST, 'etype' => TType::STRING, 'elem' => array('type' => TType::STRING)), 2 => array('var' => 'dbName', 'type' => TType::STRING), 3 => array('var' => 'tableName', 'type' => TType::STRING), 4 => array('var' => 'createTime', 'type' => TType::I32), 5 => array('var' => 'lastAccessTime', 'type' => TType::I32), 6 => array('var' => 'sd', 'type' => TType::STRUCT, 'class' => 'StorageDescriptor'), 7 => array('var' => 'parameters', 'type' => TType::MAP, 'ktype' => TType::STRING, 'vtype' => TType::STRING, 'key' => array('type' => TType::STRING), 'val' => array('type' => TType::STRING)), 8 => array('var' => 'privileges', 'type' => TType::STRUCT, 'class' => 'PrincipalPrivilegeSet'));
     }
     if (is_array($vals)) {
         if (isset($vals['values'])) {
             $this->values = $vals['values'];
         }
         if (isset($vals['dbName'])) {
             $this->dbName = $vals['dbName'];
         }
         if (isset($vals['tableName'])) {
             $this->tableName = $vals['tableName'];
         }
         if (isset($vals['createTime'])) {
             $this->createTime = $vals['createTime'];
         }
         if (isset($vals['lastAccessTime'])) {
             $this->lastAccessTime = $vals['lastAccessTime'];
         }
         if (isset($vals['sd'])) {
             $this->sd = $vals['sd'];
         }
         if (isset($vals['parameters'])) {
             $this->parameters = $vals['parameters'];
         }
         if (isset($vals['privileges'])) {
             $this->privileges = $vals['privileges'];
         }
     }
 }
Example #4
0
 public function read($input)
 {
     $xfer = 0;
     $fname = null;
     $ftype = 0;
     $fid = 0;
     $xfer += $input->readStructBegin($fname);
     while (true) {
         $xfer += $input->readFieldBegin($fname, $ftype, $fid);
         if ($ftype == TType::STOP) {
             break;
         }
         switch ($fid) {
             case 1:
                 if ($ftype == TType::STRING) {
                     $xfer += $input->readString($this->db_name);
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             case 2:
                 if ($ftype == TType::STRING) {
                     $xfer += $input->readString($this->tbl_name);
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             case 3:
                 if ($ftype == TType::LST) {
                     $this->new_parts = array();
                     $_size439 = 0;
                     $_etype442 = 0;
                     $xfer += $input->readListBegin($_etype442, $_size439);
                     for ($_i443 = 0; $_i443 < $_size439; ++$_i443) {
                         $elem444 = null;
                         $elem444 = new Partition();
                         $xfer += $elem444->read($input);
                         $this->new_parts[] = $elem444;
                     }
                     $xfer += $input->readListEnd();
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             default:
                 $xfer += $input->skip($ftype);
                 break;
         }
         $xfer += $input->readFieldEnd();
     }
     $xfer += $input->readStructEnd();
     return $xfer;
 }
Example #5
0
 public function read($input)
 {
     $xfer = 0;
     $fname = null;
     $ftype = 0;
     $fid = 0;
     $xfer += $input->readStructBegin($fname);
     while (true) {
         $xfer += $input->readFieldBegin($fname, $ftype, $fid);
         if ($ftype == TType::STOP) {
             break;
         }
         switch ($fid) {
             case 0:
                 if ($ftype == TType::LST) {
                     $this->success = array();
                     $_size379 = 0;
                     $_etype382 = 0;
                     $xfer += $input->readListBegin($_etype382, $_size379);
                     for ($_i383 = 0; $_i383 < $_size379; ++$_i383) {
                         $elem384 = null;
                         $elem384 = new Partition();
                         $xfer += $elem384->read($input);
                         $this->success[] = $elem384;
                     }
                     $xfer += $input->readListEnd();
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             case 1:
                 if ($ftype == TType::STRUCT) {
                     $this->o1 = new MetaException();
                     $xfer += $this->o1->read($input);
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             case 2:
                 if ($ftype == TType::STRUCT) {
                     $this->o2 = new NoSuchObjectException();
                     $xfer += $this->o2->read($input);
                 } else {
                     $xfer += $input->skip($ftype);
                 }
                 break;
             default:
                 $xfer += $input->skip($ftype);
                 break;
         }
         $xfer += $input->readFieldEnd();
     }
     $xfer += $input->readStructEnd();
     return $xfer;
 }