@Override public long getNumChildTaps() { return getTaps().length; }
@Override public Iterator<Child> getChildTaps() { return Arrays.asList( getTaps() ).iterator(); }
@Override public boolean createResource( Config conf ) throws IOException { for( Tap tap : getTaps() ) { if( !tap.createResource( conf ) ) return false; } return true; }
@Override public boolean commitResource( Config conf ) throws IOException { for( Tap tap : getTaps() ) { if( !tap.commitResource( conf ) ) return false; } return true; }
@Override public TupleEntryCollector openForWrite( FlowProcess<? extends Config> flowProcess, Output output ) throws IOException { return new MultiSinkCollector( flowProcess, getTaps() ); }
@Override public boolean deleteResource( Config conf ) throws IOException { for( Tap tap : getTaps() ) { if( !tap.deleteResource( conf ) ) return false; } return true; }
@Override public boolean resourceExists( Config conf ) throws IOException { for( Tap tap : getTaps() ) { if( !tap.resourceExists( conf ) ) return false; } return true; }
@Override public void presentSinkFields( FlowProcess<? extends Config> flowProcess, Fields fields ) { for( Tap child : getTaps() ) child.presentSinkFields( flowProcess, fields ); }
@Override public boolean rollbackResource( Config conf ) throws IOException { for( Tap tap : getTaps() ) { if( !tap.rollbackResource( conf ) ) return false; } return true; }
private void bridge( FlowProcess flowProcess, Object conf ) { childConfigs = new ArrayList<>(); for( int i = 0; i < getTaps().length; i++ ) { Tap tap = getTaps()[ i ]; Object newConfig = flowProcess.copyConfig( conf ); tap.sinkConfInit( flowProcess, newConfig ); childConfigs.add( flowProcess.diffConfigIntoMap( conf, newConfig ) ); } }
@Override public Scheme getScheme() { if( super.getScheme() != null ) return super.getScheme(); Set<Fields> fields = new HashSet<Fields>(); for( Tap child : getTaps() ) fields.add( child.getSinkFields() ); // if all schemes have the same sink fields, the just use the scheme if( fields.size() == 1 ) { setScheme( getTaps()[ 0 ].getScheme() ); return super.getScheme(); } Fields allFields = Fields.merge( fields.toArray( new Fields[ fields.size() ] ) ); setScheme( new NullScheme( allFields, allFields ) ); return super.getScheme(); }