public Branch visitChild( Stack stack ) { String pipeName = createUniqueName(); Fields fields = RelUtil.createTypedFieldsFor( this, false ); return new Branch( stack.heads, pipeName, fields, tuples ); } }
@Override public Enumerator enumerator() { PlatformBroker platformBroker = getPlatformBroker(); Optiq.writeSQLPlan( platformBroker.getProperties(), createUniqueName(), getVolcanoPlanner() ); Branch branch = getBranch(); TupleEntryCollector collector = getTupleEntryCollector( platformBroker, branch ); long rowCount; try { rowCount = 0; for( List<RexLiteral> values : branch.tuples ) { collector.add( createTupleFrom( values ) ); rowCount++; } } finally { if( platformBroker.getCollectorCache() == null ) collector.close(); } LOG.debug( "inserted {} rows", rowCount ); return new Linq4j().singletonEnumerable( rowCount ).enumerator(); }
public LingualFlowFactory getFlowFactory( Branch branch ) { LingualFlowFactory lingualFlowFactory = new LingualFlowFactory( this, nextConnection.get(), createUniqueName(), branch.current ); for( Ref head : branch.heads.keySet() ) { Stereotype<Protocol, Format> stereotypeFor; TableDef tableDef = head.tableDef; if( tableDef == null ) { stereotypeFor = catalogManager.findStereotypeFor( head.fields ); // do not use head name // local insert case if ( stereotypeFor == null ) stereotypeFor = branch.tailTableDef.getStereotype(); } else stereotypeFor = tableDef.getStereotype(); lingualFlowFactory.setSourceStereotype( head.name, stereotypeFor ); if( tableDef != null ) addHandlers( lingualFlowFactory, tableDef.getParentSchema() ); } if( branch.tailTableDef != null ) lingualFlowFactory.setSinkStereotype( branch.current.getName(), branch.tailTableDef.getStereotype() ); else lingualFlowFactory.setSinkStereotype( branch.current.getName(), catalogManager.getStereoTypeFor( Fields.UNKNOWN ) ); if( branch.tailTableDef != null ) addHandlers( lingualFlowFactory, branch.tailTableDef.getParentSchema() ); else addHandlers( lingualFlowFactory, getSchemeCatalog().getRootSchemaDef() ); return lingualFlowFactory; }
public Enumerator enumerator() { PlatformBroker platformBroker = getPlatformBroker(); Properties properties = platformBroker.getProperties(); Optiq.writeSQLPlan( properties, Misc.createUniqueName(), getVolcanoPlanner() ); FlowProcess flowProcess = platformBroker.getFlowProcess(); SchemaCatalogManager schemaCatalog = platformBroker.getCatalogManager(); Tap tap = schemaCatalog.createTapFor( getTableDef(), SinkMode.KEEP ); int size = tap.getSourceFields().size(); Type[] types = new Type[ size ]; for( int i = 0; i < size; i++ ) types[ i ] = getPhysType().fieldClass( i ); int maxRows = getMaxRows( properties ); if( size == 1 ) return new TapObjectEnumerator( maxRows, types, flowProcess, tap ); else return new TapArrayEnumerator( maxRows, types, flowProcess, tap ); }