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

Add option to return query results w/ order matching SELECT bindings #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dannyfreeman
Copy link
Contributor

No description provided.

@@ -122,7 +123,7 @@
(let [namespaces (into {}
(map (fn [^Namespace ns] [(.prefix ns) (.iri ns)]))
(iterator-seq (.. results namespaces iterator)))]
(with-meta (vector-map-results valfn results) {:namespaces namespaces})))
(vary-meta (vector-map-results valfn results) assoc :namespaces namespaces)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with-meta sets the metadata, overriding any previous metadata that may or may not have been present. vary-meta updates existing metadata, and has the same signature as update. We almost always want to accumulate metadata, never override it with new values.

@@ -98,11 +96,12 @@

(defn key-map-results
"Converts a Iteration of bindings into a seq of keymaps."
[^IFn keyfn ^IFn valfn ^CloseableIterator results]
[^IFn keyfn ^IFn valfn ^SelectQueryResult results]
Copy link
Contributor Author

@dannyfreeman dannyfreeman Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this to a more specific interface, which implements CLoseableIterator. See https://docs.stardog.com/javadoc/snarl/com/stardog/stark/query/SelectQueryResult.html

Necessary to avoid reflecting when calling the variables method.

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

Successfully merging this pull request may close these issues.

1 participant