2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.impl
.eval
.func
;
7 import java
.io
.IOException
;
9 import com
.yahoo
.pig
.BagEvalFunc
;
10 import com
.yahoo
.pig
.data
.*;
11 import com
.yahoo
.pig
.impl
.PigContext
;
12 import com
.yahoo
.pig
.impl
.eval
.EvalItemList
;
14 public class BagFuncEvalItem
extends FuncEvalItem
{
16 public BagFuncEvalItem(PigContext pigContext
, BagEvalFunc func
, EvalItemList args
) {
17 super(pigContext
, func
, args
);
21 public void eval(Tuple input
, DataCollector output
) throws IOException
{
23 Datum amendKey
= null;
24 if (input
instanceof AmendableTuple
) amendKey
= ((AmendableTuple
) input
).getAmendKey();
26 output
= setupBagProcessingPipeline(amendKey
, output
);
28 ((BagEvalFunc
) func
).exec(args
.simpleEval(input
), output
);
29 if (!output
.isStale())
30 output
.add(null); // EOF
34 public DataBag
simpleEval(Tuple input
) throws IOException
{
35 DataBag d
= BagFactory
.getInstance().getNewBag();
37 DataCollector emitTo
= d
;
39 if (nestedEval
!= null) emitTo
= nestedEval
.collector(d
);
41 ((BagEvalFunc
) func
).exec(args
.simpleEval(input
), emitTo
);
47 public String
stringVal(Tuple tup
) throws IOException
{
48 throw new IOException("Internal error: illegal to call stringVal() on FuncEvalItem");
52 public Double
doubleVal(Tuple tup
) throws IOException
{
53 throw new IOException("Internal error: illegal to call doubleVal() on FuncEvalItem");