Package cascading.tuple.util

Examples of cascading.tuple.util.TupleBuilder


    }

    private TupleBuilder makeBuilder( final Fields valueField, final Fields joinField )
      {
      if( valueField.isUnknown() || joinField.isNone() )
        return new TupleBuilder()
        {
        @Override
        public Tuple makeResult( Tuple valueTuple, Tuple groupTuple )
          {
          valueTuple.set( valueFields[ cleanPos ], joinFields[ cleanPos ], groupTuple );

          return valueTuple;
          }
        };

      return new TupleBuilder()
      {
      Tuple result = TupleViews.createOverride( valueField, joinField );

      @Override
      public Tuple makeResult( Tuple valueTuple, Tuple groupTuple )
View Full Code Here


    }

  protected TupleBuilder createNarrowBuilder( final Fields incomingFields, final Fields narrowFields )
    {
    if( narrowFields.isNone() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return Tuple.NULL;
        }
      };

    if( incomingFields.isUnknown() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return input.get( incomingFields, narrowFields );
        }
      };

    if( narrowFields.isAll() ) // dubious this is ever reached
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return input;
View Full Code Here

    return createDefaultNarrowBuilder( incomingFields, narrowFields );
    }

  protected TupleBuilder createDefaultNarrowBuilder( final Fields incomingFields, final Fields narrowFields )
    {
    return new TupleBuilder()
    {
    Tuple result = createNarrow( incomingFields.getPos( narrowFields ) );

    @Override
    public Tuple makeResult( Tuple input, Tuple output )
View Full Code Here

    }

  protected TupleBuilder createNulledBuilder( final Fields incomingFields, final Fields keyField )
    {
    if( incomingFields.isUnknown() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return Tuples.nulledCopy( incomingFields, input, keyField );
        }
      };

    if( keyField.isNone() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return input;
        }
      };

    if( keyField.isAll() )
      return new TupleBuilder()
      {
      Tuple nullTuple = Tuple.size( incomingFields.size() );

      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return nullTuple;
        }
      };

    return new TupleBuilder()
    {
    Tuple nullTuple = Tuple.size( keyField.size() );
    Tuple result = createOverride( incomingFields, keyField );

    @Override
View Full Code Here

    }

  // we must make a new Tuple instance to wrap the incoming copy
  protected TupleBuilder createDefaultNarrowBuilder( final Fields incomingFields, final Fields narrowFields )
    {
    return new TupleBuilder()
    {
    int[] pos = incomingFields.getPos( narrowFields );

    @Override
    public Tuple makeResult( Tuple input, Tuple output )
View Full Code Here

  protected abstract Fields getIncomingArgumentsFields();

  protected TupleBuilder createArgumentsBuilder( final Fields incomingFields, final Fields argumentsSelector )
    {
    if( incomingFields.isUnknown() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return input.get( incomingFields, argumentsSelector );
        }
      };

    if( argumentsSelector.isAll() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return input;
        }
      };

    if( argumentsSelector.isNone() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return Tuple.NULL;
        }
      };

    final Fields inputDeclarationFields = Fields.asDeclaration( incomingFields );

    return new TupleBuilder()
    {
    Tuple result = createNarrow( inputDeclarationFields.getPos( argumentsSelector ) );

    @Override
    public Tuple makeResult( Tuple input, Tuple output )
View Full Code Here

  protected TupleBuilder createOutgoingBuilder( final Operator operator, final Fields incomingFields, final Fields argumentSelector, final Fields remainderFields, final Fields declaredFields, final Fields outgoingSelector )
    {
    final Fields inputDeclarationFields = Fields.asDeclaration( incomingFields );

    if( operator.getOutputSelector().isResults() )
      return new TupleBuilder()
      {
      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return output;
        }
      };

    if( operator.getOutputSelector().isAll() && !( incomingFields.isUnknown() || declaredFields.isUnknown() ) )
      return new TupleBuilder()
      {
      Tuple result = createComposite( inputDeclarationFields, declaredFields );

      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return TupleViews.reset( result, input, output );
        }
      };

    if( operator.getOutputSelector().isReplace() )
      {
      if( incomingFields.isUnknown() )
        return new TupleBuilder()
        {
        Fields resultFields = operator.getFieldDeclaration().isArguments() ? argumentSelector : declaredFields;

        @Override
        public Tuple makeResult( Tuple input, Tuple output )
          {
          Tuple result = new Tuple( input );

          result.set( Fields.UNKNOWN, resultFields, output );

          return result;
          }
        };

      return new TupleBuilder()
      {
      Fields resultFields = operator.getFieldDeclaration().isArguments() ? argumentSelector : declaredFields;
      Tuple result = createOverride( inputDeclarationFields, resultFields );

      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        return TupleViews.reset( result, input, output );
        }
      };
      }

    if( operator.getOutputSelector().isSwap() )
      {
      if( remainderFields.size() == 0 ) // the same as Fields.RESULTS
        return new TupleBuilder()
        {
        @Override
        public Tuple makeResult( Tuple input, Tuple output )
          {
          return output;
          }
        };
      else if( declaredFields.isUnknown() )
        return new TupleBuilder()
        {
        @Override
        public Tuple makeResult( Tuple input, Tuple output )
          {
          return input.get( incomingFields, remainderFields ).append( output );
          }
        };
      else
        return new TupleBuilder()
        {
        Tuple view = createNarrow( inputDeclarationFields.getPos( remainderFields ) );
        Tuple result = createComposite( Fields.asDeclaration( remainderFields ), declaredFields );

        @Override
        public Tuple makeResult( Tuple input, Tuple output )
          {
          TupleViews.reset( view, input );

          return TupleViews.reset( result, view, output );
          }
        };
      }

    if( incomingFields.isUnknown() || declaredFields.isUnknown() )
      return new TupleBuilder()
      {
      Fields selector = outgoingSelector.isUnknown() ? Fields.ALL : outgoingSelector;
      TupleEntry incoming = new TupleEntry( incomingFields, true );
      TupleEntry declared = new TupleEntry( declaredFields, true );

      @Override
      public Tuple makeResult( Tuple input, Tuple output )
        {
        incoming.setTuple( input );
        declared.setTuple( output );

        return TupleEntry.select( selector, incoming, declared );
        }
      };

    return new TupleBuilder()
    {
    Fields inputFields = operator.getFieldDeclaration().isArguments() ? Fields.mask( inputDeclarationFields, declaredFields ) : inputDeclarationFields;
    Tuple appended = createComposite( inputFields, declaredFields );
    Fields allFields = Fields.resolve( Fields.ALL, inputFields, declaredFields );
    Tuple result = createNarrow( allFields.getPos( outgoingSelector ), appended );
View Full Code Here

TOP

Related Classes of cascading.tuple.util.TupleBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.