Created
February 26, 2021 18:02
-
-
Save jasraj/ece63030522db03f4fd7634f80b048aa to your computer and use it in GitHub Desktop.
kdb String Deduplication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ q).Q.w[]`used | |
/ 385648 | |
/ 1. Generate some strings with repeats | |
/ q).Q.w[]`used | |
/ 10482848 | |
strs:.Q.an @/:(mod[;count .Q.an] 4 cut til 1000000); | |
/ 2. Deduplicate | |
/ q).Q.w[]`used | |
/ 2484864 | |
strs:distinct[strs] raze where each distinct[strs] ~\:/: strs | |
/ Check reference count of each string | |
/ q)-16!/:strs | |
/ 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 3968 39.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment