Uses 911K of libraries. Click here for Pure Java version (5684L/29K).
1 | !7 |
2 | |
3 | cprint SnippetsBitSetWordIndex { |
4 | transient WordIndexWithBitSets<S> wordIndex; // string = snippet ID |
5 | switchable S regexp = "\\w+"; |
6 | |
7 | start-thread { |
8 | dm_reloadOnFieldChange regexp(); |
9 | time "Make bit-set word index" { |
10 | print("Making index"); |
11 | new WordIndexWithBitSets<S> wordIndex; |
12 | wordIndex.regexp = regexp; |
13 | for (virtual CSnippet sn : dm_allSnippets()) { |
14 | S snippetID = (S) rcall snippetID(sn); |
15 | S text = cast rcall text(sn); |
16 | wordIndex.add(snippetID, text); |
17 | } |
18 | wordIndex.doneAdding(); |
19 | setField(+wordIndex); |
20 | } |
21 | infoBox("Indexed " + nWords(wordIndex.numWords())); |
22 | } |
23 | |
24 | // API |
25 | |
26 | Iterable<S> snippetPreSearch(S query, O... _) { |
27 | long nanos = nanoTime(); |
28 | Iterable<S> l; |
29 | //time "lookup" { |
30 | l = wordIndex == null ? null : wordIndex.documentsContainingAllWords(query, _); |
31 | //} |
32 | //print((nanoTime()-nanos) + " nanos in pre"); |
33 | ret l; |
34 | } |
35 | } |
Began life as a copy of #1029025
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: | #1029073 |
Snippet name: | Snippets BitSet Word Index |
Eternal ID of this version: | #1029073/3 |
Text MD5: | f808908ac597798db94028e72047152e |
Transpilation MD5: | 500b259c4cfcfa87b5ecd2c5c53c2039 |
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:04 |
Source code size: | 980 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 248 / 337 |
Version history: | 2 change(s) |
Referenced in: | [show references] |