Uses 911K of libraries. Click here for Pure Java version (5684L/29K).
!7 cprint SnippetsBitSetWordIndex { transient WordIndexWithBitSets<S> wordIndex; // string = snippet ID switchable S regexp = "\\w+"; start-thread { dm_reloadOnFieldChange regexp(); time "Make bit-set word index" { print("Making index"); new WordIndexWithBitSets<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.documentsContainingAllWords(query, _); //} //print((nanoTime()-nanos) + " nanos in pre"); ret l; } }
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: | 247 / 334 |
Version history: | 2 change(s) |
Referenced in: | [show references] |