Package cascading.operation

Examples of cascading.operation.Filter


//    performLimitTest( 5, 3, 2 );
//    }

  private void performLimitTest( int limit, int tasks, int values )
    {
    Filter filter = new Limit( limit );

    int count = 0;

    for( int i = 0; i < tasks; i++ )
      {
      FlowProcess process = new TestFlowProcess( tasks, i );

      filter.prepare( process, operationCall );

      operationCall.setArguments( getEntry( new Tuple( 1 ) ) );

      for( int j = 0; j < values; j++ )
        {
        if( !filter.isRemove( process, operationCall ) )
          count++;
        }
      }

    String message = String.format( "limit:%d tasks:%d values:%d", limit, tasks, values );
View Full Code Here


    }

  @Test
  public void testNotNull()
    {
    Filter filter = new FilterNotNull();

    assertTrue( invokeFilter( filter, new Tuple( 1 ) ) );
    assertFalse( invokeFilter( filter, new Tuple( (Comparable) null ) ) );
    assertTrue( invokeFilter( filter, new Tuple( "0", 1 ) ) );
    assertTrue( invokeFilter( filter, new Tuple( "0", null ) ) );
View Full Code Here

    }

  @Test
  public void testNull()
    {
    Filter filter = new FilterNull();

    assertFalse( invokeFilter( filter, new Tuple( 1 ) ) );
    assertTrue( invokeFilter( filter, new Tuple( (Comparable) null ) ) );

    assertFalse( invokeFilter( filter, new Tuple( "0", 1 ) ) );
View Full Code Here

  public void testAnd()
    {
    Fields[] fields = new Fields[]{new Fields( 0 ), new Fields( 1 )};

    Filter[] filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( true )};
    Filter filter = new And( fields, filters );

    assertTrue( invokeFilter( filter, new Tuple( 1, 2 ) ) );

    filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( false )};
    filter = new And( fields, filters );
View Full Code Here

  public void testOr()
    {
    Fields[] fields = new Fields[]{new Fields( 0 ), new Fields( 1 )};

    Filter[] filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( true )};
    Filter filter = new Or( fields, filters );

    assertTrue( invokeFilter( filter, new Tuple( 1, 2 ) ) );

    filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( false )};
    filter = new Or( fields, filters );
View Full Code Here

  public void testXor()
    {
    Fields[] fields = new Fields[]{new Fields( 0 ), new Fields( 1 )};

    Filter[] filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( true )};
    Filter filter = new Xor( fields[ 0 ], filters[ 0 ], fields[ 1 ], filters[ 1 ] );

    assertFalse( invokeFilter( filter, new Tuple( 1, 2 ) ) );

    filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( false )};
    filter = new Xor( fields[ 0 ], filters[ 0 ], fields[ 1 ], filters[ 1 ] );
View Full Code Here

  public void testNot()
    {
    Fields[] fields = new Fields[]{new Fields( 0 ), new Fields( 1 )};

    Filter[] filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( true )};
    Filter filter = new Not( new Or( fields, filters ) );

    assertFalse( invokeFilter( filter, new Tuple( 1, 2 ) ) );

    filters = new Filter[]{new BooleanFilter( true ), new BooleanFilter( false )};
    filter = new Not( new Or( fields, filters ) );
View Full Code Here

    }

  @Test
  public void testPartialDuplicates()
    {
    Filter filter = new Unique.FilterPartialDuplicates( 2 );

    Tuple[] tuples = new Tuple[]{new Tuple( 1 ), // false - first time
                                 new Tuple( 1 ), // true - second time
                                 new Tuple( (Comparable) null ), // false
                                 new Tuple( (Comparable) null ), // true - make lots, its a LRU
View Full Code Here

      performSampleTest( i, 100000 );
    }

  private void performSampleTest( double sample, int values )
    {
    Filter filter = new Sample( sample );

    int count = 0;

    filter.prepare( null, operationCall );

    operationCall.setArguments( getEntry( new Tuple( 1 ) ) );

    for( int j = 0; j < values; j++ )
      {
      if( !filter.isRemove( null, operationCall ) )
        count++;
      }

    String message = String.format( "sample:%f values:%d", sample, values );
View Full Code Here

    Tap source = getPlatform().getTextFile( inputFileApache );
    Tap sink = getPlatform().getTextFile( getOutputPath( "filter" ), SinkMode.REPLACE );

    Pipe pipe = new Pipe( "test" );

    Filter filter = new RegexFilter( "^68.*" );

    pipe = new Each( pipe, new Fields( "line" ), filter );

    Flow flow = getPlatform().getFlowConnector().connect( source, sink, pipe );

View Full Code Here

TOP

Related Classes of cascading.operation.Filter

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.