integration/presto/src/main/java/org/apache/carbondata/presto/impl/CarbonTableReader.java
/**
   * Read the metadata of the given table and cache it in this.carbonCache (CarbonTableReader cache).
   *
   * @param table name of the given table.
   * @return the CarbonTable instance which contains all the needed metadata for a table.
   */
Read the metadata of the given table and cache it in this.carbonCache (CarbonTableReader cache).
@param table name of the given table.
@return the CarbonTable instance which contains all the needed metadata for a table.
Read the metadata of the given table and cache it in this . carbonCache ( CarbonTableReader cache ) . @param table name of the given table . @return the CarbonTable instance which contains all the needed metadata for a table .
private CarbonTable parseCarbonMetadata(SchemaTableName table) {
    CarbonTable result = null;
    try {
      CarbonTableCacheModel cache = carbonCache.get().get(table);
      if (cache == null) {
        cache = new CarbonTableCacheModel();
      }
      if (cache.isValid()) return cache.carbonTable;
      cache.carbonTableIdentifier =
              new CarbonTableIdentifier(table.getSchemaName(), table.getTableName(),
                      UUID.randomUUID().toString());
      String storePath = config.getStorePath();
      String tablePath = storePath + "/" + cache.carbonTableIdentifier.getDatabaseName() + "/"
          + cache.carbonTableIdentifier.getTableName();
      AbsoluteTableIdentifier absoluteTableIdentifier =
          AbsoluteTableIdentifier.from(tablePath, cache.carbonTableIdentifier);
      cache.carbonTablePath =
          PathFactory.getInstance().getCarbonTablePath(absoluteTableIdentifier, null);
      carbonCache.get().put(table, cache);
      ThriftReader.TBaseCreator createTBase = new ThriftReader.TBaseCreator() {
        public TBase create() {
          return new org.apache.carbondata.format.TableInfo();
        }
      };
      ThriftReader thriftReader =
              new ThriftReader(cache.carbonTablePath.getSchemaFilePath(), createTBase);
      thriftReader.open();
      org.apache.carbondata.format.TableInfo tableInfo =
              (org.apache.carbondata.format.TableInfo) thriftReader.read();
      thriftReader.close();
      SchemaConverter schemaConverter = new ThriftWrapperSchemaConverterImpl();
      TableInfo wrapperTableInfo = schemaConverter
          .fromExternalToWrapperTableInfo(tableInfo, table.getSchemaName(), table.getTableName(),
              tablePath);
      CarbonMetadata.getInstance().loadTableMetadata(wrapperTableInfo);
      cache.tableInfo = wrapperTableInfo;
      cache.carbonTable = CarbonMetadata.getInstance()
              .getCarbonTable(cache.carbonTableIdentifier.getTableUniqueName());
      result = cache.carbonTable;
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
    return result;
  }
private CarbonTable parseCarbonMetadata ( SchemaTableName table ) { CarbonTable result = null ; try { CarbonTableCacheModel cache = carbonCache . get ( ) . get ( table ) ; if ( cache == null ) { cache = new CarbonTableCacheModel ( ) ; } if ( cache . isValid ( ) ) return cache . carbonTable ; cache . carbonTableIdentifier = new CarbonTableIdentifier ( table . getSchemaName ( ) , table . getTableName ( ) , UUID . randomUUID ( ) . toString ( ) ) ; String storePath = config . getStorePath ( ) ; String tablePath = storePath + "/" + cache . carbonTableIdentifier . getDatabaseName ( ) + "/" + cache . carbonTableIdentifier . getTableName ( ) ; AbsoluteTableIdentifier absoluteTableIdentifier = AbsoluteTableIdentifier . from ( tablePath , cache . carbonTableIdentifier ) ; cache . carbonTablePath = PathFactory . getInstance ( ) . getCarbonTablePath ( absoluteTableIdentifier , null ) ; carbonCache . get ( ) . put ( table , cache ) ; ThriftReader . TBaseCreator createTBase = new ThriftReader . TBaseCreator ( ) { public TBase create ( ) { return new org . apache . carbondata . format . TableInfo ( ) ; } } ; ThriftReader thriftReader = new ThriftReader ( cache . carbonTablePath . getSchemaFilePath ( ) , createTBase ) ; thriftReader . open ( ) ; org . apache . carbondata . format . TableInfo tableInfo = ( org . apache . carbondata . format . TableInfo ) thriftReader . read ( ) ; thriftReader . close ( ) ; SchemaConverter schemaConverter = new ThriftWrapperSchemaConverterImpl ( ) ; TableInfo wrapperTableInfo = schemaConverter . fromExternalToWrapperTableInfo ( tableInfo , table . getSchemaName ( ) , table . getTableName ( ) , tablePath ) ; CarbonMetadata . getInstance ( ) . loadTableMetadata ( wrapperTableInfo ) ; cache . tableInfo = wrapperTableInfo ; cache . carbonTable = CarbonMetadata . getInstance ( ) . getCarbonTable ( cache . carbonTableIdentifier . getTableUniqueName ( ) ) ; result = cache . carbonTable ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } return result ; }
Read the metadata of the given table and cache it in this.carbonCache (CarbonTableReader cache).
Read the metadata of the given table and cache it in this . carbonCache ( CarbonTableReader cache ) .
// If table is not previously cached, then: // Step 1: get store path of the table and cache it. // create table identifier. the table id is randomly generated. // get the store path of the table. // cache the table //Step 2: read the metadata (tableInfo) of the table. // TBase is used to read and write thrift objects. // TableInfo is a kind of TBase used to read and write table information. // TableInfo is generated by thrift, see schema.thrift under format/src/main/thrift for details. // Step 3: convert format level TableInfo to code level TableInfo // wrapperTableInfo is the code level information of a table in carbondata core, different from the Thrift TableInfo. // Step 4: Load metadata info into CarbonMetadata