001/*
002 * Copyright (c) 2007-2016 Concurrent, Inc. All Rights Reserved.
003 *
004 * Project and contact information: http://www.cascading.org/
005 *
006 * This file is part of the Cascading project.
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020
021package cascading.operation;
022
023import java.util.Iterator;
024
025import cascading.pipe.joiner.JoinerClosure;
026import cascading.tuple.Fields;
027import cascading.tuple.TupleEntry;
028import cascading.tuple.TupleEntryCollector;
029
030/**
031 * Class OperationCall is the common base class for {@link FunctionCall}, {@link FilterCall},
032 * {@link AggregatorCall}, {@link ValueAssertionCall}, and {@link GroupAssertionCall}.
033 */
034public class ConcreteCall<C> implements FunctionCall<C>, FilterCall<C>, AggregatorCall<C>, BufferCall<C>, ValueAssertionCall<C>, GroupAssertionCall<C>
035  {
036  /** Field context */
037  private C context;
038  /** Field group */
039  private TupleEntry group;
040  /** Field argumentFields */
041  private Fields argumentFields;
042  /** Field arguments */
043  private TupleEntry arguments;
044  /** Field argumentsIterator */
045  private Iterator<TupleEntry> argumentsIterator;
046  /** Field declaredFields */
047  private Fields declaredFields;
048  /** Field outputCollector */
049  private TupleEntryCollector outputCollector;
050  /** Field retainValues */
051  private boolean retainValues = false;
052  /** Fields joinerClosure * */
053  private JoinerClosure joinerClosure;
054
055  /** Constructor OperationCall creates a new OperationCall instance. */
056  public ConcreteCall()
057    {
058    }
059
060  /**
061   * Constructor ConcreteCall creates a new ConcreteCall instance.
062   *
063   * @param argumentFields of type Fields
064   */
065  public ConcreteCall( Fields argumentFields )
066    {
067    this.argumentFields = argumentFields;
068    }
069
070  /**
071   * Constructor ConcreteCall creates a new ConcreteCall instance.
072   *
073   * @param argumentFields of type Fields
074   * @param declaredFields of type Fields
075   */
076  public ConcreteCall( Fields argumentFields, Fields declaredFields )
077    {
078    this.argumentFields = argumentFields;
079    this.declaredFields = declaredFields;
080    }
081
082  /**
083   * Constructor OperationCall creates a new OperationCall instance.
084   *
085   * @param arguments       of type TupleEntry
086   * @param outputCollector of type TupleCollector
087   */
088  public ConcreteCall( TupleEntry arguments, TupleEntryCollector outputCollector )
089    {
090    this.arguments = arguments;
091    this.outputCollector = outputCollector;
092    }
093
094  public ConcreteCall( ConcreteCall<C> concreteCall )
095    {
096    this.arguments = concreteCall.arguments;
097    this.argumentFields = concreteCall.argumentFields;
098    this.argumentsIterator = concreteCall.argumentsIterator;
099    this.context = concreteCall.context;
100    this.declaredFields = concreteCall.declaredFields;
101    this.outputCollector = concreteCall.outputCollector;
102    this.retainValues = concreteCall.retainValues;
103    this.joinerClosure = concreteCall.joinerClosure;
104    }
105
106  /** @see AggregatorCall#getContext() */
107  public C getContext()
108    {
109    return context;
110    }
111
112  public void setContext( C context )
113    {
114    this.context = context;
115    }
116
117  /** @see AggregatorCall#getGroup() */
118  public TupleEntry getGroup()
119    {
120    return group;
121    }
122
123  public void setGroup( TupleEntry group )
124    {
125    this.group = group;
126    }
127
128  public Fields getArgumentFields()
129    {
130    return argumentFields;
131    }
132
133  public void setArgumentFields( Fields argumentFields )
134    {
135    this.argumentFields = argumentFields;
136    }
137
138  /** @see BufferCall#getArgumentsIterator() */
139  public Iterator<TupleEntry> getArgumentsIterator()
140    {
141    return argumentsIterator;
142    }
143
144  public void setArgumentsIterator( Iterator<TupleEntry> argumentsIterator )
145    {
146    this.argumentsIterator = argumentsIterator;
147    }
148
149  /** @see FunctionCall#getArguments() */
150  public TupleEntry getArguments()
151    {
152    return arguments;
153    }
154
155  public void setArguments( TupleEntry arguments )
156    {
157    this.arguments = arguments;
158    }
159
160  public Fields getDeclaredFields()
161    {
162    return declaredFields;
163    }
164
165  /** @see FunctionCall#getOutputCollector() */
166  public TupleEntryCollector getOutputCollector()
167    {
168    return outputCollector;
169    }
170
171  public void setOutputCollector( TupleEntryCollector outputCollector )
172    {
173    this.outputCollector = outputCollector;
174    }
175
176  @Override
177  public void setRetainValues( boolean retainValues )
178    {
179    this.retainValues = retainValues;
180    }
181
182  @Override
183  public boolean isRetainValues()
184    {
185    return retainValues;
186    }
187
188  public void setJoinerClosure( JoinerClosure joinerClosure )
189    {
190    this.joinerClosure = joinerClosure;
191    }
192
193  @Override
194  public JoinerClosure getJoinerClosure()
195    {
196    return joinerClosure;
197    }
198  }