cascading.pipe.Pipe.getHeads()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中cascading.pipe.Pipe.getHeads()方法的一些代码示例,展示了Pipe.getHeads()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pipe.getHeads()方法的具体详情如下:
包路径:cascading.pipe.Pipe
类名称:Pipe
方法名:getHeads

Pipe.getHeads介绍

[英]Method getHeads returns the first Pipe instances in this pipe assembly.
[中]方法getHeads返回此管道部件中的第一个管道实例。

代码示例

代码示例来源:origin: cwensel/cascading

/**
 * Method getHeads returns the first Pipe instances in this pipe assembly.
 *
 * @return the first (type Pipe[]) of this Pipe object.
 */
public Pipe[] getHeads()
 {
 Pipe[] pipes = getPrevious();
 if( pipes.length == 0 )
  return new Pipe[]{this};
 if( pipes.length == 1 )
  return pipes[ 0 ].getHeads();
 Set<Pipe> heads = new HashSet<Pipe>();
 for( Pipe pipe : pipes )
  Collections.addAll( heads, pipe.getHeads() );
 return heads.toArray( new Pipe[ heads.size() ] );
 }

代码示例来源:origin: cwensel/cascading

/**
 * Method connect links the given source, sink, and trap Taps to the given pipe assembly. The given trap will
 * be linked to the assembly head along with the source.
 *
 * @param name   name to give the resulting Flow
 * @param source source Tap to bind to the head of the given tail Pipe
 * @param sink   sink Tap to bind to the given tail Pipe
 * @param trap   trap Tap to sink all failed Tuples into
 * @param tail   tail end of a pipe assembly
 * @return Flow
 */
public Flow connect( String name, Tap source, Tap sink, Tap trap, Pipe tail )
 {
 Map<String, Tap> sources = new HashMap<String, Tap>();
 sources.put( tail.getHeads()[ 0 ].getName(), source );
 Map<String, Tap> traps = new HashMap<String, Tap>();
 traps.put( tail.getHeads()[ 0 ].getName(), trap );
 return connect( name, sources, sink, traps, tail );
 }

代码示例来源:origin: cascading/cascading-bind

protected Map<String, Tap> getSourceTapsMap( Pipe... sinkPipes )
 {
 Set<Pipe> sourcePipesSet = new HashSet<Pipe>();
 for( Pipe pipe : sinkPipes )
  Collections.addAll( sourcePipesSet, pipe.getHeads() );
 Pipe[] sourcePipes = sourcePipesSet.toArray( new Pipe[ sourcePipesSet.size() ] );
 String[] names = makeNames( sourcePipes );
 return Cascades.tapsMap( sourcePipes, getSourceTapsFor( names ) );
 }

代码示例来源:origin: cwensel/cascading

/**
 * Method connect links the given source and sink Taps to the given pipe assembly.
 *
 * @param name   name to give the resulting Flow
 * @param source source Tap to bind to the head of the given tail Pipe
 * @param sink   sink Tap to bind to the given tail Pipe
 * @param tail   tail end of a pipe assembly
 * @return Flow
 */
public Flow connect( String name, Tap source, Tap sink, Pipe tail )
 {
 Map<String, Tap> sources = new HashMap<String, Tap>();
 sources.put( tail.getHeads()[ 0 ].getName(), source );
 return connect( name, sources, sink, tail );
 }

代码示例来源:origin: cwensel/cascading

/**
 * Method connect links the named source Taps and sink Tap to the given pipe assembly.
 * <p>
 * Since only once source Tap is given, it is assumed to be associated with the 'head' pipe.
 * So the head pipe does not need to be included as an argument.
 *
 * @param name   name to give the resulting Flow
 * @param source source Tap to bind to the head of the given tail Pipes
 * @param sinks  all tail names and sink Taps to bind to the given tail Pipes
 * @param tails  all tail ends of a pipe assembly
 * @return Flow
 */
public Flow connect( String name, Tap source, Map<String, Tap> sinks, Pipe... tails )
 {
 Set<Pipe> heads = new HashSet<Pipe>();
 for( Pipe pipe : tails )
  Collections.addAll( heads, pipe.getHeads() );
 if( heads.isEmpty() )
  throw new IllegalArgumentException( "no pipe instance found" );
 if( heads.size() != 1 )
  throw new IllegalArgumentException( "there may be only 1 head pipe instance, found " + heads.size() );
 Map<String, Tap> sources = new HashMap<String, Tap>();
 for( Pipe pipe : heads )
  sources.put( pipe.getName(), source );
 return connect( name, sources, sinks, tails );
 }

代码示例来源:origin: cwensel/cascading

/**
 * Method connect links the named trap Taps, source and sink Tap to the given pipe assembly.
 *
 * @param name   name to give the resulting Flow
 * @param source source Tap to bind to the head of the given tail Pipe
 * @param sink   sink Tap to bind to the given tail Pipe
 * @param traps  all pipe names and trap Taps to sink all failed Tuples into
 * @param tail   tail end of a pipe assembly
 * @return Flow
 */
public Flow connect( String name, Tap source, Tap sink, Map<String, Tap> traps, Pipe tail )
 {
 Map<String, Tap> sources = new HashMap<String, Tap>();
 sources.put( tail.getHeads()[ 0 ].getName(), source );
 Map<String, Tap> sinks = new HashMap<String, Tap>();
 sinks.put( tail.getName(), sink );
 return connect( name, sources, sinks, traps, tail );
 }

代码示例来源:origin: cwensel/cascading

/**
 * Method addSource adds a new source {@link Tap} named after the given {@link Pipe} for use in the resulting {@link Flow}.
 * <p>
 * If the given pipe is not a head pipe, it will be resolved. If more than one is found, an
 * {@link IllegalArgumentException} will be thrown.
 *
 * @param pipe   of Pipe
 * @param source of Tap
 * @return FlowDef
 */
public FlowDef addSource( Pipe pipe, Tap source )
 {
 if( pipe == null )
  throw new IllegalArgumentException( "pipe may not be null" );
 Pipe[] heads = pipe.getHeads();
 if( heads.length != 1 )
  throw new IllegalArgumentException( "pipe has too many heads, found: " + Arrays.toString( Pipe.names( heads ) ) );
 addSource( heads[ 0 ].getName(), source );
 return this;
 }

代码示例来源:origin: cwensel/cascading

for( Pipe head : pipe.getHeads() )

代码示例来源:origin: cwensel/cascading

@Test
public void testGetFirstJoin()
 {
 Pipe pipeFirst = new Pipe( "first" );
 Pipe pipeSecond = new Pipe( "second" );
 Pipe pipe = new CoGroup( pipeFirst, pipeSecond );
 pipe = new Pipe( pipe );
 pipe = new Pipe( pipe );
 pipe = new Pipe( pipe );
 assertTrue( pipe.getHeads()[ 0 ] == pipeFirst || pipe.getHeads()[ 0 ] == pipeSecond );
 }

代码示例来源:origin: org.springframework.data/spring-cascading

Collections.addAll(heads, pipe.getHeads());

代码示例来源:origin: cwensel/cascading

@Test
public void testGetFirstSplit()
 {
 Pipe pipeFirst = new Pipe( "first" );
 Pipe pipe = new Pipe( pipeFirst );
 Pipe pipeA = new Pipe( pipe );
 Pipe pipeB = new Pipe( pipe );
 pipeA = new Pipe( pipeA );
 pipeB = new Pipe( pipeB );
 assertEquals( pipeFirst, pipeA.getHeads()[ 0 ] );
 assertEquals( pipeFirst, pipeB.getHeads()[ 0 ] );
 }

代码示例来源:origin: cwensel/cascading

@Test
public void testGetFirst()
 {
 Pipe pipeFirst = new Pipe( "first" );
 Pipe pipe = new Pipe( pipeFirst );
 pipe = new Pipe( pipe );
 pipe = new Pipe( pipe );
 pipe = new Pipe( pipe );
 assertEquals( pipeFirst, pipe.getHeads()[ 0 ] );
 }

代码示例来源:origin: cwensel/cascading

@Test
 public void testNestedAssembliesAccessors() throws IOException
  {
  Pipe pipe = new Pipe( "test" );

  pipe = new SecondAssembly( pipe );

  Pipe[] allPrevious = pipe.getPrevious();

  assertEquals( "wrong number of previous", 1, allPrevious.length );

//    for( Pipe previous : allPrevious )
//      assertFalse( previous instanceof PipeAssembly );

  Pipe[] heads = pipe.getHeads();

  assertEquals( "wrong number of heads", 1, heads.length );

  for( Pipe head : heads )
   assertFalse( head instanceof SubAssembly );

  }

代码示例来源:origin: cascading/cascading-platform

@Test
 public void testNestedAssembliesAccessors() throws IOException
  {
  Pipe pipe = new Pipe( "test" );

  pipe = new SecondAssembly( pipe );

  Pipe[] allPrevious = pipe.getPrevious();

  assertEquals( "wrong number of previous", 1, allPrevious.length );

//    for( Pipe previous : allPrevious )
//      assertFalse( previous instanceof PipeAssembly );

  Pipe[] heads = pipe.getHeads();

  assertEquals( "wrong number of heads", 1, heads.length );

  for( Pipe head : heads )
   assertFalse( head instanceof SubAssembly );

  }

相关文章