Initial import into git.
[galago.git] / java / pig-galago / src / com / yahoo / pig / impl / eval / func / BagFuncEvalItem.java
blob582c487177685b62ba51030eabb5d739216cd0eb
1 /*
2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
4 */
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);
20 @Override
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
33 @Override
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);
43 return d;
46 @Override
47 public String stringVal(Tuple tup) throws IOException {
48 throw new IOException("Internal error: illegal to call stringVal() on FuncEvalItem");
51 @Override
52 public Double doubleVal(Tuple tup) throws IOException {
53 throw new IOException("Internal error: illegal to call doubleVal() on FuncEvalItem");