You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2012/11/06 22:22:30 UTC
svn commit: r1406339 [13/17] - in /hbase/trunk: ./ examples/ hbase-examples/
hbase-examples/src/ hbase-examples/src/main/ hbase-examples/src/main/cpp/
hbase-examples/src/main/cpp/gen-cpp/ hbase-examples/src/main/java/
hbase-examples/src/main/java/org/ ...
Added: hbase/trunk/hbase-examples/src/main/php/gen-php/Hbase/Types.php
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/php/gen-php/Hbase/Types.php?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/php/gen-php/Hbase/Types.php (added)
+++ hbase/trunk/hbase-examples/src/main/php/gen-php/Hbase/Types.php Tue Nov 6 21:22:27 2012
@@ -0,0 +1,1461 @@
+<?php
+namespace Hbase;
+
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+use Thrift\Base\TBase;
+use Thrift\Type\TType;
+use Thrift\Type\TMessageType;
+use Thrift\Exception\TException;
+use Thrift\Exception\TProtocolException;
+use Thrift\Protocol\TProtocol;
+use Thrift\Exception\TApplicationException;
+
+
+class TCell {
+ static $_TSPEC;
+
+ public $value = null;
+ public $timestamp = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'value',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'timestamp',
+ 'type' => TType::I64,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['value'])) {
+ $this->value = $vals['value'];
+ }
+ if (isset($vals['timestamp'])) {
+ $this->timestamp = $vals['timestamp'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'TCell';
+ }
+
+ 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->value);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::I64) {
+ $xfer += $input->readI64($this->timestamp);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('TCell');
+ if ($this->value !== null) {
+ $xfer += $output->writeFieldBegin('value', TType::STRING, 1);
+ $xfer += $output->writeString($this->value);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->timestamp !== null) {
+ $xfer += $output->writeFieldBegin('timestamp', TType::I64, 2);
+ $xfer += $output->writeI64($this->timestamp);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class ColumnDescriptor {
+ static $_TSPEC;
+
+ public $name = null;
+ public $maxVersions = 3;
+ public $compression = "NONE";
+ public $inMemory = false;
+ public $bloomFilterType = "NONE";
+ public $bloomFilterVectorSize = 0;
+ public $bloomFilterNbHashes = 0;
+ public $blockCacheEnabled = false;
+ public $timeToLive = -1;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'name',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'maxVersions',
+ 'type' => TType::I32,
+ ),
+ 3 => array(
+ 'var' => 'compression',
+ 'type' => TType::STRING,
+ ),
+ 4 => array(
+ 'var' => 'inMemory',
+ 'type' => TType::BOOL,
+ ),
+ 5 => array(
+ 'var' => 'bloomFilterType',
+ 'type' => TType::STRING,
+ ),
+ 6 => array(
+ 'var' => 'bloomFilterVectorSize',
+ 'type' => TType::I32,
+ ),
+ 7 => array(
+ 'var' => 'bloomFilterNbHashes',
+ 'type' => TType::I32,
+ ),
+ 8 => array(
+ 'var' => 'blockCacheEnabled',
+ 'type' => TType::BOOL,
+ ),
+ 9 => array(
+ 'var' => 'timeToLive',
+ 'type' => TType::I32,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['name'])) {
+ $this->name = $vals['name'];
+ }
+ if (isset($vals['maxVersions'])) {
+ $this->maxVersions = $vals['maxVersions'];
+ }
+ if (isset($vals['compression'])) {
+ $this->compression = $vals['compression'];
+ }
+ if (isset($vals['inMemory'])) {
+ $this->inMemory = $vals['inMemory'];
+ }
+ if (isset($vals['bloomFilterType'])) {
+ $this->bloomFilterType = $vals['bloomFilterType'];
+ }
+ if (isset($vals['bloomFilterVectorSize'])) {
+ $this->bloomFilterVectorSize = $vals['bloomFilterVectorSize'];
+ }
+ if (isset($vals['bloomFilterNbHashes'])) {
+ $this->bloomFilterNbHashes = $vals['bloomFilterNbHashes'];
+ }
+ if (isset($vals['blockCacheEnabled'])) {
+ $this->blockCacheEnabled = $vals['blockCacheEnabled'];
+ }
+ if (isset($vals['timeToLive'])) {
+ $this->timeToLive = $vals['timeToLive'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'ColumnDescriptor';
+ }
+
+ 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->name);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->maxVersions);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->compression);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::BOOL) {
+ $xfer += $input->readBool($this->inMemory);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 5:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->bloomFilterType);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 6:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->bloomFilterVectorSize);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 7:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->bloomFilterNbHashes);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 8:
+ if ($ftype == TType::BOOL) {
+ $xfer += $input->readBool($this->blockCacheEnabled);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 9:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->timeToLive);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('ColumnDescriptor');
+ if ($this->name !== null) {
+ $xfer += $output->writeFieldBegin('name', TType::STRING, 1);
+ $xfer += $output->writeString($this->name);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->maxVersions !== null) {
+ $xfer += $output->writeFieldBegin('maxVersions', TType::I32, 2);
+ $xfer += $output->writeI32($this->maxVersions);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->compression !== null) {
+ $xfer += $output->writeFieldBegin('compression', TType::STRING, 3);
+ $xfer += $output->writeString($this->compression);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->inMemory !== null) {
+ $xfer += $output->writeFieldBegin('inMemory', TType::BOOL, 4);
+ $xfer += $output->writeBool($this->inMemory);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->bloomFilterType !== null) {
+ $xfer += $output->writeFieldBegin('bloomFilterType', TType::STRING, 5);
+ $xfer += $output->writeString($this->bloomFilterType);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->bloomFilterVectorSize !== null) {
+ $xfer += $output->writeFieldBegin('bloomFilterVectorSize', TType::I32, 6);
+ $xfer += $output->writeI32($this->bloomFilterVectorSize);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->bloomFilterNbHashes !== null) {
+ $xfer += $output->writeFieldBegin('bloomFilterNbHashes', TType::I32, 7);
+ $xfer += $output->writeI32($this->bloomFilterNbHashes);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->blockCacheEnabled !== null) {
+ $xfer += $output->writeFieldBegin('blockCacheEnabled', TType::BOOL, 8);
+ $xfer += $output->writeBool($this->blockCacheEnabled);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->timeToLive !== null) {
+ $xfer += $output->writeFieldBegin('timeToLive', TType::I32, 9);
+ $xfer += $output->writeI32($this->timeToLive);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class TRegionInfo {
+ static $_TSPEC;
+
+ public $startKey = null;
+ public $endKey = null;
+ public $id = null;
+ public $name = null;
+ public $version = null;
+ public $serverName = null;
+ public $port = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'startKey',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'endKey',
+ 'type' => TType::STRING,
+ ),
+ 3 => array(
+ 'var' => 'id',
+ 'type' => TType::I64,
+ ),
+ 4 => array(
+ 'var' => 'name',
+ 'type' => TType::STRING,
+ ),
+ 5 => array(
+ 'var' => 'version',
+ 'type' => TType::BYTE,
+ ),
+ 6 => array(
+ 'var' => 'serverName',
+ 'type' => TType::STRING,
+ ),
+ 7 => array(
+ 'var' => 'port',
+ 'type' => TType::I32,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['startKey'])) {
+ $this->startKey = $vals['startKey'];
+ }
+ if (isset($vals['endKey'])) {
+ $this->endKey = $vals['endKey'];
+ }
+ if (isset($vals['id'])) {
+ $this->id = $vals['id'];
+ }
+ if (isset($vals['name'])) {
+ $this->name = $vals['name'];
+ }
+ if (isset($vals['version'])) {
+ $this->version = $vals['version'];
+ }
+ if (isset($vals['serverName'])) {
+ $this->serverName = $vals['serverName'];
+ }
+ if (isset($vals['port'])) {
+ $this->port = $vals['port'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'TRegionInfo';
+ }
+
+ 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->startKey);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->endKey);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::I64) {
+ $xfer += $input->readI64($this->id);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->name);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 5:
+ if ($ftype == TType::BYTE) {
+ $xfer += $input->readByte($this->version);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 6:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->serverName);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 7:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->port);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('TRegionInfo');
+ if ($this->startKey !== null) {
+ $xfer += $output->writeFieldBegin('startKey', TType::STRING, 1);
+ $xfer += $output->writeString($this->startKey);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->endKey !== null) {
+ $xfer += $output->writeFieldBegin('endKey', TType::STRING, 2);
+ $xfer += $output->writeString($this->endKey);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->id !== null) {
+ $xfer += $output->writeFieldBegin('id', TType::I64, 3);
+ $xfer += $output->writeI64($this->id);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->name !== null) {
+ $xfer += $output->writeFieldBegin('name', TType::STRING, 4);
+ $xfer += $output->writeString($this->name);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->version !== null) {
+ $xfer += $output->writeFieldBegin('version', TType::BYTE, 5);
+ $xfer += $output->writeByte($this->version);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->serverName !== null) {
+ $xfer += $output->writeFieldBegin('serverName', TType::STRING, 6);
+ $xfer += $output->writeString($this->serverName);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->port !== null) {
+ $xfer += $output->writeFieldBegin('port', TType::I32, 7);
+ $xfer += $output->writeI32($this->port);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class Mutation {
+ static $_TSPEC;
+
+ public $isDelete = false;
+ public $column = null;
+ public $value = null;
+ public $writeToWAL = true;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'isDelete',
+ 'type' => TType::BOOL,
+ ),
+ 2 => array(
+ 'var' => 'column',
+ 'type' => TType::STRING,
+ ),
+ 3 => array(
+ 'var' => 'value',
+ 'type' => TType::STRING,
+ ),
+ 4 => array(
+ 'var' => 'writeToWAL',
+ 'type' => TType::BOOL,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['isDelete'])) {
+ $this->isDelete = $vals['isDelete'];
+ }
+ if (isset($vals['column'])) {
+ $this->column = $vals['column'];
+ }
+ if (isset($vals['value'])) {
+ $this->value = $vals['value'];
+ }
+ if (isset($vals['writeToWAL'])) {
+ $this->writeToWAL = $vals['writeToWAL'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'Mutation';
+ }
+
+ 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::BOOL) {
+ $xfer += $input->readBool($this->isDelete);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->column);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->value);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::BOOL) {
+ $xfer += $input->readBool($this->writeToWAL);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('Mutation');
+ if ($this->isDelete !== null) {
+ $xfer += $output->writeFieldBegin('isDelete', TType::BOOL, 1);
+ $xfer += $output->writeBool($this->isDelete);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->column !== null) {
+ $xfer += $output->writeFieldBegin('column', TType::STRING, 2);
+ $xfer += $output->writeString($this->column);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->value !== null) {
+ $xfer += $output->writeFieldBegin('value', TType::STRING, 3);
+ $xfer += $output->writeString($this->value);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->writeToWAL !== null) {
+ $xfer += $output->writeFieldBegin('writeToWAL', TType::BOOL, 4);
+ $xfer += $output->writeBool($this->writeToWAL);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class BatchMutation {
+ static $_TSPEC;
+
+ public $row = null;
+ public $mutations = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'row',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'mutations',
+ 'type' => TType::LST,
+ 'etype' => TType::STRUCT,
+ 'elem' => array(
+ 'type' => TType::STRUCT,
+ 'class' => '\Hbase\Mutation',
+ ),
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['row'])) {
+ $this->row = $vals['row'];
+ }
+ if (isset($vals['mutations'])) {
+ $this->mutations = $vals['mutations'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'BatchMutation';
+ }
+
+ 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->row);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::LST) {
+ $this->mutations = array();
+ $_size0 = 0;
+ $_etype3 = 0;
+ $xfer += $input->readListBegin($_etype3, $_size0);
+ for ($_i4 = 0; $_i4 < $_size0; ++$_i4)
+ {
+ $elem5 = null;
+ $elem5 = new \Hbase\Mutation();
+ $xfer += $elem5->read($input);
+ $this->mutations []= $elem5;
+ }
+ $xfer += $input->readListEnd();
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('BatchMutation');
+ if ($this->row !== null) {
+ $xfer += $output->writeFieldBegin('row', TType::STRING, 1);
+ $xfer += $output->writeString($this->row);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->mutations !== null) {
+ if (!is_array($this->mutations)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('mutations', TType::LST, 2);
+ {
+ $output->writeListBegin(TType::STRUCT, count($this->mutations));
+ {
+ foreach ($this->mutations as $iter6)
+ {
+ $xfer += $iter6->write($output);
+ }
+ }
+ $output->writeListEnd();
+ }
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class TIncrement {
+ static $_TSPEC;
+
+ public $table = null;
+ public $row = null;
+ public $column = null;
+ public $ammount = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'table',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'row',
+ 'type' => TType::STRING,
+ ),
+ 3 => array(
+ 'var' => 'column',
+ 'type' => TType::STRING,
+ ),
+ 4 => array(
+ 'var' => 'ammount',
+ 'type' => TType::I64,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['table'])) {
+ $this->table = $vals['table'];
+ }
+ if (isset($vals['row'])) {
+ $this->row = $vals['row'];
+ }
+ if (isset($vals['column'])) {
+ $this->column = $vals['column'];
+ }
+ if (isset($vals['ammount'])) {
+ $this->ammount = $vals['ammount'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'TIncrement';
+ }
+
+ 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->table);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->row);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->column);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::I64) {
+ $xfer += $input->readI64($this->ammount);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('TIncrement');
+ if ($this->table !== null) {
+ $xfer += $output->writeFieldBegin('table', TType::STRING, 1);
+ $xfer += $output->writeString($this->table);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->row !== null) {
+ $xfer += $output->writeFieldBegin('row', TType::STRING, 2);
+ $xfer += $output->writeString($this->row);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->column !== null) {
+ $xfer += $output->writeFieldBegin('column', TType::STRING, 3);
+ $xfer += $output->writeString($this->column);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->ammount !== null) {
+ $xfer += $output->writeFieldBegin('ammount', TType::I64, 4);
+ $xfer += $output->writeI64($this->ammount);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class TRowResult {
+ static $_TSPEC;
+
+ public $row = null;
+ public $columns = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'row',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'columns',
+ 'type' => TType::MAP,
+ 'ktype' => TType::STRING,
+ 'vtype' => TType::STRUCT,
+ 'key' => array(
+ 'type' => TType::STRING,
+ ),
+ 'val' => array(
+ 'type' => TType::STRUCT,
+ 'class' => '\Hbase\TCell',
+ ),
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['row'])) {
+ $this->row = $vals['row'];
+ }
+ if (isset($vals['columns'])) {
+ $this->columns = $vals['columns'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'TRowResult';
+ }
+
+ 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->row);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::MAP) {
+ $this->columns = array();
+ $_size7 = 0;
+ $_ktype8 = 0;
+ $_vtype9 = 0;
+ $xfer += $input->readMapBegin($_ktype8, $_vtype9, $_size7);
+ for ($_i11 = 0; $_i11 < $_size7; ++$_i11)
+ {
+ $key12 = '';
+ $val13 = new \Hbase\TCell();
+ $xfer += $input->readString($key12);
+ $val13 = new \Hbase\TCell();
+ $xfer += $val13->read($input);
+ $this->columns[$key12] = $val13;
+ }
+ $xfer += $input->readMapEnd();
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('TRowResult');
+ if ($this->row !== null) {
+ $xfer += $output->writeFieldBegin('row', TType::STRING, 1);
+ $xfer += $output->writeString($this->row);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->columns !== null) {
+ if (!is_array($this->columns)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('columns', TType::MAP, 2);
+ {
+ $output->writeMapBegin(TType::STRING, TType::STRUCT, count($this->columns));
+ {
+ foreach ($this->columns as $kiter14 => $viter15)
+ {
+ $xfer += $output->writeString($kiter14);
+ $xfer += $viter15->write($output);
+ }
+ }
+ $output->writeMapEnd();
+ }
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class TScan {
+ static $_TSPEC;
+
+ public $startRow = null;
+ public $stopRow = null;
+ public $timestamp = null;
+ public $columns = null;
+ public $caching = null;
+ public $filterString = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'startRow',
+ 'type' => TType::STRING,
+ ),
+ 2 => array(
+ 'var' => 'stopRow',
+ 'type' => TType::STRING,
+ ),
+ 3 => array(
+ 'var' => 'timestamp',
+ 'type' => TType::I64,
+ ),
+ 4 => array(
+ 'var' => 'columns',
+ 'type' => TType::LST,
+ 'etype' => TType::STRING,
+ 'elem' => array(
+ 'type' => TType::STRING,
+ ),
+ ),
+ 5 => array(
+ 'var' => 'caching',
+ 'type' => TType::I32,
+ ),
+ 6 => array(
+ 'var' => 'filterString',
+ 'type' => TType::STRING,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['startRow'])) {
+ $this->startRow = $vals['startRow'];
+ }
+ if (isset($vals['stopRow'])) {
+ $this->stopRow = $vals['stopRow'];
+ }
+ if (isset($vals['timestamp'])) {
+ $this->timestamp = $vals['timestamp'];
+ }
+ if (isset($vals['columns'])) {
+ $this->columns = $vals['columns'];
+ }
+ if (isset($vals['caching'])) {
+ $this->caching = $vals['caching'];
+ }
+ if (isset($vals['filterString'])) {
+ $this->filterString = $vals['filterString'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'TScan';
+ }
+
+ 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->startRow);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 2:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->stopRow);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 3:
+ if ($ftype == TType::I64) {
+ $xfer += $input->readI64($this->timestamp);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 4:
+ if ($ftype == TType::LST) {
+ $this->columns = array();
+ $_size16 = 0;
+ $_etype19 = 0;
+ $xfer += $input->readListBegin($_etype19, $_size16);
+ for ($_i20 = 0; $_i20 < $_size16; ++$_i20)
+ {
+ $elem21 = null;
+ $xfer += $input->readString($elem21);
+ $this->columns []= $elem21;
+ }
+ $xfer += $input->readListEnd();
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 5:
+ if ($ftype == TType::I32) {
+ $xfer += $input->readI32($this->caching);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ case 6:
+ if ($ftype == TType::STRING) {
+ $xfer += $input->readString($this->filterString);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('TScan');
+ if ($this->startRow !== null) {
+ $xfer += $output->writeFieldBegin('startRow', TType::STRING, 1);
+ $xfer += $output->writeString($this->startRow);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->stopRow !== null) {
+ $xfer += $output->writeFieldBegin('stopRow', TType::STRING, 2);
+ $xfer += $output->writeString($this->stopRow);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->timestamp !== null) {
+ $xfer += $output->writeFieldBegin('timestamp', TType::I64, 3);
+ $xfer += $output->writeI64($this->timestamp);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->columns !== null) {
+ if (!is_array($this->columns)) {
+ throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+ }
+ $xfer += $output->writeFieldBegin('columns', TType::LST, 4);
+ {
+ $output->writeListBegin(TType::STRING, count($this->columns));
+ {
+ foreach ($this->columns as $iter22)
+ {
+ $xfer += $output->writeString($iter22);
+ }
+ }
+ $output->writeListEnd();
+ }
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->caching !== null) {
+ $xfer += $output->writeFieldBegin('caching', TType::I32, 5);
+ $xfer += $output->writeI32($this->caching);
+ $xfer += $output->writeFieldEnd();
+ }
+ if ($this->filterString !== null) {
+ $xfer += $output->writeFieldBegin('filterString', TType::STRING, 6);
+ $xfer += $output->writeString($this->filterString);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class IOError extends TException {
+ static $_TSPEC;
+
+ public $message = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'message',
+ 'type' => TType::STRING,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['message'])) {
+ $this->message = $vals['message'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'IOError';
+ }
+
+ 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->message);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('IOError');
+ if ($this->message !== null) {
+ $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
+ $xfer += $output->writeString($this->message);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class IllegalArgument extends TException {
+ static $_TSPEC;
+
+ public $message = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'message',
+ 'type' => TType::STRING,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['message'])) {
+ $this->message = $vals['message'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'IllegalArgument';
+ }
+
+ 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->message);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('IllegalArgument');
+ if ($this->message !== null) {
+ $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
+ $xfer += $output->writeString($this->message);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+class AlreadyExists extends TException {
+ static $_TSPEC;
+
+ public $message = null;
+
+ public function __construct($vals=null) {
+ if (!isset(self::$_TSPEC)) {
+ self::$_TSPEC = array(
+ 1 => array(
+ 'var' => 'message',
+ 'type' => TType::STRING,
+ ),
+ );
+ }
+ if (is_array($vals)) {
+ if (isset($vals['message'])) {
+ $this->message = $vals['message'];
+ }
+ }
+ }
+
+ public function getName() {
+ return 'AlreadyExists';
+ }
+
+ 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->message);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ break;
+ default:
+ $xfer += $input->skip($ftype);
+ break;
+ }
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+ }
+
+ public function write($output) {
+ $xfer = 0;
+ $xfer += $output->writeStructBegin('AlreadyExists');
+ if ($this->message !== null) {
+ $xfer += $output->writeFieldBegin('message', TType::STRING, 1);
+ $xfer += $output->writeString($this->message);
+ $xfer += $output->writeFieldEnd();
+ }
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+ }
+
+}
+
+
Added: hbase/trunk/hbase-examples/src/main/python/DemoClient.py
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/python/DemoClient.py?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/python/DemoClient.py (added)
+++ hbase/trunk/hbase-examples/src/main/python/DemoClient.py Tue Nov 6 21:22:27 2012
@@ -0,0 +1,218 @@
+#!/usr/bin/python
+'''
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+'''
+
+import sys
+import time
+import os
+
+# Modify this import path to point to the correct location to thrift.
+thrift_path = os.path.abspath('/Users/sergey/Downloads/thrift/lib/py/build/lib.macosx-10.8-intel-2.7')
+sys.path.append(thrift_path)
+gen_py_path = os.path.abspath('gen-py')
+sys.path.append(gen_py_path)
+
+from thrift import Thrift
+from thrift.transport import TSocket, TTransport
+from thrift.protocol import TBinaryProtocol
+from hbase import ttypes
+from hbase.Hbase import Client, ColumnDescriptor, Mutation
+
+def printVersions(row, versions):
+ print "row: " + row + ", values: ",
+ for cell in versions:
+ print cell.value + "; ",
+ print
+
+def printRow(entry):
+ print "row: " + entry.row + ", cols:",
+ for k in sorted(entry.columns):
+ print k + " => " + entry.columns[k].value,
+ print
+
+
+def demo_client(host, port, is_framed_transport):
+
+ # Make socket
+ socket = TSocket.TSocket(host, port)
+
+ # Make transport
+ if is_framed_transport:
+ transport = TTransport.TFramedTransport(socket)
+ else:
+ transport = TTransport.TBufferedTransport(socket)
+
+ # Wrap in a protocol
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+ # Create a client to use the protocol encoder
+ client = Client(protocol)
+
+ # Connect!
+ transport.open()
+
+ t = "demo_table"
+
+ #
+ # Scan all tables, look for the demo table and delete it.
+ #
+ print "scanning tables..."
+ for table in client.getTableNames():
+ print " found: %s" %(table)
+ if table == t:
+ if client.isTableEnabled(table):
+ print " disabling table: %s" %(t)
+ client.disableTable(table)
+ print " deleting table: %s" %(t)
+ client.deleteTable(table)
+
+ columns = []
+ col = ColumnDescriptor()
+ col.name = 'entry:'
+ col.maxVersions = 10
+ columns.append(col)
+ col = ColumnDescriptor()
+ col.name = 'unused:'
+ columns.append(col)
+
+ try:
+ print "creating table: %s" %(t)
+ client.createTable(t, columns)
+ except AlreadyExists, ae:
+ print "WARN: " + ae.message
+
+ cols = client.getColumnDescriptors(t)
+ print "column families in %s" %(t)
+ for col_name in cols.keys():
+ col = cols[col_name]
+ print " column: %s, maxVer: %d" % (col.name, col.maxVersions)
+
+ dummy_attributes = {}
+ #
+ # Test UTF-8 handling
+ #
+ invalid = "foo-\xfc\xa1\xa1\xa1\xa1\xa1"
+ valid = "foo-\xE7\x94\x9F\xE3\x83\x93\xE3\x83\xBC\xE3\x83\xAB";
+
+ # non-utf8 is fine for data
+ mutations = [Mutation(column="entry:foo",value=invalid)]
+ print str(mutations)
+ client.mutateRow(t, "foo", mutations, dummy_attributes)
+
+ # try empty strings
+ mutations = [Mutation(column="entry:", value="")]
+ client.mutateRow(t, "", mutations, dummy_attributes)
+
+ # this row name is valid utf8
+ mutations = [Mutation(column="entry:foo", value=valid)]
+ client.mutateRow(t, valid, mutations, dummy_attributes)
+
+ # non-utf8 is not allowed in row names
+ try:
+ mutations = [Mutation(column="entry:foo", value=invalid)]
+ client.mutateRow(t, invalid, mutations, dummy_attributes)
+ except ttypes.IOError, e:
+ print 'expected exception: %s' %(e.message)
+
+ # Run a scanner on the rows we just created
+ print "Starting scanner..."
+ scanner = client.scannerOpen(t, "", ["entry:"], dummy_attributes)
+
+ r = client.scannerGet(scanner)
+ while r:
+ printRow(r[0])
+ r = client.scannerGet(scanner)
+ print "Scanner finished"
+
+ #
+ # Run some operations on a bunch of rows.
+ #
+ for e in range(100, 0, -1):
+ # format row keys as "00000" to "00100"
+ row = "%0.5d" % (e)
+
+ mutations = [Mutation(column="unused:", value="DELETE_ME")]
+ client.mutateRow(t, row, mutations, dummy_attributes)
+ printRow(client.getRow(t, row, dummy_attributes)[0])
+ client.deleteAllRow(t, row, dummy_attributes)
+
+ mutations = [Mutation(column="entry:num", value="0"),
+ Mutation(column="entry:foo", value="FOO")]
+ client.mutateRow(t, row, mutations, dummy_attributes)
+ printRow(client.getRow(t, row, dummy_attributes)[0]);
+
+ mutations = [Mutation(column="entry:foo",isDelete=True),
+ Mutation(column="entry:num",value="-1")]
+ client.mutateRow(t, row, mutations, dummy_attributes)
+ printRow(client.getRow(t, row, dummy_attributes)[0])
+
+ mutations = [Mutation(column="entry:num", value=str(e)),
+ Mutation(column="entry:sqr", value=str(e*e))]
+ client.mutateRow(t, row, mutations, dummy_attributes)
+ printRow(client.getRow(t, row, dummy_attributes)[0])
+
+ time.sleep(0.05)
+
+ mutations = [Mutation(column="entry:num",value="-999"),
+ Mutation(column="entry:sqr",isDelete=True)]
+ client.mutateRowTs(t, row, mutations, 1, dummy_attributes) # shouldn't override latest
+ printRow(client.getRow(t, row, dummy_attributes)[0])
+
+ versions = client.getVer(t, row, "entry:num", 10, dummy_attributes)
+ printVersions(row, versions)
+ if len(versions) != 3:
+ print("FATAL: wrong # of versions")
+ sys.exit(-1)
+
+ r = client.get(t, row, "entry:foo", dummy_attributes)
+ # just to be explicit, we get lists back, if it's empty there was no matching row.
+ if len(r) > 0:
+ raise "shouldn't get here!"
+
+ columnNames = []
+ for (col, desc) in client.getColumnDescriptors(t).items():
+ print "column with name: "+desc.name
+ print desc
+ columnNames.append(desc.name+":")
+
+ print "Starting scanner..."
+ scanner = client.scannerOpenWithStop(t, "00020", "00040", columnNames, dummy_attributes)
+
+ r = client.scannerGet(scanner)
+ while r:
+ printRow(r[0])
+ r = client.scannerGet(scanner)
+
+ client.scannerClose(scanner)
+ print "Scanner finished"
+
+ transport.close()
+
+
+if __name__ == '__main__':
+
+ import sys
+ if len(sys.argv) < 3:
+ print 'usage: %s <host> <port>' % __file__
+ sys.exit(1)
+
+ host = sys.argv[1]
+ port = sys.argv[2]
+ is_framed_transport = False
+ demo_client(host, port, is_framed_transport)
+
Added: hbase/trunk/hbase-examples/src/main/python/gen-py/hbase/Hbase-remote
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-examples/src/main/python/gen-py/hbase/Hbase-remote?rev=1406339&view=auto
==============================================================================
--- hbase/trunk/hbase-examples/src/main/python/gen-py/hbase/Hbase-remote (added)
+++ hbase/trunk/hbase-examples/src/main/python/gen-py/hbase/Hbase-remote Tue Nov 6 21:22:27 2012
@@ -0,0 +1,382 @@
+#!/usr/bin/env python
+#
+# Autogenerated by Thrift Compiler (0.9.0)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+import sys
+import pprint
+from urlparse import urlparse
+from thrift.transport import TTransport
+from thrift.transport import TSocket
+from thrift.transport import THttpClient
+from thrift.protocol import TBinaryProtocol
+
+import Hbase
+from ttypes import *
+
+if len(sys.argv) <= 1 or sys.argv[1] == '--help':
+ print ''
+ print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
+ print ''
+ print 'Functions:'
+ print ' void enableTable(Bytes tableName)'
+ print ' void disableTable(Bytes tableName)'
+ print ' bool isTableEnabled(Bytes tableName)'
+ print ' void compact(Bytes tableNameOrRegionName)'
+ print ' void majorCompact(Bytes tableNameOrRegionName)'
+ print ' getTableNames()'
+ print ' getColumnDescriptors(Text tableName)'
+ print ' getTableRegions(Text tableName)'
+ print ' void createTable(Text tableName, columnFamilies)'
+ print ' void deleteTable(Text tableName)'
+ print ' get(Text tableName, Text row, Text column, attributes)'
+ print ' getVer(Text tableName, Text row, Text column, i32 numVersions, attributes)'
+ print ' getVerTs(Text tableName, Text row, Text column, i64 timestamp, i32 numVersions, attributes)'
+ print ' getRow(Text tableName, Text row, attributes)'
+ print ' getRowWithColumns(Text tableName, Text row, columns, attributes)'
+ print ' getRowTs(Text tableName, Text row, i64 timestamp, attributes)'
+ print ' getRowWithColumnsTs(Text tableName, Text row, columns, i64 timestamp, attributes)'
+ print ' getRows(Text tableName, rows, attributes)'
+ print ' getRowsWithColumns(Text tableName, rows, columns, attributes)'
+ print ' getRowsTs(Text tableName, rows, i64 timestamp, attributes)'
+ print ' getRowsWithColumnsTs(Text tableName, rows, columns, i64 timestamp, attributes)'
+ print ' void mutateRow(Text tableName, Text row, mutations, attributes)'
+ print ' void mutateRowTs(Text tableName, Text row, mutations, i64 timestamp, attributes)'
+ print ' void mutateRows(Text tableName, rowBatches, attributes)'
+ print ' void mutateRowsTs(Text tableName, rowBatches, i64 timestamp, attributes)'
+ print ' i64 atomicIncrement(Text tableName, Text row, Text column, i64 value)'
+ print ' void deleteAll(Text tableName, Text row, Text column, attributes)'
+ print ' void deleteAllTs(Text tableName, Text row, Text column, i64 timestamp, attributes)'
+ print ' void deleteAllRow(Text tableName, Text row, attributes)'
+ print ' void increment(TIncrement increment)'
+ print ' void incrementRows( increments)'
+ print ' void deleteAllRowTs(Text tableName, Text row, i64 timestamp, attributes)'
+ print ' ScannerID scannerOpenWithScan(Text tableName, TScan scan, attributes)'
+ print ' ScannerID scannerOpen(Text tableName, Text startRow, columns, attributes)'
+ print ' ScannerID scannerOpenWithStop(Text tableName, Text startRow, Text stopRow, columns, attributes)'
+ print ' ScannerID scannerOpenWithPrefix(Text tableName, Text startAndPrefix, columns, attributes)'
+ print ' ScannerID scannerOpenTs(Text tableName, Text startRow, columns, i64 timestamp, attributes)'
+ print ' ScannerID scannerOpenWithStopTs(Text tableName, Text startRow, Text stopRow, columns, i64 timestamp, attributes)'
+ print ' scannerGet(ScannerID id)'
+ print ' scannerGetList(ScannerID id, i32 nbRows)'
+ print ' void scannerClose(ScannerID id)'
+ print ' getRowOrBefore(Text tableName, Text row, Text family)'
+ print ' TRegionInfo getRegionInfo(Text row)'
+ print ''
+ sys.exit(0)
+
+pp = pprint.PrettyPrinter(indent = 2)
+host = 'localhost'
+port = 9090
+uri = ''
+framed = False
+http = False
+argi = 1
+
+if sys.argv[argi] == '-h':
+ parts = sys.argv[argi+1].split(':')
+ host = parts[0]
+ if len(parts) > 1:
+ port = int(parts[1])
+ argi += 2
+
+if sys.argv[argi] == '-u':
+ url = urlparse(sys.argv[argi+1])
+ parts = url[1].split(':')
+ host = parts[0]
+ if len(parts) > 1:
+ port = int(parts[1])
+ else:
+ port = 80
+ uri = url[2]
+ if url[4]:
+ uri += '?%s' % url[4]
+ http = True
+ argi += 2
+
+if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
+ framed = True
+ argi += 1
+
+cmd = sys.argv[argi]
+args = sys.argv[argi+1:]
+
+if http:
+ transport = THttpClient.THttpClient(host, port, uri)
+else:
+ socket = TSocket.TSocket(host, port)
+ if framed:
+ transport = TTransport.TFramedTransport(socket)
+ else:
+ transport = TTransport.TBufferedTransport(socket)
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+client = Hbase.Client(protocol)
+transport.open()
+
+if cmd == 'enableTable':
+ if len(args) != 1:
+ print 'enableTable requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.enableTable(eval(args[0]),))
+
+elif cmd == 'disableTable':
+ if len(args) != 1:
+ print 'disableTable requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.disableTable(eval(args[0]),))
+
+elif cmd == 'isTableEnabled':
+ if len(args) != 1:
+ print 'isTableEnabled requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.isTableEnabled(eval(args[0]),))
+
+elif cmd == 'compact':
+ if len(args) != 1:
+ print 'compact requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.compact(eval(args[0]),))
+
+elif cmd == 'majorCompact':
+ if len(args) != 1:
+ print 'majorCompact requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.majorCompact(eval(args[0]),))
+
+elif cmd == 'getTableNames':
+ if len(args) != 0:
+ print 'getTableNames requires 0 args'
+ sys.exit(1)
+ pp.pprint(client.getTableNames())
+
+elif cmd == 'getColumnDescriptors':
+ if len(args) != 1:
+ print 'getColumnDescriptors requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.getColumnDescriptors(eval(args[0]),))
+
+elif cmd == 'getTableRegions':
+ if len(args) != 1:
+ print 'getTableRegions requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.getTableRegions(eval(args[0]),))
+
+elif cmd == 'createTable':
+ if len(args) != 2:
+ print 'createTable requires 2 args'
+ sys.exit(1)
+ pp.pprint(client.createTable(eval(args[0]),eval(args[1]),))
+
+elif cmd == 'deleteTable':
+ if len(args) != 1:
+ print 'deleteTable requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.deleteTable(eval(args[0]),))
+
+elif cmd == 'get':
+ if len(args) != 4:
+ print 'get requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.get(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'getVer':
+ if len(args) != 5:
+ print 'getVer requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.getVer(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'getVerTs':
+ if len(args) != 6:
+ print 'getVerTs requires 6 args'
+ sys.exit(1)
+ pp.pprint(client.getVerTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),eval(args[5]),))
+
+elif cmd == 'getRow':
+ if len(args) != 3:
+ print 'getRow requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.getRow(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'getRowWithColumns':
+ if len(args) != 4:
+ print 'getRowWithColumns requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.getRowWithColumns(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'getRowTs':
+ if len(args) != 4:
+ print 'getRowTs requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.getRowTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'getRowWithColumnsTs':
+ if len(args) != 5:
+ print 'getRowWithColumnsTs requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.getRowWithColumnsTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'getRows':
+ if len(args) != 3:
+ print 'getRows requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.getRows(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'getRowsWithColumns':
+ if len(args) != 4:
+ print 'getRowsWithColumns requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.getRowsWithColumns(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'getRowsTs':
+ if len(args) != 4:
+ print 'getRowsTs requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.getRowsTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'getRowsWithColumnsTs':
+ if len(args) != 5:
+ print 'getRowsWithColumnsTs requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.getRowsWithColumnsTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'mutateRow':
+ if len(args) != 4:
+ print 'mutateRow requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.mutateRow(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'mutateRowTs':
+ if len(args) != 5:
+ print 'mutateRowTs requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.mutateRowTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'mutateRows':
+ if len(args) != 3:
+ print 'mutateRows requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.mutateRows(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'mutateRowsTs':
+ if len(args) != 4:
+ print 'mutateRowsTs requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.mutateRowsTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'atomicIncrement':
+ if len(args) != 4:
+ print 'atomicIncrement requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.atomicIncrement(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'deleteAll':
+ if len(args) != 4:
+ print 'deleteAll requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.deleteAll(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'deleteAllTs':
+ if len(args) != 5:
+ print 'deleteAllTs requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.deleteAllTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'deleteAllRow':
+ if len(args) != 3:
+ print 'deleteAllRow requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.deleteAllRow(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'increment':
+ if len(args) != 1:
+ print 'increment requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.increment(eval(args[0]),))
+
+elif cmd == 'incrementRows':
+ if len(args) != 1:
+ print 'incrementRows requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.incrementRows(eval(args[0]),))
+
+elif cmd == 'deleteAllRowTs':
+ if len(args) != 4:
+ print 'deleteAllRowTs requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.deleteAllRowTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'scannerOpenWithScan':
+ if len(args) != 3:
+ print 'scannerOpenWithScan requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpenWithScan(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'scannerOpen':
+ if len(args) != 4:
+ print 'scannerOpen requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpen(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'scannerOpenWithStop':
+ if len(args) != 5:
+ print 'scannerOpenWithStop requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpenWithStop(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'scannerOpenWithPrefix':
+ if len(args) != 4:
+ print 'scannerOpenWithPrefix requires 4 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpenWithPrefix(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),))
+
+elif cmd == 'scannerOpenTs':
+ if len(args) != 5:
+ print 'scannerOpenTs requires 5 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpenTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),))
+
+elif cmd == 'scannerOpenWithStopTs':
+ if len(args) != 6:
+ print 'scannerOpenWithStopTs requires 6 args'
+ sys.exit(1)
+ pp.pprint(client.scannerOpenWithStopTs(eval(args[0]),eval(args[1]),eval(args[2]),eval(args[3]),eval(args[4]),eval(args[5]),))
+
+elif cmd == 'scannerGet':
+ if len(args) != 1:
+ print 'scannerGet requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.scannerGet(eval(args[0]),))
+
+elif cmd == 'scannerGetList':
+ if len(args) != 2:
+ print 'scannerGetList requires 2 args'
+ sys.exit(1)
+ pp.pprint(client.scannerGetList(eval(args[0]),eval(args[1]),))
+
+elif cmd == 'scannerClose':
+ if len(args) != 1:
+ print 'scannerClose requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.scannerClose(eval(args[0]),))
+
+elif cmd == 'getRowOrBefore':
+ if len(args) != 3:
+ print 'getRowOrBefore requires 3 args'
+ sys.exit(1)
+ pp.pprint(client.getRowOrBefore(eval(args[0]),eval(args[1]),eval(args[2]),))
+
+elif cmd == 'getRegionInfo':
+ if len(args) != 1:
+ print 'getRegionInfo requires 1 args'
+ sys.exit(1)
+ pp.pprint(client.getRegionInfo(eval(args[0]),))
+
+else:
+ print 'Unrecognized method %s' % cmd
+ sys.exit(1)
+
+transport.close()