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

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

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

Pipe.getPrevious介绍

[英]Get all the upstream pipes this pipe is connected to. This method will return the Pipe instances passed on the constructors as inputs to this Pipe instance.
[中]获取该管道连接的所有上游管道。此方法将返回传递给构造函数的管道实例,作为此管道实例的输入。

代码示例

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

public static Integer findOrdinal( Pipe pipe, Pipe previous )
 {
 Pipe[] previousPipes = pipe.getPrevious();
 TreeMap<Integer, Integer> sorted = new TreeMap<>();
 for( int i = 0; i < previousPipes.length; i++ )
  {
  int result = isPrevious( previousPipes[ i ], (Pipe) previous );
  if( result == -1 )
   continue;
  sorted.put( result, i );
  }
 return sorted.firstEntry().getValue();
 }
}

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

static Pipe resolvePrevious( Pipe pipe )
 {
 if( pipe instanceof Splice || pipe instanceof Operator )
  return pipe;
 Pipe[] pipes = pipe.getPrevious();
 if( pipes.length > 1 )
  throw new IllegalStateException( "cannot resolve SubAssemblies with multiple tails at this time" );
 for( Pipe previous : pipes )
  {
  if( previous instanceof Splice || previous instanceof Operator )
   return previous;
  return resolvePrevious( previous );
  }
 return pipe;
 }

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

/**
 * Is responsible for unwinding nested SubAssembly instances.
 *
 * @param tails of type Pipe[]
 * @return a Pipe[]
 */
public static Pipe[] unwind( Pipe... tails )
 {
 Set<Pipe> previous = new HashSet<Pipe>();
 for( Pipe pipe : tails )
  {
  if( pipe instanceof SubAssembly )
   Collections.addAll( previous, unwind( pipe.getPrevious() ) );
  else
   previous.add( pipe );
  }
 return previous.toArray( new Pipe[ previous.size() ] );
 }

代码示例来源:origin: cascading/lingual-core

private static List<String> getIncomingFieldNames( Pipe pipe )
 {
 if( pipe.getPrevious().length != 1 )
  return null;
 final Pipe previous = pipe.getPrevious()[ 0 ];
 if( !( previous instanceof Splice ) )
  return null;
 final Splice splice = (Splice) previous;
 if( splice.getDeclaredFields() == null )
  return null;
 return fieldNames( splice.getDeclaredFields() );
 }

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

private static void collectPipes( String name, Pipe[] tails, Set<Pipe> pipes )
 {
 for( Pipe tail : tails )
  {
  if( !( tail instanceof SubAssembly ) && tail.getName().equals( name ) )
   pipes.add( tail );
  collectPipes( name, SubAssembly.unwind( tail.getPrevious() ), pipes );
  }
 }

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

private void setParent( Set<Pipe> stopSet, Pipe[] tails )
 {
 if( tails == null )
  return;
 for( Pipe tail : tails )
  {
  if( stopSet.contains( tail ) )
   continue;
  tail.setParent( this );
  Pipe[] current;
  if( tail instanceof SubAssembly )
   current = ( (SubAssembly) tail ).previous;
  else
   current = tail.getPrevious();
  if( current == null && tail instanceof SubAssembly )
   LOG.warn( "previous pipes not set via setPrevious or constructor on: {}", tail );
  setParent( stopSet, current );
  }
 }

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

private static void collectNames( Pipe[] pipes, Set<String> names )
 {
 for( Pipe pipe : pipes )
  {
  if( pipe instanceof SubAssembly )
   names.addAll( asList( ( (SubAssembly) pipe ).getTailNames() ) );
  else
   names.add( pipe.getName() );
  collectNames( SubAssembly.unwind( pipe.getPrevious() ), names );
  }
 }

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

private static int collectPipes( Pipe pipe, int depth, Pipe... allPrevious )
 {
 depth++;
 for( Pipe previous : allPrevious )
  {
  if( pipe == previous )
   return depth;
  int result;
  if( previous instanceof SubAssembly )
   result = collectPipes( pipe, depth, SubAssembly.unwind( previous ) );
  else
   result = collectPipes( pipe, depth, previous.getPrevious() );
  if( result != -1 )
   return result;
  }
 return -1;
 }

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

for( Pipe pipe : SubAssembly.unwind( current.getPrevious() ) )
  makeGraph( pipe, sources, sinks );
if( SubAssembly.unwind( current.getPrevious() ).length == 0 )
for( Pipe previous : SubAssembly.unwind( current.getPrevious() ) )

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

  }

相关文章