public function prepare() { parent::prepare(); if (count($this->attribs) > 2 || count($this->attribs) < 1) { throw new OrientDBWrongParamsException('This command requires record ID and, optionally, record version'); } $arr = explode(':', $this->attribs[0]); if (count($arr) != 2) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } $this->clusterID = (int) $arr[0]; $this->recordPos = (int) $arr[1]; if ($this->clusterID === 0 || (string) $this->recordPos !== $arr[1]) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } if (count($this->attribs) == 2) { $this->version = (int) $this->attribs[1]; } else { // Pessimistic way $this->version = -1; } // Add ClusterID $this->addShort($this->clusterID); // Add RecordID $this->addLong($this->recordPos); // Add version $this->addInt($this->version); // Synchronous mode $this->addByte(chr($this->mode)); }
public function prepare() { parent::prepare(); if (!empty($this->mode)) { // Populate $this->attribs with mode from child classes array_unshift($this->attribs, $this->mode); } if (count($this->attribs) > 3 || count($this->attribs) < 2) { throw new OrientDBWrongParamsException('This command requires query and, optionally, fetchplan'); } if (empty($this->mode)) { if ($this->attribs[0] == OrientDB::COMMAND_SELECT_SYNC || $this->attribs[0] == OrientDB::COMMAND_SELECT_ASYNC || $this->attribs[0] == OrientDB::COMMAND_QUERY) { $this->mode = $this->attribs[0]; } else { throw new OrientDBWrongParamsException('Wrong command mode'); } } if (($this->mode == OrientDB::COMMAND_QUERY || $this->mode == OrientDB::COMMAND_SELECT_SYNC) && count($this->attribs) == 3) { throw new OrientDBWrongParamsException('Fetch is useless with COMMAND_QUERY'); } $this->query = trim($this->attribs[1]); $this->fetchPlan = '*:0'; if (count($this->attribs) == 3) { $this->fetchPlan = $this->attribs[2]; } // Add mode if ($this->mode == OrientDB::COMMAND_QUERY || $this->mode == OrientDB::COMMAND_SELECT_SYNC || $this->mode == OrientDB::COMMAND_SELECT_GREMLIN) { $this->addByte(self::MODE_SYNC); } else { $this->addByte(self::MODE_ASYNC); } if ($this->mode == OrientDB::COMMAND_SELECT_ASYNC) { $objName = 'com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery'; } elseif ($this->mode == OrientDB::COMMAND_SELECT_SYNC) { $objName = 'com.orientechnologies.orient.core.sql.query.OSQLSynchQuery'; } elseif ($this->mode == OrientDB::COMMAND_SELECT_GREMLIN) { $objName = 'com.orientechnologies.orient.graph.gremlin.OCommandGremlin'; } else { $objName = 'com.orientechnologies.orient.core.sql.OCommandSQL'; } // Java query object serialization $buff = ''; // Java query object name serialization $buff .= pack('N', strlen($objName)); $buff .= $objName; // Query text serialization in TEXT mode $buff .= pack('N', strlen($this->query)); $buff .= $this->query; if ($this->mode == OrientDB::COMMAND_SELECT_ASYNC || $this->mode == OrientDB::COMMAND_SELECT_SYNC || $this->mode == OrientDB::COMMAND_SELECT_GREMLIN) { // Limit set to -1 to ignore and use TEXT MODE $buff .= pack('N', -1); // Add a fetchplan $buff .= pack('N', strlen($this->fetchPlan)); $buff .= $this->fetchPlan; } // Params serialization, we have 0 params $buff .= pack('N', 0); // Now query object serialization complete, add it to command bytes $this->addString($buff); }
public function prepare() { parent::prepare(); if (count($this->attribs) > 2 || count($this->attribs) < 1) { throw new OrientDBWrongParamsException('This command requires record ID and, optionally, fetch plan'); } $arr = explode(':', $this->attribs[0]); if (count($arr) != 2) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } $this->clusterID = (int) $arr[0]; $this->recordPos = (int) $arr[1]; if ((string) $this->clusterID !== $arr[0] || (string) $this->recordPos !== $arr[1]) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } // Add ClusterID $this->addShort($this->clusterID); // Add RecordID $this->addLong($this->recordPos); // Fetchplan $this->fetchPlan = '*:0'; if (count($this->attribs) == 2) { $this->fetchPlan = $this->attribs[1]; } $this->addString($this->fetchPlan); // Cache ignore - use cache $this->addByte(0); // Flag - Tombstone if ($this->parent->protocolVersion >= 13) { $this->addByte(0); } }
public function prepare() { parent::prepare(); if (count($this->attribs) > 3 || count($this->attribs) < 2) { throw new OrientDBWrongParamsException('This command requires cluster ID, record content and, optionally, record Type'); } // Add datasegment ID $this->addInt($this->datasegmentID); // Process clusterID $this->clusterID = (int) $this->attribs[0]; // Add ClusterID $this->addShort($this->clusterID); // Process recordContent $this->recordContent = $this->attribs[1]; // Add RecordContent $this->addBytes($this->recordContent); // recordType $this->recordType = OrientDB::RECORD_TYPE_DOCUMENT; if (count($this->attribs) == 3) { if (in_array($this->attribs[2], OrientDB::$recordTypes)) { $this->recordType = $this->attribs[2]; } else { throw new OrientDBWrongParamsException('Incorrect record Type: ' . $this->attribs[2] . '. Available types is: ' . implode(', ', OrientDB::$recordTypes)); } } $this->addByte($this->recordType); // Synchronous mode $this->addByte(chr($this->mode)); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 1) { throw new OrientDBWrongParamsException('This command requires cluster name'); } // Add cluster name $this->addString($this->attribs[0]); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 2) { throw new OrientDBWrongParamsException('This command requires name and password'); } // Add name $this->addString($this->attribs[0]); // Add name $this->addString($this->attribs[1]); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 1) { throw new OrientDBWrongParamsException('This command requires cluster ID'); } $this->clusterID = $this->attribs[0]; if (!is_int($this->clusterID)) { throw new OrientDBWrongParamsException('Integer expected'); } // Add clusterID $this->addShort($this->clusterID); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 2) { throw new OrientDBWrongParamsException('This command requires DB name and type'); } // Add DB name $this->addString($this->attribs[0]); // Add DB type. Since rc9. Right now only document is supported $this->addString('document'); // Add DB storage type $db_types = array(OrientDB::DB_TYPE_MEMORY, OrientDB::DB_TYPE_LOCAL); if (!in_array($this->attribs[1], $db_types)) { throw new OrientDBWrongParamsException('Not supported DB type. Supported types is: ' . implode(', ', $db_types)); } $this->addString($this->attribs[1]); }
public function prepare() { parent::prepare(); if (count($this->attribs) > 4 || count($this->attribs) < 2) { throw new OrientDBWrongParamsException('This command requires record ID, record content and, optionally, record version and, optionally, record type'); } $arr = explode(':', $this->attribs[0]); if (count($arr) != 2) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } $this->clusterID = (int) $arr[0]; $this->recordPos = (int) $arr[1]; if ($this->clusterID === 0 || (string) $this->recordPos !== $arr[1]) { throw new OrientDBWrongParamsException('Wrong format for record ID'); } // Add ClusterID $this->addShort($this->clusterID); // Add Record pos $this->addLong($this->recordPos); // Prepare record content $this->recordContent = $this->attribs[1]; // Add record content $this->addBytes($this->recordContent); // Add version if (count($this->attribs) >= 3) { $this->version = (int) $this->attribs[2]; } else { // Pessimistic way $this->version = -1; } $this->addInt($this->version); if (count($this->attribs) == 4) { if (in_array($this->attribs[3], OrientDB::$recordTypes)) { $this->recordType = $this->attribs[3]; } else { throw new OrientDBWrongParamsException('Incorrect record Type: ' . $this->attribs[2] . '. Available types is: ' . implode(', ', OrientDB::$recordTypes)); } } else { $this->recordType = OrientDB::RECORD_TYPE_DOCUMENT; } // Add recordType $this->addByte($this->recordType); $this->addByte(chr($this->mode)); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 2) { throw new OrientDBWrongParamsException('This command requires login and password'); } // Add Driver name $this->addString(OrientDB::DRIVER_NAME); // Add Driver version $this->addString(OrientDB::DRIVER_VERSION); // Add protocol version $this->addShort($this->parent->getProtocolVersionClient()); // Add client ID $this->addString(''); // Add login $this->addString($this->attribs[0]); // Add password $this->addString($this->attribs[1]); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 1) { throw new OrientDBWrongParamsException('This command requires cluster IDs in array'); } if (!is_array($this->attribs[0])) { throw new OrientDBWrongParamsException('Array expected'); } // Add count $this->addShort(count($this->attribs[0])); // Add clusterIDs for ($i = 0; $i < count($this->attribs[0]); $i++) { $this->addShort($this->attribs[0][$i]); } // Flag - Tombstone if ($this->parent->protocolVersion >= 13) { $this->addByte(0); } }
public function prepare() { parent::prepare(); if (count($this->attribs) != 2) { throw new OrientDBWrongParamsException('This command requires cluster name and cluster type'); } $this->clusterName = $this->attribs[0]; if (in_array($this->attribs[1], OrientDB::$clusterTypes)) { $this->clusterType = $this->attribs[1]; } else { throw new OrientDBWrongParamsException('Incorrect cluster Type: ' . $this->attribs[1] . '. Available types is: ' . implode(', ', OrientDB::$clusterTypes)); } // Add clusterType $this->addString($this->clusterType); // Add clusterName $this->addString($this->clusterName); // Add clusterLocation $this->addString($this->clusterLocation); // Add datasegment name $this->addString($this->datasegmentName); }
public function prepare() { parent::prepare(); if (count($this->attribs) != 3) { throw new OrientDBWrongParamsException('This command requires DB name, login and password'); } // Add Driver name $this->addString(OrientDB::DRIVER_NAME); // Add Driver version $this->addString(OrientDB::DRIVER_VERSION); // Add protocol version $this->addShort($this->parent->getProtocolVersionClient()); // Add client ID $this->addString(''); // Add DB name $this->addString($this->attribs[0]); // Add DB type. Since rc9. Right now only document is supported $this->addString('document'); // Add login $this->addString($this->attribs[1]); // Add password $this->addString($this->attribs[2]); }
public function testUnpackI64BelowPositiveBound() { if (PHP_INT_SIZE == 8) { $result = 9223372036854775806; } else { $result = '9223372036854775806'; } $hi = 0x7fffffff; $low = 0xfffffffe; $this->assertSame($result, OrientDBCommandAbstract::unpackI64($hi, $low)); }
public function prepare() { parent::prepare(); throw new OrientDBException('Not implemented'); }
public function __construct($parent) { parent::__construct($parent); $this->opType = OrientDBCommandAbstract::DB_LIST; }
public function testConvertComplementShortZeroViaUnpack() { $short = 0; $packed = pack('n', $short); $unpacked = unpack('n', $packed); $unpacked = reset($unpacked); $this->assertSame($short, $unpacked); $this->assertSame($short, OrientDBCommandAbstract::convertComplementShort($unpacked)); }