-
-
Save refset/357699aeeb59d605f0d005bf65f672aa to your computer and use it in GitHub Desktop.
av-scan.clj
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
(let [n (xt/start-node {}) | |
_ (xt/await-tx n (xt/submit-tx n [[::xt/put {:xt/id 0 :k 0}] | |
[::xt/put {:xt/id 1 :k 0}] | |
[::xt/put {:xt/id 2 :k 0}] | |
[::xt/put {:xt/id 3 :k 1}] | |
[::xt/put {:xt/id 4 :k 2}] | |
[::xt/put {:xt/id 5 :k 2}] | |
[::xt/put {:xt/id 6 :k 3}]]))] | |
(with-open [r (xt/open-q (xt/db n) | |
'{:find [v] | |
:where [[_ :k v]]})] | |
(take 10 (iterator-seq r))) | |
;;=> ([0] [0] [0] [1] [2] [2] [3]) | |
;; ideally this might just return a scan over AV, but XT isn't doing that today (2021-09-11) | |
;; it is potentially a optimisation/heuristic we could support in future | |
;; raw access to AV is possible anyway though | |
(with-open [db (xt/open-db n)] | |
(with-open [is (db/open-index-snapshot (:index-store db))] | |
(doall (map xtdb.codec/decode-value-buffer (take 10 (xtdb.db/av is :k nil)))))) | |
;;=> (0 1 2 3) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment