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

35
LINES

< > BotCompany Repo | #1029084 // Snippets Deep BitSet Word Index

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

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

!7

cprint SnippetsDeepBitSetWordIndex {
  transient DeepBitSetWordIndex<S> wordIndex; // string = snippet ID
  switchable S regexp = "\\w+";

  start-thread {
    dm_reloadOnFieldChange regexp();
    time "Make bit-set word index" {
      print("Making index");
      new DeepBitSetWordIndex<S> wordIndex;
      wordIndex.regexp = regexp;
      for (virtual CSnippet sn : dm_allSnippets()) {
        S snippetID = (S) rcall snippetID(sn);
        S text = cast rcall text(sn);
        wordIndex.add(snippetID, text);
      }
      wordIndex.doneAdding();
      setField(+wordIndex);
    }
    infoBox("Indexed " + nWords(wordIndex.numWords()));
  }
  
  // API
  
  Iterable<S> snippetPreSearch(S query, O... _) {
    long nanos = nanoTime();
    Iterable<S> l;
    //time "lookup" {
      l = wordIndex == null ? null : wordIndex.preSearch(query, _);
    //}
    //print((nanoTime()-nanos) + " nanos in pre");
    ret l;
  }
}

Author comment

Began life as a copy of #1029073

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: #1029084
Snippet name: Snippets Deep BitSet Word Index
Eternal ID of this version: #1029084/1
Text MD5: 5460122caa1f7daaae5f4ab1898cb220
Transpilation MD5: 8aba4657a58348fb27e7ea7db1a73760
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-19 02:20:41
Source code size: 964 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 188 / 304
Referenced in: [show references]