diff --git a/Model/src/main/java/org/gusdb/wdk/model/dbms/TableUtilization.java b/Model/src/main/java/org/gusdb/wdk/model/dbms/TableUtilization.java index 272e5bbab..40c9dc452 100644 --- a/Model/src/main/java/org/gusdb/wdk/model/dbms/TableUtilization.java +++ b/Model/src/main/java/org/gusdb/wdk/model/dbms/TableUtilization.java @@ -43,7 +43,7 @@ public static void main(String[] args) throws Exception { // initialize data structures outsize the try so we can close the model before dumping output Map> queryToTablesMap = new LinkedHashMap<>(); // ordered query map (query -> tableName[]) Map queryToJoinedStringMap = new LinkedHashMap<>(); // another ordered query map (query -> join(tableName[]) - Map> joinedStringToQueriesMap = new LinkedHashMap<>(); + //Map> joinedStringToQueriesMap = new LinkedHashMap<>(); // build a model to get all queries try (WdkModel model = WdkModel.construct(projectId, GusHome.getGusHome())) { @@ -69,7 +69,7 @@ public static void main(String[] args) throws Exception { queryToJoinedStringMap.put(query.getFullName(), String.join("|", queryTables)); } - System.out.println("Processed " + numSqlQueries + " SQL queries in model for " + projectId + "\n)"); + System.out.println("\nProcessed " + numSqlQueries + " SQL queries in model for " + projectId + "\n)"); } // dump out the map from queryName -> tableName[] @@ -77,11 +77,19 @@ public static void main(String[] args) throws Exception { // make a list of unique table combinations; index will be the "ID" for that combo List joinedStringList = new ArrayList<>(new HashSet<>(queryToJoinedStringMap.values())); + joinedStringList.sort((a,b) -> a.compareTo(b)); // dump unique table combinations System.out.println("Unique table combinations by index:"); for (int i = 0; i < joinedStringList.size(); i++) { - System.out.println(i + " : " + joinedStringList.get(i)); + // find how many queries use each combination + int count = 0; + for (String joinedTableString : queryToJoinedStringMap.values()) { + if (joinedStringList.get(i).equals(joinedTableString)) { + count++; + } + } + System.out.println(i + " (" + count + "): " + joinedStringList.get(i)); } // desired output: