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

33
LINES

< > BotCompany Repo | #1028945 // Cache All Snippets With Text [cached in upper case for faster searching]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (2638L/14K).

!7

cprint CacheAllSnippets {
  transient SS texts; // snippet ID to uppercase text
  transient SS titles; // snipppet ID to title
  
  start-thread {
    time "Loaded all snippet texts & titles" {
      new SS texts;
      new SS titles;
      for (virtual CSnippet sn : dm_allSnippets()) {
        S snippetID = (S) rcall snippetID(sn);
        texts.put(snippetID, upper((S) rcall text(sn)));
        titles.put(snippetID, getString title(sn));
      }
      setFields(+texts, +titles);
    }
    print("Loaded " + nSnippets(texts) + ", " + nChars(totalStringLength(values(texts))));
  }
  
  // API
  
  // id to uppercase text
  SS getData() {
    sleepWhile(() -> texts == null, max := 10.0);
    ret texts;
  }
  
  SS getTitles() {
    sleepWhile(() -> titles == null, max := 10.0);
    ret titles;
  }
}

Author comment

Began life as a copy of #1028144

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028945
Snippet name: Cache All Snippets With Text [cached in upper case for faster searching]
Eternal ID of this version: #1028945/8
Text MD5: 7da1e7d866cb40200e82121923a1baa1
Transpilation MD5: b7d437489073f3e6b6c2006964c40000
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-12 20:20:41
Source code size: 846 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 266 / 5013
Version history: 7 change(s)
Referenced in: #1028948 - Instant Full-Text Snippet Search
#1028972 - Snippets Word Index [OK]
#1028975 - Instant Full-Text Snippet Search v2 [using word index, seems OK]
#1029009 - Instant Full-Text Snippet Search v3 [using double word index, skips texts > 100k chars]
#1029014 - Instant Full-Text Snippet Search v4 [using deep double word index, OK]
#1029017 - Instant Full-Text Snippet Search v4.1 [using deep double word index, dev.]
#1029035 - Instant Full-Text Snippet Search v5 [using deep word index]
#1029044 - Instant Full-Text Snippet Search v6 [using deep word pair index]
#1029090 - Instant Full-Text Snippet Search v7 [using deep chunked bit-set word index, dev.]