public TableInfo getTableInfo ( String tblName , Transaction tx ) { // Optimization: TableInfo resultTi = tiMap . get ( tblName ) ; if ( resultTi != null ) return resultTi ; RecordFile tcatfile = tcatInfo . open ( tx , true ) ; tcatfile . beforeFirst ( ) ; boolean found = false ; while ( tcatfile . next ( ) ) { String t = ( String ) tcatfile . getVal ( TCAT_TBLNAME ) . asJavaVal ( ) ; if ( t . equals ( tblName ) ) { found = true ; break ; } } tcatfile . close ( ) ; // return null if table is undefined if ( ! found ) return null ; RecordFile fcatfile = fcatInfo . open ( tx , true ) ; fcatfile . beforeFirst ( ) ; Schema sch = new Schema ( ) ; while ( fcatfile . next ( ) ) if ( ( ( String ) fcatfile . getVal ( FCAT_TBLNAME ) . asJavaVal ( ) ) . equals ( tblName ) ) { String fldname = ( String ) fcatfile . getVal ( FCAT_FLDNAME ) . asJavaVal ( ) ; int fldtype = ( Integer ) fcatfile . getVal ( FCAT_TYPE ) . asJavaVal ( ) ; int fldarg = ( Integer ) fcatfile . getVal ( FCAT_TYPEARG ) . asJavaVal ( ) ; sch . addField ( fldname , Type . newInstance ( fldtype , fldarg ) ) ; } fcatfile . close ( ) ; // Optimization: resultTi = new TableInfo ( tblName , sch ) ; tiMap . put ( tblName , resultTi ) ; return resultTi ; }
Retrieves the metadata for the specified table out of the catalog .