Skip to content

Commit

Permalink
implement: lru caching for string:corpus-find/disk
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffhhk committed Mar 30, 2021
1 parent bed5975 commit b4743cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions medikanren/db.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
(require
"repr.rkt"
"string-search.rkt"
"lru.rkt"
racket/file
racket/stream
racket/string
Expand Down Expand Up @@ -139,6 +140,13 @@
(define cui-index (port->string-keys in-concept-cui-index))
(close-input-port in-concept-cui-index)
(lambda (cui*) (string:corpus-find* cui-corpus cui-index cui*)))
(num-cached-cuis
(define lru
(make-lru
(lambda (cui) (string:corpus-find/disk cid->concept in-concept-cui-index cui))
#:num-entries-max num-cached-cuis))
(define (lookup cui) (lru-ref lru cui))
(lambda (cui*) (string:corpus-find*/disk cid->concept lookup cui*)))
(else
(define (lookup cui) (string:corpus-find/disk cid->concept in-concept-cui-index cui))
(lambda (cui*) (string:corpus-find*/disk cid->concept lookup cui*)))))
Expand Down

0 comments on commit b4743cc

Please sign in to comment.