001/*
002 * Copyright (c) 2007-2017 Xplenty, 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.flow.hadoop.util;
022
023import java.util.Collection;
024
025import cascading.tuple.Tuple;
026import cascading.tuple.collect.Spillable;
027
028/**
029 *
030 */
031public class LazySpillableTupleCollection extends LazyCollection implements Spillable
032  {
033  Spillable spillable;
034
035  public LazySpillableTupleCollection( Collection<Tuple> parent )
036    {
037    super( parent );
038
039    if( !( parent instanceof Spillable ) )
040      throw new IllegalArgumentException( "parent is not a Spillable type: " + parent.getClass().getName() );
041
042    this.spillable = (Spillable) parent;
043    }
044
045  @Override
046  public void setGrouping( Tuple group )
047    {
048    spillable.setGrouping( group );
049    }
050
051  @Override
052  public Tuple getGrouping()
053    {
054    return spillable.getGrouping();
055    }
056
057  @Override
058  public void setSpillStrategy( SpillStrategy spillStrategy )
059    {
060    spillable.setSpillStrategy( spillStrategy );
061    }
062
063  @Override
064  public void setSpillListener( SpillListener spillListener )
065    {
066    spillable.setSpillListener( spillListener );
067    }
068
069  @Override
070  public int spillCount()
071    {
072    return spillable.spillCount();
073    }
074  }