2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.impl
.eval
;
7 import java
.io
.ByteArrayInputStream
;
8 import java
.io
.IOException
;
11 import com
.yahoo
.pig
.data
.*;
12 import com
.yahoo
.pig
.impl
.PigContext
;
13 import com
.yahoo
.pig
.impl
.logicalLayer
.parser
.ParseException
;
14 import com
.yahoo
.pig
.impl
.logicalLayer
.parser
.QueryParser
;
15 import com
.yahoo
.pig
.impl
.logicalLayer
.schema
.SchemaItem
;
17 public abstract class EvalItem
{
19 protected PigContext pigContext
;
20 protected EvalItem(PigContext pigContext
) {
21 this.pigContext
= pigContext
;
24 public SchemaItem schema
= null;
26 public abstract void eval(Tuple input
, DataCollector output
) throws IOException
;
28 public abstract Datum
simpleEval(Tuple input
) throws IOException
;
30 public abstract List
<String
> getFuncs();
32 public abstract boolean isSimple();
34 public abstract String
stringVal(Tuple tup
) throws IOException
;
36 public abstract Double
doubleVal(Tuple tup
) throws IOException
;
38 public abstract SchemaItem
mapInputSchema(SchemaItem input
);
40 public void finish(){}
43 * Creates a copy of this eval item
45 public EvalItem
copy() throws ParseException
{
47 ByteArrayInputStream in
= new ByteArrayInputStream(toString().getBytes());
48 QueryParser parser
= new QueryParser(in
, pigContext
, null);
49 item
= parser
.PEvalItem();