Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

45
LINES

< > BotCompany Repo | #1000678 // Searching directly in a MySQL dump

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (2083L/16K/48K).

1  
!636
2  
!modern
3  
4  
main {
5  
  static Map<String, List> tables;
6  
  static Map<String, List> tableFields;
7  
  
8  
  psvm {
9  
    importMySQLDump(gunzipToText("#1000673"));
10  
    printStats();
11  
    
12  
    // Try a search!
13  
    searchSnippet("hotwire");
14  
  }
15  
  
16  
  static void importMySQLDump(String dump) {
17  
    System.out.println("Importing " + dump.length() + " chars.");
18  
    Class importer = hotwire("#1000660");
19  
    set(importer, "in", dump);
20  
    callMain(importer);
21  
    tables = (Map) get(importer, "tables");
22  
    tableFields = (Map) get(importer, "tableFields");
23  
    print("Total rows imported: " + get(importer, "totalRows"));
24  
  }
25  
  
26  
  static void printStats() {
27  
    print(structure(tables.keySet()));
28  
    print(structure(tableFields));
29  
  }
30  
  
31  
  static void searchSnippet(String pat) {
32  
    // preparation
33  
    List<List> table = tables.get("snippets_public");
34  
    List fields = tableFields.get("snippets_public");
35  
    int iID = fields.indexOf("sn_id");
36  
    int iTitle = fields.indexOf("sn_title");
37  
    
38  
    // search
39  
    System.out.println("\nResult of search for " + quote(pat) + ":\n");
40  
    for (List row : table) {
41  
      if (indexOfIgnoreCase(row.get(iTitle), pat) >= 0)
42  
        print("#" + row.get(iID) + " - " + row.get(iTitle));
43  
    }
44  
  }
45  
}

Author comment

Began life as a copy of #1000667

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000678
Snippet name: Searching directly in a MySQL dump
Eternal ID of this version: #1000678/1
Text MD5: c0399eb8933ded3331a4b39450da80a9
Transpilation MD5: 8166f368ffd144365089e07dee27135a
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-14 02:11:05
Source code size: 1269 bytes / 45 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 673 / 718
Referenced in: [show references]