1 | static class SnippetDB { |
2 | static List<S> fields; |
3 | static List<List<S>> rows; |
4 | |
5 | *() {} |
6 | |
7 | *(S snippetIDOfGzippedMysqlDump) { |
8 | importMySQLDump(gunzipToText(snippetIDOfGzippedMysqlDump)); |
9 | } |
10 | |
11 | void importMySQLDump(String dump) { |
12 | System.out.println("Importing " + dump.length() + " chars."); |
13 | Class importer = hotwire("#1000660"); |
14 | set(importer, "in", dump); |
15 | callMain(importer); |
16 | Map<String, List> tables = (Map) get(importer, "tables"); |
17 | Map<String, List> tableFields = (Map) get(importer, "tableFields"); |
18 | fields = tableFields.get("snippets_public"); |
19 | rows = tables.get("snippets_public"); |
20 | } |
21 | |
22 | S getField(List<S> row, S field) { |
23 | int i = fields.indexOf(field); |
24 | return i < 0 ? null : row.get(i); |
25 | } |
26 | |
27 | List<List<S>> rowsOrderedBy(S field) { |
28 | final int i = fields.indexOf(field); |
29 | List<List<S>> list = new ArrayList<List<S>>(rows); |
30 | sort(list, new Comparator<List<S>>() { |
31 | public int compare(List<S> rowA, List<S> rowB) { |
32 | S a = rowA.get(i), b = rowB.get(i); |
33 | return a.compareTo(b); |
34 | } |
35 | }); |
36 | return list; |
37 | } |
38 | |
39 | public void finalize() { |
40 | System.err.println("Note: SnippetDB released from memory."); |
41 | } |
42 | } |
Began life as a copy of #1000678
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000989 |
Snippet name: | class SnippetDB (snapshot of snippet DB in memory) |
Eternal ID of this version: | #1000989/1 |
Text MD5: | 8cef8825fd15e40f67288d860a5f4d60 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-09-15 18:14:59 |
Source code size: | 1246 bytes / 42 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 638 / 2091 |
Referenced in: | [show references] |