(Tuple input)
| 347 | } |
| 348 | |
| 349 | private Object getOutput(Tuple input) throws ExecException { |
| 350 | if (outputQueue == null) { |
| 351 | throw new ExecException("Process has already been shut down. No way to retrieve output for input: " + input); |
| 352 | } |
| 353 | |
| 354 | if (ScriptingOutputCapturer.isClassCapturingOutput() && |
| 355 | !soc.isInstanceCapturingOutput()) { |
| 356 | Tuple t = TupleFactory.getInstance().newTuple(TURN_ON_OUTPUT_CAPTURING); |
| 357 | try { |
| 358 | inputQueue.put(t); |
| 359 | } catch (InterruptedException e) { |
| 360 | throw new ExecException("Failed adding capture input flag to inputQueue"); |
| 361 | } |
| 362 | soc.setInstanceCapturingOutput(true); |
| 363 | } |
| 364 | |
| 365 | try { |
| 366 | if (this.getInputSchema() == null || this.getInputSchema().size() == 0) { |
| 367 | //When nothing is passed into the UDF the tuple |
| 368 | //being sent is the full tuple for the relation. |
| 369 | //We want it to be nothing (since that's what the user wrote). |
| 370 | input = TupleFactory.getInstance().newTuple(0); |
| 371 | } |
| 372 | inputQueue.put(input); |
| 373 | } catch (Exception e) { |
| 374 | throw new ExecException("Failed adding input to inputQueue", e); |
| 375 | } |
| 376 | Object o = null; |
| 377 | try { |
| 378 | if (outputQueue != null) { |
| 379 | o = outputQueue.take(); |
| 380 | if (o == NULL_OBJECT) { |
| 381 | o = null; |
| 382 | } |
| 383 | } |
| 384 | } catch (Exception e) { |
| 385 | throw new ExecException("Problem getting output", e); |
| 386 | } |
| 387 | |
| 388 | if (o == ERROR_OUTPUT) { |
| 389 | outputQueue = null; |
| 390 | if (outerrThreadsError == null) { |
| 391 | outerrThreadsError = new StreamingUDFException(this.language, "Problem with streaming udf. Can't recreate exception."); |
| 392 | } |
| 393 | throw outerrThreadsError; |
| 394 | } |
| 395 | |
| 396 | return o; |
| 397 | } |
| 398 | |
| 399 | @Override |
| 400 | public Schema outputSchema(Schema input) { |
no test coverage detected