All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hotels.plunger.TupleScheme Maven / Gradle / Ivy

The newest version!
/**
 * Copyright 2015 Expedia Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hotels.plunger;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;

import cascading.flow.FlowProcess;
import cascading.scheme.Scheme;
import cascading.scheme.SinkCall;
import cascading.scheme.SourceCall;
import cascading.tap.Tap;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;

/** Simple {@link Scheme} implementation to glue everything together. */
class TupleScheme extends Scheme, List, Void, Void> {

  private static final long serialVersionUID = 1L;

  /** {@inheritDoc} */
  TupleScheme() {
    super();
  }

  /** {@inheritDoc} */
  TupleScheme(Fields fields) {
    super(fields, fields);
  }

  /** {@inheritDoc} */
  TupleScheme(Fields sourceFields, Fields sinkFields) {
    super(sourceFields, sinkFields);
  }

  /** {@inheritDoc} */
  @Override
  public void sourceConfInit(FlowProcess flowProcess, Tap, List> tap,
      Properties conf) {
  }

  /** {@inheritDoc} */
  @Override
  public void sinkConfInit(FlowProcess flowProcess, Tap, List> tap,
      Properties conf) {
  }

  /** {@inheritDoc} */
  @Override
  public boolean source(FlowProcess flowProcess, SourceCall> sourceCall)
    throws IOException {
    if (sourceCall.getInput().hasNext()) {
      sourceCall.getIncomingEntry().setTuple(sourceCall.getInput().next());
      return true;
    }
    return false;
  }

  /** {@inheritDoc} */
  @Override
  public void sink(FlowProcess flowProcess, SinkCall> sinkCall) throws IOException {
    sinkCall.getOutput().add(sinkCall.getOutgoingEntry().getTupleCopy());
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy