001/*
002 * Copyright (c) 2016-2017 Chris K Wensel <chris@wensel.net>. All Rights Reserved.
003 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
004 *
005 * Project and contact information: http://www.cascading.org/
006 *
007 * This file is part of the Cascading project.
008 *
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *     http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 */
021
022package cascading.scheme;
023
024import cascading.tap.Tap;
025import cascading.tuple.TupleEntry;
026
027/**
028 * SourceCall provides access to the current {@link Scheme#source(cascading.flow.FlowProcess, SourceCall)} invocation
029 * arguments.
030 * <p>
031 * Use the Context to store thread local values.
032 *
033 * @param <Context>
034 * @param <Input>
035 */
036public interface SourceCall<Context, Input>
037  {
038  /**
039   * Method getContext returns the context of this SourceCall object.
040   *
041   * @return the context (type C) of this SourceCall object.
042   */
043  Context getContext();
044
045  /**
046   * Method setContext sets the context of this SourceCall object.
047   *
048   * @param context the context of this SourceCall object.
049   */
050  void setContext( Context context );
051
052  /**
053   * Method getIncomingEntry returns a pre-prepared {@link TupleEntry} to be populated
054   * with the input values from {@link #getInput()}.
055   * <p>
056   * That is, using the getInput() method, retrieve the current incoming values and
057   * place them into the getIncomingEntry() via {@link TupleEntry#setTuple(cascading.tuple.Tuple)}
058   * or by modifying the tuple returned from {@link cascading.tuple.TupleEntry#getTuple()}.
059   * <p>
060   * The returned Tuple entry is guaranteed to be the size of the declared incoming source fields.
061   * <p>
062   * The returned TupleEntry from this method is modifiable and is intended to be re-used. This is an exception to
063   * the general rule that passed TupleEntry instances must not be modified.
064   *
065   * @return TupleEntry
066   */
067  TupleEntry getIncomingEntry();
068
069  /**
070   * Method getInput returns the input mechanism for the underlying platform used to retrieve new values (records,
071   * lines, etc).
072   * <p>
073   * Do not cache the returned value as it may change.
074   *
075   * @return the platform dependent input handler
076   */
077  Input getInput();
078
079  /**
080   * Method getTap returns the parent {@link Tap} instance that encapsulates the current {@link Scheme} instance.
081   *
082   * @return the parent Tap
083   */
084  Tap getTap();
085  }