public static void writeSQLPlan( Properties properties, String name, VolcanoPlanner planner ) { String path = getSQLPlanPath( properties, name ); if( path == null ) return; PrintWriter writer; try { File file = new File( path ).getAbsoluteFile(); File parentDir = file.getParentFile(); parentDir.mkdirs(); writer = new PrintWriter( file ); } catch( IOException exception ) { throw new RuntimeException( "unable to write sql plan to: " + path, exception ); } planner.dump( writer ); writer.close(); }
Optiq.writeSQLPlan( properties, flowFactory.getName(), getVolcanoPlanner() );
@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 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 ); }