當前位置: 首頁>>代碼示例>>Java>>正文


Java DDLBuilder類代碼示例

本文整理匯總了Java中org.apache.tajo.catalog.DDLBuilder的典型用法代碼示例。如果您正苦於以下問題:Java DDLBuilder類的具體用法?Java DDLBuilder怎麽用?Java DDLBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DDLBuilder類屬於org.apache.tajo.catalog包,在下文中一共展示了DDLBuilder類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dumpDatabase

import org.apache.tajo.catalog.DDLBuilder; //導入依賴的package包/類
private static void dumpDatabase(TajoClient client, String databaseName, PrintWriter writer)
    throws SQLException, ServiceException {
  writer.write("\n");
  writer.write("--\n");
  writer.write(String.format("-- Database name: %s%n", CatalogUtil.denormalizeIdentifier(databaseName)));
  writer.write("--\n");
  writer.write("\n");
  writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", CatalogUtil.denormalizeIdentifier(databaseName)));
  writer.write("\n\n");

  // returned list is immutable.
  List<String> tableNames = TUtil.newList(client.getTableList(databaseName));
  Collections.sort(tableNames);
  for (String tableName : tableNames) {
    try {
      TableDesc table = client.getTableDesc(CatalogUtil.buildFQName(databaseName, tableName));
      if (table.isExternal()) {
        writer.write(DDLBuilder.buildDDLForExternalTable(table));
      } else {
        writer.write(DDLBuilder.buildDDLForBaseTable(table));
      }
      writer.write("\n\n");
    } catch (Exception e) {
      // dump for each table can throw any exception. We need to skip the exception case.
      // here, the error message prints out via stderr.
      System.err.println("ERROR:" + tableName + "," + e.getMessage());
    }
  }
}
 
開發者ID:gruter,項目名稱:tajo-cdh,代碼行數:30,代碼來源:TajoDump.java


注:本文中的org.apache.tajo.catalog.DDLBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。