Skip to content

getGraphs() for RDF/JS Interface #1566

@danielbeeke

Description

@danielbeeke

Issue type:

  • ➕ Feature request

Description:

getGraphs() for Graph Name Enumeration

This feature proposes the addition of a new method, getGraphs(), to the Comunica RDF/JS interface. Similar to the existing countQuads() method (similar as both are an addition to the current Streams > Store spec), getGraphs() would provide a stream-based interface for enumerating the named graphs available within a RDF/js store that is queried by Comunica.

The proposed TypeScript signature is:

type getGraphs(): Stream<NamedNode>

This method would return a Stream of NamedNode objects, where each NamedNode represents the IRI of an available named graph.


Use Case: localStore - A File System-Backed RDF/JS Store

This getGraphs() feature is a very helpful performance optimization for the localStore project. localStore is an RDF/JS Store implementation that leverages the browser's showDirectoryPicker API (currently Chrome-only) to mount a local folder on the end-user's computer.

In localStore, a baseUri is a required option. Files and folders within the mounted directory are represented as relative IRIs to this baseUri. For files outside the baseUri's scope, their names are transformed into hex strings for the filenames.

localStore is designed to be fully queryable and updateable, allowing for the creation and modification of Turtle files directly on the local disk. These files often utilize relative notation, such as <>.


Problem Solved by getGraphs()

Currently, there's no standardized way within the RDF/JS specification to only enumerate the named graphs a store contains. For localStore, each Turtle file on the disk essentially represents a named graph. Without getGraphs() a .match() is called to get all graphs, which results in parsing all of the named graphs. With getGraphs localStore can just iterate over all the file handlers and return the named graphs without parsing their contents. Might be helpful for other triples stores too when iterating over all graphs is more costly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    To do (prio:high)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions