private String[] makeNames( Pipe[] pipes ) { String[] names = new String[ pipes.length ]; for( int i = 0; i < pipes.length; i++ ) names[ i ] = pipes[ i ].getName(); return names; }
@Override public String toString() { return getClass().getSimpleName() + "(" + getName() + ")"; }
public synchronized Map<String, Integer> getPipePos() { if( pipePos != null ) return pipePos; pipePos = new HashMap<String, Integer>(); int pos = 0; for( Object pipe : pipes ) pipePos.put( ( (Pipe) pipe ).getName(), pos++ ); return pipePos; }
private void addPipe( Pipe pipe ) { if( pipe.getName() == null ) throw new IllegalArgumentException( "each input pipe must have a name" ); pipes.add( pipe ); // allow same pipe }
@Override public int hashCode() { return 31 * getName().hashCode() + getClass().hashCode(); }
private static Pipe find( String name, Iterator<FlowElement> iterator ) { while( iterator.hasNext() ) { FlowElement flowElement = iterator.next(); if( flowElement instanceof Pipe && ( (Pipe) flowElement ).getName().equals( name ) ) return (Pipe) flowElement; } return null; }
private String makeName( CascadingRelNode node, Pipe pipe ) { String name = ""; if( node != null ) name = node.getClass().getSimpleName() + ":"; name += pipe.getClass().getSimpleName() + "[" + pipe.getName() + "]"; return name; }
protected void printInternal( StringBuffer buffer, Scope scope ) { buffer.append( getClass().getSimpleName() ).append( "('" ).append( getName() ).append( "')" ); } }
private String makeName( Pipe[] pipes ) { String[] names = new String[ pipes.length ]; for( int i = 0; i < pipes.length; i++ ) names[ i ] = pipes[ i ].getName(); String name = Util.join( names, "+" ); if( name.length() > 32 ) name = name.substring( 0, 32 ); return name; } }
/** * Method addTrap adds a new trap {@link Tap} named after the given {@link Pipe} for use in the resulting {@link Flow}. * * @param pipe of Pipe * @param trap of Tap * @return FlowDef */ public FlowDef addTrap( Pipe pipe, Tap trap ) { addTrap( pipe.getName(), trap ); return this; }
@Override public String format( String trace ) { return "[" + Util.truncate( pipe.getName(), 25 ) + "][" + trace + "]"; } } );
/** * Method addSink adds a new sink {@link Tap} named after the given {@link Pipe} for use in the resulting {@link Flow}. * * @param tail of Pipe * @param sink of Tap * @return FlowDef */ public FlowDef addSink( Pipe tail, Tap sink ) { addSink( tail.getName(), sink ); return this; }
public Map<String, Pipe> getTailsByName(){ Map<String, Pipe> tails = Maps.newHashMap(); for (Pipe pipe : getTails()) { tails.put(pipe.getName(), pipe); } return tails; }
private List<Fields> getOrderedResolvedFields( Set<Scope> incomingScopes ) { Map<String, Scope> scopesMap = new HashMap<String, Scope>(); for( Scope incomingScope : incomingScopes ) scopesMap.put( incomingScope.getName(), incomingScope ); List<Fields> appendableFields = new ArrayList<Fields>(); for( Pipe pipe : pipes ) appendableFields.add( scopesMap.get( pipe.getName() ).getIncomingSpliceFields() ); return appendableFields; }
@Override public boolean containsPipeNamed( String pipeName ) { Set<FlowElement> vertices = getElementGraph().vertexSet(); for( FlowElement vertex : vertices ) { if( vertex instanceof Pipe && ( (Pipe) vertex ).getName().equals( pipeName ) ) return true; } return false; }
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 ); } }
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 ); } }
@Test public void testName() { Pipe count = new Pipe( "count" ); Pipe pipe = new GroupBy( count, new Fields( 1 ) ); pipe = new Every( pipe, new Fields( 1 ), new Count(), new Fields( 0, 1 ) ); assertEquals( "not equal: count.getName()", "count", count.getName() ); assertEquals( "not equal: pipe.getName()", "count", pipe.getName() ); pipe = new Each( count, new Fields( 1 ), new RegexSplitter( Fields.size( 2 ) ) ); assertEquals( "not equal: pipe.getName()", "count", pipe.getName() ); }
@Test public void testName() { Pipe count = new Pipe( "count" ); Pipe pipe = new GroupBy( count, new Fields( 1 ) ); pipe = new Every( pipe, new Fields( 1 ), new Count(), new Fields( 0, 1 ) ); assertEquals( "not equal: count.getName()", "count", count.getName() ); assertEquals( "not equal: pipe.getName()", "count", pipe.getName() ); pipe = new Each( count, new Fields( 1 ), new RegexSplitter( Fields.size( 2 ) ) ); assertEquals( "not equal: pipe.getName()", "count", pipe.getName() ); }