Examples of TupleEntryIterator


Examples of cascading.tuple.TupleEntryIterator

    flow.complete();

    validateLength( flow, 5 );

    // test the ordering
    TupleEntryIterator iterator = flow.openSink();
    TestText target = (TestText) iterator.next().getObject( "group" );
    String value = target == null ? null : target.value;
//    System.out.println( "value = " + value );

    while( iterator.hasNext() )
      {
      TestText nextTarget = (TestText) iterator.next().getObject( "group" );
      String next = nextTarget == null ? null : nextTarget.value;

      if( value != null && value.compareTo( next ) >= 0 )
        fail( "not increasing: " + value + " " + value );

      value = next;
//      System.out.println( "value = " + value );
      }

    iterator.close();
    }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    flow.complete();

    validateLength( flow, 37, null );

    TupleEntryIterator iterator = flow.openSink();

    String line = iterator.next().getString( 0 );
    assertTrue( "not equal: wrong values", line.matches( "[a-z]\t[0-9]\t[A-Z]" ) );

    iterator.close();
    }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    flow.complete();

    validateLength( flow, 37, null );

    TupleEntryIterator iterator = flow.openSink();

    String line = iterator.next().getTuple().toString();
    assertTrue( "not equal: wrong values: " + line, line.matches( "[0-9]\t[a-z]\t[A-Z]" ) );

    iterator.close();
    }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    validateLength( flow.openTapForRead( test ), 1, 1 );

    test = getPlatform().getTabDelimitedFile( new Fields( "upper" ), sink.getIdentifier().toString() + "/2-b", SinkMode.KEEP );
    validateLength( flow.openTapForRead( test ), 1, 1 );

    TupleEntryIterator input = flow.openTapForRead( test ); // open 2-b

    assertEquals( "wrong value", "B", input.next().getObject( 0 ) );

    input.close();
    }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    validateCase( test, testCase, sink );
    }

  private void validateCase( String test, Boolean[] testCase, Tap sink ) throws IOException
    {
    TupleEntryIterator iterator = sink.openForRead( getPlatform().getFlowProcess() );
    LinkedHashMap<Long, List<String>> group = new LinkedHashMap<Long, List<String>>();

    while( iterator.hasNext() )
      {
      Tuple tuple = iterator.next().getTuple();

      String[] values = tuple.getString( 0 ).split( "\\s" );

      long num = Long.parseLong( values[ 0 ] );
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

      }
    }

  private void validateFile( Tap tap, int length, int uniqueValues, boolean isReversed, int comparePosition ) throws IOException, ParseException
    {
    TupleEntryIterator iterator = tap.openForRead( getPlatform().getFlowProcess() );

    Set<Long> values = new HashSet<Long>();

    long lastValue = isReversed ? Long.MAX_VALUE : Long.MIN_VALUE;
    int count = 0;

    while( iterator.hasNext() )
      {
      Tuple tuple = iterator.next().getTuple();
      count++;

      tuple = new Tuple( (Object[]) tuple.getString( 1 ).split( "\t" ) );

      long value = tuple.getLong( comparePosition );
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    @Override
    public void operate( FlowProcess flowProcess, FunctionCall functionCall )
      {
      try
        {
        TupleEntryIterator iterator = flowProcess.openTapForRead( tap );

        while( iterator.hasNext() )
          functionCall.getOutputCollector().add( new Tuple( iterator.next().getTuple() ) );

        iterator.close();
        }
      catch( IOException exception )
        {
        exception.printStackTrace();
        }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

  @Test
  public void testTupleEntryNextTwice() throws IOException
    {
    Tap tap = getPlatform().getTextFile( inputFileNums10 );

    TupleEntryIterator iterator = tap.openForRead( getPlatform().getFlowProcess() );

    int count = 0;
    while( iterator.hasNext() )
      {
      iterator.next();
      count++;
      }

    assertFalse( iterator.hasNext() );
    assertEquals( 10, count );
    }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

    LOG.info( "reading step state from local path: {}", stepStatePath );

    Hfs temp = new Lfs( new TextLine( new Fields( "line" ) ), stepStatePath.toString() );

    TupleEntryIterator reader = null;

    try
      {
      reader = temp.openForRead( new HadoopFlowProcess( jobConf ) );

      if( !reader.hasNext() )
        throw new FlowException( "step state path is empty: " + temp.getIdentifier() );

      return reader.next().getString( 0 );
      }
    catch( IOException exception )
      {
      throw new FlowException( "unable to find state path: " + temp.getIdentifier(), exception );
      }
    finally
      {
      try
        {
        if( reader != null )
          reader.close();
        }
      catch( IOException exception )
        {
        LOG.warn( "error closing state path reader", exception );
        }
View Full Code Here

Examples of cascading.tuple.TupleEntryIterator

      new Tuple( "c", 10, 4, (double) 10 / 4, (double) 10 / 4, 4 ),
      new Tuple( "d", 6, 2, (double) 6 / 2, (double) 6 / 2, 4 ),
      new Tuple( "e", 5, 1, (double) 5 / 1, (double) 5 / 1, 5 )
    };

    TupleEntryIterator iterator = flow.openSink();
    int count = 0;

    while( iterator.hasNext() )
      assertEquals( results[ count++ ], iterator.next().getTuple() );

    iterator.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.