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

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

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

Pipe.names介绍

[英]Convenience method for finding all Pipe names in an assembly.
[中]查找部件中所有管道名称的简便方法。

代码示例

代码示例来源: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

protected void verifyTraps( FlowDef flowDef, Pipe[] flowTails )
 {
 verifyNotSourcesSinks( flowDef.getTraps(), flowDef.getSources(), flowDef.getSinks(), "trap" );
 Set<String> names = new HashSet<String>( asList( Pipe.names( flowTails ) ) );
 for( String name : flowDef.getTraps().keySet() )
  {
  if( !names.contains( name ) )
   throw new PlannerException( "trap name not found in assembly: '" + name + "'" );
  }
 }

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

remainingSinks.removeAll( asList( Pipe.names( flowTails ) ) );

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

protected void verifyCheckpoints( FlowDef flowDef, Pipe[] flowTails )
 {
 verifyNotSourcesSinks( flowDef.getCheckpoints(), flowDef.getSources(), flowDef.getSinks(), "checkpoint" );
 for( Tap checkpointTap : flowDef.getCheckpoints().values() )
  {
  Scheme scheme = checkpointTap.getScheme();
  if( scheme.getSourceFields().equals( Fields.UNKNOWN ) && scheme.getSinkFields().equals( Fields.ALL ) )
   continue;
  throw new PlannerException( "checkpoint tap scheme must be undeclared, source fields must be UNKNOWN, and sink fields ALL, got: " + scheme.toString() );
  }
 Set<String> names = new HashSet<String>( asList( Pipe.names( flowTails ) ) );
 for( String name : flowDef.getCheckpoints().keySet() )
  {
  if( !names.contains( name ) )
   throw new PlannerException( "named checkpoint declared in FlowDef, but no named branch found in pipe assembly: '" + name + "'" );
  Set<Pipe> pipes = new HashSet<Pipe>( asList( Pipe.named( name, flowTails ) ) );
  int count = 0;
  for( Pipe pipe : pipes )
   {
   if( pipe instanceof Checkpoint )
    count++;
   }
  if( count == 0 )
   throw new PlannerException( "no checkpoint pipe with branch name found in pipe assembly: '" + name + "'" );
  if( count > 1 )
   throw new PlannerException( "more than one checkpoint pipe with branch name found in pipe assembly: '" + name + "'" );
  }
 }

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

@Test
public void testGetNames()
 {
 Pipe pipe = new Pipe( "first" );
 pipe = new NestedSubAssembly( pipe );
 Pipe pipe1 = new Pipe( "fifth", ( (SubAssembly) pipe ).getTails()[ 0 ] );
 Pipe pipe2 = new Pipe( "sixth", ( (SubAssembly) pipe ).getTails()[ 1 ] );
 assertEquals( 6, Pipe.names( pipe1, pipe2 ).length );
 assertEquals( 1, Pipe.named( "second", pipe1, pipe2 ).length );
 assertEquals( 1, Pipe.named( "sixth", pipe1, pipe2 ).length );
 assertEquals( pipe2, Pipe.named( "sixth", pipe1, pipe2 )[ 0 ] );
 }
}

相关文章