Source:
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"); List<String> tableNames = TUtil.newList(client.getTableList(databaseName)); Collections.sort(tableNames); for (String tableName : tableNames) { try { String fqName = CatalogUtil.buildFQName(databaseName, tableName); TableDesc table = client.getTableDesc(fqName); if (table.getMeta().getStoreType().equalsIgnoreCase("SYSTEM")) { continue; } if (table.isExternal()) { writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); } if (table.hasPartition()) { writer.write("\n\n"); writer.write("--\n"); writer.write(String.format("-- Table Partitions: %s%n", tableName)); writer.write("--\n"); List<PartitionDescProto> partitionProtos = client.getPartitionsOfTable(fqName); for (PartitionDescProto eachPartitionProto : partitionProtos) { writer.write(DDLBuilder.buildDDLForAddPartition(table, eachPartitionProto)); } writer.write("\n\n"); } if (client.hasIndexes(tableName)) { List<CatalogProtos.IndexDescProto> indexeProtos = client.getIndexes(tableName); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto))); } } writer.write("\n\n"); } catch (Exception e) { e.printStackTrace(); System.err.println("ERROR:" + tableName + "," + e.getMessage()); } } }

Target:
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"); List<String> tableNames = TUtil.newList(client.getTableList(databaseName)); Collections.sort(tableNames); for (String tableName : tableNames) { try { String fqName = CatalogUtil.buildFQName(databaseName, tableName); TableDesc table = client.getTableDesc(fqName); if (table.getMeta().getStoreType().equalsIgnoreCase("SYSTEM")) { continue; } if (table.isExternal()) { writer.write(DDLBuilder.buildDDLForExternalTable(table)); } else { writer.write(DDLBuilder.buildDDLForBaseTable(table)); } if (table.hasPartition()) { writer.write("\n\n"); writer.write("--\n"); writer.write(String.format("-- Table Partitions: %s%n", tableName)); writer.write("--\n"); List<PartitionDescProto> partitionProtos = client.getPartitionsOfTable(fqName); for (PartitionDescProto eachPartitionProto : partitionProtos) { writer.write(DDLBuilder.buildDDLForAddPartition(table, eachPartitionProto)); } writer.write("\n\n"); } if (client.hasIndexes(tableName)) { List<CatalogProtos.IndexDescProto> indexeProtos = client.getIndexes(tableName); for (CatalogProtos.IndexDescProto eachIndexProto : indexeProtos) { writer.write("\n\n"); writer.write(DDLBuilder.buildDDLForIndex(new IndexDesc(eachIndexProto))); } } writer.write("\n\n"); } catch (Exception e) { System.err.println("ERROR:" + tableName + "," + e.getMessage()); } } }