OpenSearchSearcherService.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. namespace OpenSearch\Generated\Search;
  3. /**
  4. * Autogenerated by Thrift Compiler (0.9.3)
  5. *
  6. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  7. * @generated
  8. */
  9. use Thrift\Base\TBase;
  10. use Thrift\Type\TType;
  11. use Thrift\Type\TMessageType;
  12. use Thrift\Exception\TException;
  13. use Thrift\Exception\TProtocolException;
  14. use Thrift\Protocol\TProtocol;
  15. use Thrift\Protocol\TBinaryProtocolAccelerated;
  16. use Thrift\Exception\TApplicationException;
  17. interface OpenSearchSearcherServiceIf extends \OpenSearch\Generated\GeneralSearcher\GeneralSearcherServiceIf {
  18. /**
  19. * @param \OpenSearch\Generated\Search\SearchParams $searchParams
  20. * @return \OpenSearch\Generated\GeneralSearcher\SearchResult
  21. * @throws \OpenSearch\Generated\Common\OpenSearchException
  22. * @throws \OpenSearch\Generated\Common\OpenSearchClientException
  23. */
  24. public function execute(\OpenSearch\Generated\Search\SearchParams $searchParams);
  25. }
  26. class OpenSearchSearcherServiceClient extends \OpenSearch\Generated\GeneralSearcher\GeneralSearcherServiceClient implements \OpenSearch\Generated\Search\OpenSearchSearcherServiceIf {
  27. public function __construct($input, $output=null) {
  28. parent::__construct($input, $output);
  29. }
  30. public function execute(\OpenSearch\Generated\Search\SearchParams $searchParams)
  31. {
  32. $this->send_execute($searchParams);
  33. return $this->recv_execute();
  34. }
  35. public function send_execute(\OpenSearch\Generated\Search\SearchParams $searchParams)
  36. {
  37. $args = new \OpenSearch\Generated\Search\OpenSearchSearcherService_execute_args();
  38. $args->searchParams = $searchParams;
  39. $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
  40. if ($bin_accel)
  41. {
  42. thrift_protocol_write_binary($this->output_, 'execute', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
  43. }
  44. else
  45. {
  46. $this->output_->writeMessageBegin('execute', TMessageType::CALL, $this->seqid_);
  47. $args->write($this->output_);
  48. $this->output_->writeMessageEnd();
  49. $this->output_->getTransport()->flush();
  50. }
  51. }
  52. public function recv_execute()
  53. {
  54. $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
  55. if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\OpenSearch\Generated\Search\OpenSearchSearcherService_execute_result', $this->input_->isStrictRead());
  56. else
  57. {
  58. $rseqid = 0;
  59. $fname = null;
  60. $mtype = 0;
  61. $this->input_->readMessageBegin($fname, $mtype, $rseqid);
  62. if ($mtype == TMessageType::EXCEPTION) {
  63. $x = new TApplicationException();
  64. $x->read($this->input_);
  65. $this->input_->readMessageEnd();
  66. throw $x;
  67. }
  68. $result = new \OpenSearch\Generated\Search\OpenSearchSearcherService_execute_result();
  69. $result->read($this->input_);
  70. $this->input_->readMessageEnd();
  71. }
  72. if ($result->success !== null) {
  73. return $result->success;
  74. }
  75. if ($result->error !== null) {
  76. throw $result->error;
  77. }
  78. if ($result->e !== null) {
  79. throw $result->e;
  80. }
  81. throw new \Exception("execute failed: unknown result");
  82. }
  83. }
  84. // HELPER FUNCTIONS AND STRUCTURES
  85. class OpenSearchSearcherService_execute_args {
  86. static $_TSPEC;
  87. /**
  88. * @var \OpenSearch\Generated\Search\SearchParams
  89. */
  90. public $searchParams = null;
  91. public function __construct($vals=null) {
  92. if (!isset(self::$_TSPEC)) {
  93. self::$_TSPEC = array(
  94. 1 => array(
  95. 'var' => 'searchParams',
  96. 'type' => TType::STRUCT,
  97. 'class' => '\OpenSearch\Generated\Search\SearchParams',
  98. ),
  99. );
  100. }
  101. if (is_array($vals)) {
  102. if (isset($vals['searchParams'])) {
  103. $this->searchParams = $vals['searchParams'];
  104. }
  105. }
  106. }
  107. public function getName() {
  108. return 'OpenSearchSearcherService_execute_args';
  109. }
  110. public function read($input)
  111. {
  112. $xfer = 0;
  113. $fname = null;
  114. $ftype = 0;
  115. $fid = 0;
  116. $xfer += $input->readStructBegin($fname);
  117. while (true)
  118. {
  119. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  120. if ($ftype == TType::STOP) {
  121. break;
  122. }
  123. switch ($fid)
  124. {
  125. case 1:
  126. if ($ftype == TType::STRUCT) {
  127. $this->searchParams = new \OpenSearch\Generated\Search\SearchParams();
  128. $xfer += $this->searchParams->read($input);
  129. } else {
  130. $xfer += $input->skip($ftype);
  131. }
  132. break;
  133. default:
  134. $xfer += $input->skip($ftype);
  135. break;
  136. }
  137. $xfer += $input->readFieldEnd();
  138. }
  139. $xfer += $input->readStructEnd();
  140. return $xfer;
  141. }
  142. public function write($output) {
  143. $xfer = 0;
  144. $xfer += $output->writeStructBegin('OpenSearchSearcherService_execute_args');
  145. if ($this->searchParams !== null) {
  146. if (!is_object($this->searchParams)) {
  147. throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
  148. }
  149. $xfer += $output->writeFieldBegin('searchParams', TType::STRUCT, 1);
  150. $xfer += $this->searchParams->write($output);
  151. $xfer += $output->writeFieldEnd();
  152. }
  153. $xfer += $output->writeFieldStop();
  154. $xfer += $output->writeStructEnd();
  155. return $xfer;
  156. }
  157. }
  158. class OpenSearchSearcherService_execute_result {
  159. static $_TSPEC;
  160. /**
  161. * @var \OpenSearch\Generated\GeneralSearcher\SearchResult
  162. */
  163. public $success = null;
  164. /**
  165. * @var \OpenSearch\Generated\Common\OpenSearchException
  166. */
  167. public $error = null;
  168. /**
  169. * @var \OpenSearch\Generated\Common\OpenSearchClientException
  170. */
  171. public $e = null;
  172. public function __construct($vals=null) {
  173. if (!isset(self::$_TSPEC)) {
  174. self::$_TSPEC = array(
  175. 0 => array(
  176. 'var' => 'success',
  177. 'type' => TType::STRUCT,
  178. 'class' => '\OpenSearch\Generated\GeneralSearcher\SearchResult',
  179. ),
  180. 1 => array(
  181. 'var' => 'error',
  182. 'type' => TType::STRUCT,
  183. 'class' => '\OpenSearch\Generated\Common\OpenSearchException',
  184. ),
  185. 2 => array(
  186. 'var' => 'e',
  187. 'type' => TType::STRUCT,
  188. 'class' => '\OpenSearch\Generated\Common\OpenSearchClientException',
  189. ),
  190. );
  191. }
  192. if (is_array($vals)) {
  193. if (isset($vals['success'])) {
  194. $this->success = $vals['success'];
  195. }
  196. if (isset($vals['error'])) {
  197. $this->error = $vals['error'];
  198. }
  199. if (isset($vals['e'])) {
  200. $this->e = $vals['e'];
  201. }
  202. }
  203. }
  204. public function getName() {
  205. return 'OpenSearchSearcherService_execute_result';
  206. }
  207. public function read($input)
  208. {
  209. $xfer = 0;
  210. $fname = null;
  211. $ftype = 0;
  212. $fid = 0;
  213. $xfer += $input->readStructBegin($fname);
  214. while (true)
  215. {
  216. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  217. if ($ftype == TType::STOP) {
  218. break;
  219. }
  220. switch ($fid)
  221. {
  222. case 0:
  223. if ($ftype == TType::STRUCT) {
  224. $this->success = new \OpenSearch\Generated\GeneralSearcher\SearchResult();
  225. $xfer += $this->success->read($input);
  226. } else {
  227. $xfer += $input->skip($ftype);
  228. }
  229. break;
  230. case 1:
  231. if ($ftype == TType::STRUCT) {
  232. $this->error = new \OpenSearch\Generated\Common\OpenSearchException();
  233. $xfer += $this->error->read($input);
  234. } else {
  235. $xfer += $input->skip($ftype);
  236. }
  237. break;
  238. case 2:
  239. if ($ftype == TType::STRUCT) {
  240. $this->e = new \OpenSearch\Generated\Common\OpenSearchClientException();
  241. $xfer += $this->e->read($input);
  242. } else {
  243. $xfer += $input->skip($ftype);
  244. }
  245. break;
  246. default:
  247. $xfer += $input->skip($ftype);
  248. break;
  249. }
  250. $xfer += $input->readFieldEnd();
  251. }
  252. $xfer += $input->readStructEnd();
  253. return $xfer;
  254. }
  255. public function write($output) {
  256. $xfer = 0;
  257. $xfer += $output->writeStructBegin('OpenSearchSearcherService_execute_result');
  258. if ($this->success !== null) {
  259. if (!is_object($this->success)) {
  260. throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
  261. }
  262. $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
  263. $xfer += $this->success->write($output);
  264. $xfer += $output->writeFieldEnd();
  265. }
  266. if ($this->error !== null) {
  267. $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1);
  268. $xfer += $this->error->write($output);
  269. $xfer += $output->writeFieldEnd();
  270. }
  271. if ($this->e !== null) {
  272. $xfer += $output->writeFieldBegin('e', TType::STRUCT, 2);
  273. $xfer += $this->e->write($output);
  274. $xfer += $output->writeFieldEnd();
  275. }
  276. $xfer += $output->writeFieldStop();
  277. $xfer += $output->writeStructEnd();
  278. return $xfer;
  279. }
  280. }
  281. class OpenSearchSearcherServiceProcessor extends \OpenSearch\Generated\GeneralSearcher\GeneralSearcherServiceProcessor {
  282. public function __construct($handler) {
  283. parent::__construct($handler);
  284. }
  285. public function process($input, $output) {
  286. $rseqid = 0;
  287. $fname = null;
  288. $mtype = 0;
  289. $input->readMessageBegin($fname, $mtype, $rseqid);
  290. $methodname = 'process_'.$fname;
  291. if (!method_exists($this, $methodname)) {
  292. $input->skip(TType::STRUCT);
  293. $input->readMessageEnd();
  294. $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD);
  295. $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid);
  296. $x->write($output);
  297. $output->writeMessageEnd();
  298. $output->getTransport()->flush();
  299. return;
  300. }
  301. $this->$methodname($rseqid, $input, $output);
  302. return true;
  303. }
  304. protected function process_execute($seqid, $input, $output) {
  305. $args = new \OpenSearch\Generated\Search\OpenSearchSearcherService_execute_args();
  306. $args->read($input);
  307. $input->readMessageEnd();
  308. $result = new \OpenSearch\Generated\Search\OpenSearchSearcherService_execute_result();
  309. try {
  310. $result->success = $this->handler_->execute($args->searchParams);
  311. } catch (\OpenSearch\Generated\Common\OpenSearchException $error) {
  312. $result->error = $error;
  313. } catch (\OpenSearch\Generated\Common\OpenSearchClientException $e) {
  314. $result->e = $e;
  315. }
  316. $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
  317. if ($bin_accel)
  318. {
  319. thrift_protocol_write_binary($output, 'execute', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());
  320. }
  321. else
  322. {
  323. $output->writeMessageBegin('execute', TMessageType::REPLY, $seqid);
  324. $result->write($output);
  325. $output->writeMessageEnd();
  326. $output->getTransport()->flush();
  327. }
  328. }
  329. }