2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.impl
.physicalLayer
;
7 import java
.io
.IOException
;
9 import com
.yahoo
.pig
.data
.*;
10 import com
.yahoo
.pig
.impl
.eval
.*;
11 import com
.yahoo
.pig
.impl
.util
.DataBuffer
;
13 // unary, non-blocking operator.
14 class POEval
extends PhysicalOperator
{
16 private boolean alreadyOpen
= false;
17 private DataBuffer buf
= null;
18 private DataCollector evalPipeline
= null;
19 private boolean inputDrained
;
21 public POEval(PhysicalOperator input
, EvalSpecPipe specIn
, int outputType
) {
23 inputs
= new PhysicalOperator
[1];
29 public POEval(EvalSpecPipe specIn
, int outputType
) {
31 inputs
= new PhysicalOperator
[1];
37 public boolean open(boolean continueFromLast
) throws IOException
{
38 if (!super.open(continueFromLast
)) return false;
41 buf
= new DataBuffer();
42 if (evalPipeline
== null)
43 evalPipeline
= spec
.collector(buf
);
50 public Tuple
getNext() throws IOException
{
53 // no pending outputs, so look to input to provide more food
59 Tuple nextTuple
= inputs
[0].getNext();
61 if (nextTuple
== null)
64 evalPipeline
.add(nextTuple
); // if nextTuple is null, then we're inserting an EOF marker
66 Tuple t
= buf
.removeFirst();