Skip to content

Commit

Permalink
Adjust output
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrdoherty committed Oct 25, 2023
1 parent 16f6bfc commit a393b6c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Model/src/main/java/org/gusdb/wdk/model/dbms/TableUtilization.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, List<String>> queryToTablesMap = new LinkedHashMap<>(); // ordered query map (query -> tableName[])
Map<String, String> queryToJoinedStringMap = new LinkedHashMap<>(); // another ordered query map (query -> join(tableName[])
Map<String, List<String>> joinedStringToQueriesMap = new LinkedHashMap<>();
//Map<String, List<String>> joinedStringToQueriesMap = new LinkedHashMap<>();

// build a model to get all queries
try (WdkModel model = WdkModel.construct(projectId, GusHome.getGusHome())) {
Expand All @@ -69,19 +69,27 @@ 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[]
System.out.println("Map from query name to tables it uses: " + new JSONObject(queryToTablesMap).toString(2));

// make a list of unique table combinations; index will be the "ID" for that combo
List<String> 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:
Expand Down

0 comments on commit a393b6c

Please sign in to comment.