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
.IOException
;
10 import com
.yahoo
.pig
.data
.*;
11 import com
.yahoo
.pig
.impl
.PigContext
;
12 import com
.yahoo
.pig
.impl
.logicalLayer
.schema
.SchemaField
;
13 import com
.yahoo
.pig
.impl
.logicalLayer
.schema
.SchemaItem
;
14 import com
.yahoo
.pig
.impl
.logicalLayer
.schema
.SchemaItemList
;
16 final public class ConstEvalItem
extends EvalItem
{
18 public Double dval
= null;
20 public ConstEvalItem(PigContext pigContext
, String val
) {
25 public String
toString() {
26 return "'" + val
+ "'";
29 public List
<String
> getFuncs() {
30 return new ArrayList
<String
>();
33 public boolean isSimple() {
38 public String
stringVal(Tuple tup
) throws IOException
{
43 public Double
doubleVal(Tuple tup
) throws IOException
{
46 dval
= Double
.parseDouble(val
);
47 } catch(NumberFormatException exp
) {
48 exp
.printStackTrace();
55 public SchemaItem
mapInputSchema(SchemaItem input
){
58 return new SchemaField(null);
63 public void eval(Tuple input
, DataCollector output
) throws IOException
{
64 output
.add(new Tuple(new DataAtom(val
)));
65 output
.add(null); // EOF
69 public Datum
simpleEval(Tuple input
) throws IOException
{
70 return new DataAtom(val
);