!636 !modern !* ctr main { psvm { new SnippetDB db; db.importMySQLDump(gunzipToText("#1000673")); //db.printStats(); print(); db.printFullSnippet("#636"); } static class Table { List> data; List fields; *(List> *data, List *fields) {} Map rowAsMap(L row) { new Map map; for (int i = 0; i < row.size(); i++) map.put(fields.get(i), row.get(i)); return map; } } static class SnippetDB { Map tables; Map tableFields; void importMySQLDump(String dump) { print("Importing " + dump.length() + " chars."); Class importer = hotwire("#1000660"); set(importer, "in", dump); callMain(importer); tables = (Map) get(importer, "tables"); tableFields = (Map) get(importer, "tableFields"); print("Total rows imported: " + get(importer, "totalRows")); } void printStats() { print(structure(tables.keySet())); print(structure(tableFields)); } Table table(String name) { return new Table(tables.get(name), tableFields.get(name)); } Map getFullSnippet(String id) { id = "" + parseSnippetID(id); Table t = table("snippets_public"); for (List row : t.data) { Map map = t.rowAsMap(row); String _id = map.get("sn_id"); if (id.equals(_id)) return map; } return null; } void printFullSnippet(S id) { print(structure(getFullSnippet(id))); } } }