Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider switching to RDF4j background parsing implementations #116

Open
RickMoynihan opened this issue Oct 27, 2017 · 0 comments
Open

Consider switching to RDF4j background parsing implementations #116

RickMoynihan opened this issue Oct 27, 2017 · 0 comments

Comments

@RickMoynihan
Copy link
Member

RickMoynihan commented Oct 27, 2017

We currently consume results on a thread and use a pipe to convert them into a lazy sequence of results.

Since we've done this RDF4j has added convenience methods for pull based parsing (that do the same thing underneath). We should assess whether we can use them, and consider replacing this:

(pr/to-statements [reader {:keys [format buffer-size base-uri] :or {buffer-size 32
base-uri "http://example.org/base-uri"} :as options}]
(if-not format
(throw (ex-info (str "The RDF format was neither specified nor inferable from this object.") {:error :no-format-supplied}))
(let [[statements put!] (pipe buffer-size)
parser (doto (fmt/format->parser (fmt/->rdf-format format))
(.setRDFHandler (reify RDFHandler
(startRDF [this])
(endRDF [this]
(put!)
(.close reader))
(handleStatement [this statement]
(put! statement))
(handleComment [this comment])
(handleNamespace [this prefix-str uri-str]))))]
(future
(try
(.parse parser reader (str base-uri))
(catch Exception ex
(put! ex))))
(let [read-rdf (fn read-rdf [msg]
(if (instance? Throwable msg)
;; if the other thread puts an Exception on
;; the pipe, raise it here.
(throw (ex-info "Reading triples aborted."
{:error :reading-aborted} msg))
(sesame-statement->IStatement msg)))]
(map read-rdf statements))))))

with something using this

@RickMoynihan RickMoynihan added this to the Improved use of RDF4j milestone Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant