Documentation
¶
Index ¶
Constants ¶
const QueryDir = "sparql"
QueryDir is the directory of a SAL project, created by `sal init`, that holds its SPARQL queries.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(ctx context.Context, runner Runner, projectDir string, queries []Query) (*rdflibgo.Graph, error)
Run wipes .sal/constructed, runs every query, writes the graph each one builds to .sal/constructed/<name>.ttl, and returns the graphs merged into one. The output is Turtle rather than JSON-LD: it groups a subject's statements and shortens IRIs with no @context to resolve, so it is both the smaller file and the cheaper one to write and read back. The directory is wiped even when there are no queries, so it never holds the output of a query the project no longer has.
Types ¶
type ConstructCmd ¶
type ConstructCmd struct{}
ConstructCmd runs every SPARQL CONSTRUCT query in the project's sparql/ directory against the built triples table and writes the graph each one builds to .sal/constructed. It only reads the table; `sal build` is what commits the constructed triples, in the same snapshot as everything else.
func (*ConstructCmd) Run ¶
func (cmd *ConstructCmd) Run() (err error)
type Query ¶
type Query struct {
// Path is the file the query was read from.
Path string
// Name is the file's path under sparql/ without its extension, which is
// what the file of constructed triples is named after.
Name string
Text string
// Prefixes are the prefixes the query declares, which the constructed
// triples are written with.
Prefixes map[string]string
}
Query is a SPARQL CONSTRUCT query found in the project's sparql/ directory.
func FindQueries ¶
FindQueries returns every SPARQL CONSTRUCT query under the project's sparql/ directory, sorted by path. A file is a SPARQL query when it ends in .rq or .sparql; one that holds any other kind of query is skipped, and one that does not parse, or that sal cannot translate, is an error naming the file, so that a build fails on it before anything is run. A project without the directory has no queries.