Package cascading.lingual.tap

Examples of cascading.lingual.tap.TapSchema


  private final TapSchema rootMapSchema;

  LingualContext( SQLPlanner sqlPlanner, Flow flowDef, PlatformBroker platformBroker )
    {
    this.sqlPlanner = sqlPlanner;
    this.rootMapSchema = new TapSchema( new FlowQueryProvider(), new FieldTypeFactory(), platformBroker );

    initializeSchema( sqlPlanner, flowDef, rootMapSchema );
    }
View Full Code Here


  private void addTaps( SchemaDef parentSchemaDef, TapSchema parentTapSchema, Map<String, Tap> taps, Function<Tap, Fields> function )
    {
    for( String name : taps.keySet() )
      {
      TapSchema currentTapSchema = parentTapSchema;
      SchemaDef currentSchemaDef = parentSchemaDef;
      Tap tap = taps.get( name );
      String[] split = name.split( "\\." );

      for( int i = 0; i < split.length - 1; i++ )
        {
        currentTapSchema = createGetTapSchema( currentTapSchema, split[ i ] );
        currentSchemaDef = createGetSchemaDef( currentSchemaDef, split[ i ] );
        }

      name = split[ split.length - 1 ];

      Stereotype stereotype = new Stereotype( name, function.apply( tap ) );
      TableDef tableDef = new TableDef( currentSchemaDef, name, tap.getIdentifier(), stereotype );

      currentSchemaDef.addStereotype( stereotype );
      currentTapSchema.addTapTableFor( tableDef, getDefaultSchema() == null );
      }
    }
View Full Code Here

    }

  private TapSchema createGetTapSchema( TapSchema parentSchema, String schemaName )
    {
    if( parentSchema.getSubSchema( schemaName ) == null )
      parentSchema.addSchema( schemaName, new TapSchema( parentSchema, schemaName ) );

    return (TapSchema) parentSchema.getSubSchema( schemaName );
    }
View Full Code Here

    {
    Collection<SchemaDef> schemaDefs = currentSchemaDef.getChildSchemas();

    for( SchemaDef childSchemaDef : schemaDefs )
      {
      TapSchema childTapSchema = addTapSchema( connection, currentSchema, currentSchemaDef, childSchemaDef );

      addSchemas( connection, childTapSchema, childSchemaDef );
      }
    }
View Full Code Here

    }

  private TapSchema addTapSchema( LingualConnection connection, MapSchema currentMapSchema, SchemaDef currentSchemaDef, SchemaDef childSchemaDef )
    {
    SchemaCatalog schemeCatalog = connection.getPlatformBroker().getSchemeCatalog();
    TapSchema childTapSchema = (TapSchema) currentMapSchema.getSubSchema( childSchemaDef.getName() );

    if( childTapSchema == null )
      {
      childTapSchema = new TapSchema( currentMapSchema, connection, childSchemaDef );
      currentMapSchema.addSchema( childSchemaDef.getName(), childTapSchema );

      String childSchemaDescription;

      if( currentSchemaDef.getIdentifier() != null )
        childSchemaDescription = String.format( "'%s' ( %s )", childSchemaDef.getName(), currentSchemaDef.getIdentifier() );
      else
        childSchemaDescription = String.format( "'%s'", childSchemaDef.getName() );

      String name = currentSchemaDef.getName() == null ? "root" : currentSchemaDef.getName();

      LOG.info( "added schema: {}, to: '{}'", childSchemaDescription, name );
      }

    childTapSchema.addTapTablesFor( schemeCatalog, childSchemaDef );

    return childTapSchema;
    }
View Full Code Here

    }

  public void addTapToConnection( LingualConnection connection, String schemaName, Tap tap, String tableAlias )
    {
    MapSchema rootSchema = (MapSchema) connection.getRootSchema();
    TapSchema subSchema = (TapSchema) rootSchema.getSubSchema( schemaName );
    SchemaDef schemaDef = schemaCatalog.getSchemaDef( schemaName );

    if( tableAlias != null && schemaDef.getTable( tableAlias ) != null )
      {
      TapTable table = (TapTable) subSchema.getTable( tableAlias, Object.class );

      if( table.getName().equals( tableAlias ) )
        LOG.debug( "table exists: {}, discarding", tableAlias );
      else
        LOG.debug( "replacing alias: {}, for: {} ", tableAlias, table.getName() );
      }

    String currentTableName = createTableDefFor( schemaName, null, tap.getIdentifier(), tap.getSinkFields(), null, null );
    TableDef tableDef = schemaDef.getTable( currentTableName );
    TapTable tapTable = subSchema.addTapTableFor( tableDef ); // add table named after flow

    LOG.debug( "adding table:{}", tableDef.getName() );

    if( tableAlias != null && !tapTable.getName().equals( tableAlias ) )
      {
      LOG.debug( "adding alias: {}, for table: {}", tableAlias, tapTable.getName() );
      subSchema.addTable( tableAlias, tapTable ); // add names after given tableName (LAST)
      }
    }
View Full Code Here

TOP

Related Classes of cascading.lingual.tap.TapSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.