### Install Specific Module and Dependencies Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md For quick iteration, install a specific module and its direct dependencies. Remember to run a root-level install before executing tests that depend on your changes. ```bash mvn -pl -am -Pquick clean install ``` -------------------------------- ### Build and Start RDF4J Docker Container Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/docker/README_DEV.md Run this script to build the Docker image and start the RDF4J server and workbench container. ```bash ./run.sh ``` -------------------------------- ### Initial Commit Log Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/developer/squashing.md This is an example of a commit log before squashing, showing individual commits with potentially inconsistent or uninformative messages. ```git * 43d2565 (HEAD -> GH-1234-my-feature-branch) fixed typo * ce064f9 adjusted related class FooBar to be more efficient * b135e03 oops forgot one * 73e58a1 GH-1234 added feature: tests now succeed * a0178bd GH-1234 added tests for my feature ``` -------------------------------- ### Get Console Help Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tools/console.md Type 'help' to get an overview of available commands. Use 'help ' for specific command details. ```shell help ``` ```shell help connect ``` -------------------------------- ### Configure SailRepository with MemoryStore Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/configuration.md Example configuration for a SailRepository using an in-memory store. This setup is suitable for basic testing or applications that do not require persistent storage. ```turtle @prefix rdfs: . @prefix config: . [] a config:Repository ; config:rep.id "example" ; rdfs:label "Example Memory store" ; config:rep.impl [ config:rep.type "openrdf:SailRepository" ; config:sail.impl [ config:sail.type "openrdf:MemoryStore" ; config:sail.iterationCacheSyncThreshold "10000"; config:mem.persist true; config:mem.syncDelay 0; config:sail.defaultQueryEvaluationMode "STANDARD" ] ]. ``` -------------------------------- ### Mandatory Maven Install Command Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md Run this command before starting work or before any test runs to ensure all modules are installed in the local Maven repository. Use `-o` for offline mode if possible. ```bash mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200 ``` -------------------------------- ### Start RDF4J Docker Containers in Foreground Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/docker/README_DEV.md Start RDF4J containers in the foreground, printing logs and stopping with Ctrl-C. ```bash docker compose up ``` -------------------------------- ### Property Path Builder Examples Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tutorials/sparqlbuilder.md Demonstrates various property path constructions using lambda expressions and their corresponding SPARQL representations. ```java p -> p.pred(FOAF.ACCOUNT).then(FOAF.MBOX) ``` ```sparql foaf:account / foaf:mbox ``` ```java p -> p.pred(RDF.TYPE).then(RDFS.SUBCLASSOF).zeroOrMore() ``` ```sparql rdf:type / rdfs:subClassOf * ``` ```java p -> p.pred(EX.MOTHER_OF).or(EX.FATHER_OF).oneOrMore() ``` ```sparql ( ex:motherOf | ex:fatherOf ) + ``` ```java p -> p.pred(EX.MOTHER_OF).or(p1 -> p1.pred(EX.FATHER_OF).zeroOrOne()) ``` ```sparql ex:motherOf | ( ex:fatherOf ? ) ``` ```java p -> p.negProp().pred(RDF.TYPE).invPred(RDF.TYPE) ``` ```sparql !( rdf:type | ^ rdf:type ) ``` -------------------------------- ### Initialize ModelBuilder and Set Namespaces Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/model.md Shows the initial setup of the ModelBuilder and how to define custom and predefined namespaces for use in creating RDF models. ```java ModelBuilder builder = new ModelBuilder(); builder.setNamespace("ex", "http://example.org/").setNamespace(FOAF.NS); ``` -------------------------------- ### Checkout Main Branch Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/developer/releases.md Ensure you are on the main branch before starting the release process. This is the starting point for creating a new release branch. ```bash git checkout main ``` -------------------------------- ### Example Release Approval Email for RDF4J 2.2 Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/developer/releases.md An example email to send to the PMC for approval of a release. Include the release version, scheduled date, release review info, and issue tracking link. ```text Dear PMC members, Can I get your approval for RDF4J release 2.2, scheduled for February 2. Release review info: https://projects.eclipse.org/projects/technology.rdf4j/reviews/2.2-release-review Issue tracking the release: https://bugs.eclipse.org/bugs/show_bug.cgi?id=510577 Kind regards, Jeen Broekstra ``` -------------------------------- ### Maven Install Without Parallel Threads Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md If the install command fails for reasons other than missing dependencies, try running it without the `-T 1C` flag. ```bash mvn -o -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200 ``` -------------------------------- ### Configure In-Memory SAIL Stack Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Programmatically create a configuration for an in-memory SAIL stack. This example demonstrates setting up a basic MemoryStoreConfig. ```java import org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig; import org.eclipse.rdf4j.repository.config.RepositoryImplConfig; import org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig; // create a configuration for the SAIL stack var storeConfig = new MemoryStoreConfig(); // create a configuration for the repository implementation RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(storeConfig); ``` -------------------------------- ### RDF-star Turtle Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/rdfstar.md Illustrates the syntax for representing RDF-star triples with annotations in Turtle format. ```turtle <> ex:certainty 0.9 . ``` -------------------------------- ### Namespace Declaration Record Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/rdf4j-binary.md Illustrates the byte-level structure for a namespace declaration record, including the marker, prefix, and URI. ```text byte: 0 | 1 2 3 4 | 5 6 | 7 8 9 10 | 11 13 15 17 19 (etc) | ----------+---------+-----+----------+----------------------+ value: 0 | 0 0 0 2 | e x | 0 0 0 19 | h t t p : (etc) | ``` -------------------------------- ### SpinSail Configuration via RepositoryManager Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/spin.md Configure a SpinSail and MemoryStore using the RepositoryManager. This approach uses configuration objects for setup. ```java SailImplConfig spinSailConfig = new SpinSailConfig(new MemoryStoreConfig()); RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(spinSailConfig); // create the config for the actual repository String repositoryId = "spin-test"; RepositoryConfig repConfig = new RepositoryConfig(repositoryId, repositoryTypeSpec); manager.addRepositoryConfig(repConfig); // get the Repository from the manager Repository repository = manager.getRepository(repositoryId); ``` -------------------------------- ### Configure an RDF4J Memory Store Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/configuration.md Example configuration for an in-memory RDF4J repository. Use this for temporary data or when persistence is not required. ```turtle @prefix rdfs: . @prefix config: . [] a config:Repository ; config:rep.id "example" ; rdfs:label "Example Memory store" ; config:rep.impl [ config:rep.type "openrdf:SailRepository" ; config:sail.impl [ config:sail.type "openrdf:MemoryStore" ; config:sail.iterationCacheSyncThreshold "10000"; config:mem.persist true; config:mem.syncDelay 0; config:sail.defaultQueryEvaluationMode "STANDARD" ] ]. ``` -------------------------------- ### Initialize MemoryStore Repository and Add Data Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Demonstrates how to set up an in-memory RDF store and add basic triples. This is useful for testing and in-memory data manipulation. ```java public class QueryExplainExample { public static void main(String[] args) { SailRepository sailRepository = new SailRepository(new MemoryStore()); try (SailRepositoryConnection connection = sailRepository.getConnection()) { ValueFactory vf = connection.getValueFactory(); String ex = "http://example.com/"; IRI peter = vf.createIRI(ex, "peter"); IRI steve = vf.createIRI(ex, "steve"); IRI mary = vf.createIRI(ex, "mary"); IRI patricia = vf.createIRI(ex, "patricia"); IRI linda = vf.createIRI(ex, "linda"); connection.add(peter, RDF.TYPE, FOAF.PERSON); ``` -------------------------------- ### Comment Record Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/rdf4j-binary.md Shows the byte-level encoding for a comment record, starting with the marker followed by the comment text. ```text byte: 0 | 1 2 3 4 | 5 7 9 11 13 15 17 | ----------+---------+-------------------+ value: 2 | 0 0 0 7 | e x a m p l e | ``` -------------------------------- ### Create a New Repository Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tools/console.md Use the 'create' command with a template name (e.g., 'native') to create a new repository. The console will prompt for configuration details. ```shell create native ``` -------------------------------- ### Basic SpinSail Setup with MemoryStore Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/spin.md Configure a basic Sail Stack with a Memory Store and SPIN inferencing support. This is the most straightforward way to enable SPIN. ```java SpinSail spinSail = new SpinSail(); spinSail.setBaseSail(new MemoryStore()); // create a repository with the Sail stack: Repository rep = new SailRepository(spinSail); rep.init(); ``` -------------------------------- ### Show Help for Query Plan Snapshot CLI Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/benchmark/README.md Displays the help information for the query plan snapshot CLI tool. This is useful for understanding all available options and arguments. ```bash mvn -o -Dmaven.repo.local=.m2_repo -pl testsuites/benchmark -DskipTests exec:java@query-plan-snapshot -Dexec.args="--help" ``` -------------------------------- ### Valid Data Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/shacl.md An example of data that conforms to the defined SHACL shapes. ```trig ex:dataGraph { ex:steve a ex:Person. ex:jane a ex:Person; ex:age 40. } ``` -------------------------------- ### Invalid Data Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/shacl.md An example of data that violates the defined SHACL shapes, specifically the age datatype. ```trig ex:dataGraph { ex:john a ex:Person; ex:age "seventy two". } ``` -------------------------------- ### Show Available Repositories Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tools/console.md The 'show repositories' command lists all repositories available in the currently connected set. ```shell show repositories ``` -------------------------------- ### Build Project with Maven Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md Commands for building the project, either a fast path without tests or a full verification with tests. Use '-o' for offline builds and '-Dmaven.repo.local=.m2_repo'. ```bash mvn -T 1C -o -Dmaven.repo.local=.m2_repo -Pquick clean install ``` ```bash mvn -o -Dmaven.repo.local=.m2_repo verify ``` -------------------------------- ### Example SHACL Validation Report Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/shacl.md An example of a SHACL validation report in Turtle format, showing details of a validation violation. ```turtle [] a sh:ValidationReport ; sh:conforms false ; rdf4j:truncated false; sh:result [ a sh:ValidationResult ; sh:value "eighteen"; sh:focusNode ex:pete ; sh:resultPath ex:age ; sh:sourceConstraintComponent sh:DatatypeConstraintComponent ; sh:resultSeverity sh:Violation; sh:resultMessage "A person's age must be a number (xsd:int)."; sh:sourceShape [ a sh:PropertyShape; sh:message "A persons age must be a number (xsd:int)."; sh:path ex:age; sh:datatype xsd:int ] ] . ``` -------------------------------- ### GET Request for a Deleted Named Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/index.html Attempting to GET a named graph after it has been deleted should result in a 404 Not Found response. ```http GET $GRAPHSTORE$/person/2.ttl HTTP/1.1 Host: $HOST$ ``` -------------------------------- ### Query with User-Provided Keyword Binding Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Shows how to prepare a query and then use `setBinding` with a literal value, simulating a query based on user input or external data. This requires importing `Values` for creating literals. ```java import static org.eclipse.rdf4j.model.util.Values.literal; // In this example, we specify the keyword string. Of course, this // could just as easily be obtained by user input, or by reading from // a file, or... String keyword = "foobar"; // We prepare a query that retrieves all documents for a keyword. // Notice that in this query the 'keyword' variable is not bound to // any specific value yet. TupleQuery keywordQuery = con.prepareTupleQuery("SELECT ?document WHERE { ?document ex:keyword ?keyword . }"); // Then we set the binding to a literal representation of our keyword. // Evaluation of the query object will now effectively be the same as // if we had specified the query as follows: // SELECT ?document WHERE { ?document ex:keyword "foobar". } keywordQuery.setBinding("keyword", literal(keyword)); // We then evaluate the prepared query and can process the result: TupleQueryResult keywordQueryResult = keywordQuery.evaluate(); ``` -------------------------------- ### Initialize Git Submodule Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/README.md Run this command to check out a local copy of the Solstice theme submodule. You typically only need to do this once after cloning the repository. ```bash git submodule update --init --recursive ``` -------------------------------- ### Prepare and Reuse Tuple Queries with Bindings Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Demonstrates preparing two tuple queries, evaluating one to retrieve names, and then using the results to set bindings for the second query to retrieve corresponding email addresses. This pattern is useful for iterative data retrieval. ```java try (RepositoryConnection con = repo.getConnection()){ // First, prepare a query that retrieves all names of persons TupleQuery nameQuery = con.prepareTupleQuery("SELECT ?name WHERE { ?person ex:name ?name . }"); // Then, prepare another query that retrieves all e-mail addresses of persons: TupleQuery mailQuery = con.prepareTupleQuery("SELECT ?mail WHERE { ?person ex:mail ?mail ; ex:name ?name . }"); // Evaluate the first query to get all names try (TupleQueryResult nameResult = nameQuery.evaluate()){ // Loop over all names, and retrieve the corresponding e-mail address. for (BindingSet bindingSet: nameResult) { Value name = bindingSet.get("name"); // Retrieve the matching mailbox, by setting the binding for // the variable 'name' to the retrieved value. Note that we // can set the same binding name again for each iteration, it will // overwrite the previous setting. mailQuery.setBinding("name", name); try ( TupleQueryResult mailResult = mailQuery.evaluate()) { // mailResult now contains the e-mail addresses for one particular person .... } } } } ``` -------------------------------- ### SHACL Node Shape Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/shacl.md An example SHACL shape defining constraints for a 'Person' class, specifically requiring the 'age' property to be an integer. ```turtle ex:PersonShape a sh:NodeShape ; sh:targetClass ex:Person ; sh:property [ sh:path ex:age ; sh:datatype xsd:int ; ] . ``` -------------------------------- ### Configure NativeStore WAL Settings (Java) Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/configuration.md Programmatically configure Write-Ahead Logging (WAL) settings for the NativeStore. Ensure the entire 'value-store-wal/' directory is included when backing up or copying a repository. ```java NativeStore store = new NativeStore(dataDir); store.setWalSyncPolicy(ValueStoreWalConfig.SyncPolicy.INTERVAL); store.setWalSyncIntervalMillis(5); store.setWalMaxSegmentBytes(256L * 1024 * 1024); store.setWalQueueCapacity(524_288); store.setWalSyncBootstrapOnOpen(true); store.setWalAutoRecoverOnOpen(true); store.setWalEnabled(true); // or false to disable the WAL entirely ``` -------------------------------- ### Cleaned Up Commit Message Example Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/developer/squashing.md An example of a cleaned-up commit message after removing less valuable commit details, focusing on the core changes. ```gitcommit # This is a combination of 5 commits. # This is the 1st commit message: GH-1234 added new feature ABC and adjusted FooBar - added feature and tests - adjusted related class FooBar to be more efficient # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Tue Oct 13 10:01:24 2020 +1100 # # interactive rebase in progress; onto dc0fa78 ``` -------------------------------- ### Explain Tuple Query with Timed Level in Java Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Demonstrates how to prepare and explain a tuple query using the `explain` method with the `Timed` level. This feature is experimental and only works with built-in stores directly in Java code. ```java try (SailRepositoryConnection connection = sailRepository.getConnection()) { TupleQuery query = connection.prepareTupleQuery("select * where .... "); String explanation = query.explain(Explanation.Level.Timed).toString(); System.out.println(explanation); } ``` -------------------------------- ### Start RDF4J Docker Container with Docker Compose Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/docker/README_DEV.md Use Docker Compose to start the RDF4J server and workbench container in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Connect to RDF4J Server or Local Repositories Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tools/console.md Use the 'connect' command to establish a connection. Specify the server URL, or 'default' for local repositories. User credentials can also be provided. ```shell connect http://localhost:8080/rdf4j-server ``` ```shell connect default ``` ```shell connect http://example.rdf4j.org/rdfj-server myname mypassword ``` -------------------------------- ### GET Request After Deleting Existing Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Verifies the deletion of a graph by attempting to GET it. A 404 Not Found response indicates successful deletion. ```HTTP GET /person/2.ttl HTTP/1.1 Host: $HOST$ ``` ```HTTP 404 Not Found ``` -------------------------------- ### Run Interactive Mode CLI Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/benchmark/README.md Executes the RDF4J query plan snapshot CLI in interactive mode. Use arrow keys and Enter to navigate the menu. Startup without arguments presents a main action menu. ```bash mvn -o -Dmaven.repo.local=.m2_repo -pl testsuites/benchmark -DskipTests exec:java@query-plan-snapshot ``` -------------------------------- ### Example RDF Data for Palindrome Check Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/tutorials/custom-sparql-functions.md This Turtle data provides example resources with string labels, used to demonstrate the custom palindrome function. ```turtle PREFIX rdfs: . PREFIX ex: . ex:a rdfs:label "step on no pets" . ex:b rdfs:label "go on, try it" . ``` -------------------------------- ### Format Java, Imports, and XML Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md Run this command to format Java code, imports, and XML files. Ensure agent signature comments and copyright headers are present before formatting. ```bash mvn -o -Dmaven.repo.local=.m2_repo -q -T 2C process-resources ``` -------------------------------- ### Explain Tuple Query (Unoptimized) Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Prepares and explains a tuple query at the unoptimized level. This shows the query plan before any significant optimization. ```Java try (SailRepositoryConnection connection = sailRepository.getConnection()) { TupleQuery query = connection.prepareTupleQuery(String.join("\n", "", "PREFIX foaf: ", "SELECT * WHERE ", "{", " BIND( as ?person)", "\t?person a foaf:Person .", "\t{", "\t\t?person\t(foaf:knows | ^foaf:knows)* ?friend.", "\t} UNION {", "\t\t?friend foaf:age ?age", "\t\tFILTER(?age >= 18) ", "\t}", "}")); Explanation explainUnoptimized = query.explain(Explanation.Level.Unoptimized); System.out.println(explainUnoptimized); System.out.println("\n\n"); Explanation explain = query.explain(Explanation.Level.Timed); System.out.println(explain); } ``` -------------------------------- ### GET Request to Retrieve a Named Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/index.html Use GET to retrieve the content of a specific named graph. Specify the desired Accept header for the response format. ```http GET $GRAPHSTORE$/person/2.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` -------------------------------- ### Start Transaction with Serializable Isolation Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Use this to start a transaction with SERIALIZABLE isolation. Ensure to handle potential commit exceptions and consider replaying transactions if conflicts occur. ```java try (RepositoryConnection conn = rep.getConnection()) { conn.begin(IsolationLevels.SERIALIZABLE); .... conn.commit(); } ``` -------------------------------- ### GET Request for Turtle Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Demonstrates a GET request to retrieve a graph in Turtle format. Ensure the Accept header is set correctly for the desired content type. ```HTTP GET /person/2.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` ```HTTP 200 OK Content-type: text/turtle ``` -------------------------------- ### Explain Tuple Query (Timed) and DOT format Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Prepares and explains a tuple query, then outputs the explanation in DOT format. This is useful for visualizing the query plan. ```Java try (SailRepositoryConnection connection = sailRepository.getConnection()) { TupleQuery query = connection.prepareTupleQuery(String.join("\n", "", "PREFIX foaf: ", "SELECT * WHERE ", "{", " BIND( as ?person)", "\t?person a foaf:Person .", "\t{", " BIND( as ?person)", "\t\t?person\t(foaf:knows | ^foaf:knows)* ?friend.", "\t} UNION {", "\t\t?friend foaf:age ?age", "\t\tFILTER(?age >= 18) ", "\t}", "}")); Explanation explain = query.explain(Explanation.Level.Timed); System.out.println(explain); System.out.println(explain.toDot()); } ``` -------------------------------- ### GET Request for the Default Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/index.html Retrieve the content of the default graph using a GET request with the '?default' parameter. Specify the desired Accept header for the graph format. ```http GET $GRAPHSTORE$?default HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` -------------------------------- ### Maven Install Without Offline Mode Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md If offline resolution fails due to missing dependencies, run the install command without the `-o` flag, then return to offline mode. ```bash mvn -Dmaven.repo.local=.m2_repo -Pquick clean install | tail -200 ``` -------------------------------- ### Create Federation from Data Configuration File Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/federation.md Initializes a FedX federation using a data configuration file (e.g., Turtle format). This is useful for managing complex federation setups declaratively. ```java File dataConfig = new File("local/dataSourceConfig.ttl"); Repository repo = FedXFactory.createFederation(dataConfig); String q = "PREFIX rdf: " + "PREFIX dbpedia-owl: " + "SELECT ?President ?Party WHERE { " + "?President rdf:type dbpedia-owl:President .\n" + "?President dbpedia-owl:party ?Party . }"; try (RepositoryConnection conn = repo.getConnection()) { TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, q); try (TupleQueryResult res = query.evaluate()) { while (res.hasNext()) { System.out.println(res.next()); } } } repo.shutDown(); System.out.println("Done."); System.exit(0); ``` -------------------------------- ### Set Basic Authentication Handler Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/news/rdf4j-600-M1.md Illustrates how to set up basic authentication for a session using the BasicAuthenticationHandler. ```java session.setAuthenticationHandler(new BasicAuthenticationHandler("user", "secret")); ``` -------------------------------- ### Example SPARQL Query Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md A SPARQL query example that retrieves friends of a given person, filters them by age, and optionally includes their names. This query is used to demonstrate the explanation feature. ```sparql PREFIX foaf: SELECT ?friend ?name WHERE { BIND( as ?person) ?person a foaf:Person ; (foaf:knows | ^foaf:knows)* ?friend. ?friend foaf:age ?age OPTIONAL { ?friend foaf:name ?name } FILTER(?age >= 18) } ``` -------------------------------- ### GET Request for Updated Graph Content Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/index.html Verify the content of an updated graph by issuing a GET request. The response should reflect the latest changes made via a PUT operation. ```http GET $GRAPHSTORE$/person/1.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` -------------------------------- ### Run RDF4J-Spring Demo Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/spring-components/rdf4j-spring-demo/README.md Execute the demo application using Maven. The program will write output to standard output and then exit. ```bash mvn spring-boot:run ``` -------------------------------- ### Run Tests with Maven Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md Prefer using 'mvnf' for testing. This manual Maven command is for situations where specific profiles or flags not supported by 'mvnf' are needed. Start testing at the smallest scope (class/method) and expand as needed. Use '--it' for integration tests. ```bash mvn -o -Dmaven.repo.local=.m2_repo test ``` -------------------------------- ### GET Request to Retrieve a Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.txt Use GET to retrieve the content of a named graph. The Accept header can specify the desired media type. A 200 OK status indicates success, returning the graph data. ```http GET /person/1.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` ```http GET $GRAPHSTORE$?default HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` ```http GET /person/2.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` -------------------------------- ### Format Resources with Maven Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/AGENTS.md Use this command to format resources during the development process. It's a quick step before compilation. ```bash mvn -o -Dmaven.repo.local=.m2_repo -q -T 2C process-resources ``` -------------------------------- ### GET Request to Retrieve a Specific Graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/index.html Retrieve a specific RDF graph from the store using a GET request. Specify the desired Accept header for the graph format. A 200 OK response with the graph content is expected. ```http GET $GRAPHSTORE$?graph=$GRAPHSTORE$/person/1.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ``` -------------------------------- ### Run Query from File and Persist Snapshot Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/benchmark/README.md Executes a query loaded from a file and persists its plan snapshot using the memory store. Requires specifying the theme and the path to the query file. ```bash ... -Dexec.args="--store memory --theme MEDICAL_RECORDS --query-file /tmp/query.rq" ``` -------------------------------- ### Sesame Maven Dependency Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/reference/migration.md Example of a Maven dependency for the Sesame Repository API. ```xml org.openrdf.sesame sesame-repository-api ``` -------------------------------- ### GET of POST - multipart/form-data Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Retrieves the RDF graph after it has been updated using multipart/form-data. ```APIDOC ## GET /person/1.ttl (after multipart POST) ### Description Retrieves the RDF graph after an update using multipart/form-data. ### Method GET ### Endpoint /person/1.ttl ### Request Example GET /person/1.ttl HTTP/1.1 Host: $HOST$ ### Response Example 200 OK Content-type: text/turtle @prefix foaf: . @prefix v: . a foaf:Person; foaf:name "Jane Doe"; foaf:givenName "Jane"; foaf:familyName "Doe"; foaf:businessCard [ a v:VCard; v:fn "Jane Doe" ] . ``` -------------------------------- ### Explain Tuple Query (Timed) Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md Prepares and explains a tuple query with a focus on timed execution plans. This helps in understanding query performance. ```Java try (SailRepositoryConnection connection = sailRepository.getConnection()) { TupleQuery query = connection.prepareTupleQuery(String.join("\n", "", "PREFIX foaf: ", "SELECT ?friend ?name WHERE ", "{", "\tBIND( as ?person)", "\t?person a foaf:Person ; \t\t(foaf:knows | ^foaf:knows)* ?friend.", "\tOPTIONAL {", "\t\t?friend foaf:name ?name", "\t}", "\t?friend foaf:age ?age", "\tFILTER(?age >= 18) ", "}")); Explanation explain = query.explain(Explanation.Level.Timed); System.out.println(explain); } ``` -------------------------------- ### GET - existing graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Retrieves an existing RDF graph from the specified path. ```APIDOC ## GET /person/2.ttl ### Description Retrieves an existing RDF graph. ### Method GET ### Endpoint /person/2.ttl ### Request Example GET /person/2.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ### Response Example 200 OK Content-type: text/turtle ``` -------------------------------- ### GET of POST - create new graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Retrieves the newly created RDF graph. ```APIDOC ## GET $NEWPATH$ (after POST) ### Description Retrieves the RDF graph that was just created. ### Method GET ### Endpoint $NEWPATH$ ### Request Example GET $NEWPATH$ HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ### Response Example 200 OK Content-type: text/turtle @prefix foaf: . @prefix v: . [] a foaf:Person; foaf:businessCard [ a v:VCard; v:given-name "Alice" ] . ``` -------------------------------- ### Query Explanation Plan (Timed Level) Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/site/content/documentation/programming/repository.md An example of a query execution plan generated at the `Timed` explanation level. It shows the projected elements, join operations, filters, and statement patterns with actual result sizes and timings. ```text 01 Projection (resultSizeActual=2, totalTimeActual=0.247ms, selfTimeActual=0.002ms) 02 ╠══ProjectionElemList 03 ProjectionElem "friend" 04 ProjectionElem "name" 05 ╚══LeftJoin (LeftJoinIterator) (resultSizeActual=2, totalTimeActual=0.245ms, selfTimeActual=0.005ms) 06 ├──Join (JoinIterator) (resultSizeActual=2, totalTimeActual=0.238ms, selfTimeActual=0.004ms) 07 │ ╠══Extension (resultSizeActual=1, totalTimeActual=0.002ms, selfTimeActual=0.001ms) 08 │ ║ ├──ExtensionElem (person) 09 │ ║ │ ValueConstant (value=http://example.com/peter) 10 │ ║ └──SingletonSet (resultSizeActual=1, totalTimeActual=0.0ms, selfTimeActual=0.0ms) 11 │ ╚══Join (JoinIterator) (resultSizeActual=2, totalTimeActual=0.231ms, selfTimeActual=0.009ms) 12 │ ├──Filter (resultSizeActual=4, totalTimeActual=0.023ms, selfTimeActual=0.014ms) 13 │ │ ╠══Compare (>=) 14 │ │ ║ Var (name=age) 15 │ │ ║ ValueConstant (value="18"^^) 16 │ │ ╚══StatementPattern (costEstimate=4, resultSizeEstimate=12, resultSizeActual=12, totalTimeActual=0.009ms, selfTimeActual=0.009ms) 17 │ │ Var (name=friend) 18 │ │ Var (name=_const_8d89de74_uri, value=http://xmlns.com/foaf/0.1/age, anonymous) 19 │ │ Var (name=age) 20 │ └──Join (JoinIterator) (resultSizeActual=2, totalTimeActual=0.199ms, selfTimeActual=0.007ms) ``` -------------------------------- ### GET of POST - existing graph Source: https://github.com/eclipse-rdf4j/rdf4j/blob/main/testsuites/sparql/src/main/resources/testcases-sparql-1.1-w3c/http-rdf-update/tests.html Retrieves the updated RDF graph after a POST operation. ```APIDOC ## GET /person/1.ttl (after POST) ### Description Retrieves the RDF graph after it has been updated via POST. ### Method GET ### Endpoint /person/1.ttl ### Request Example GET /person/1.ttl HTTP/1.1 Host: $HOST$ Accept: text/turtle; charset=utf-8 ### Response Example 200 OK Content-type: text/turtle @prefix foaf: . @prefix v: . a foaf:Person; foaf:name "Jane Doe"; foaf:businessCard [ a v:VCard; v:fn "Jane Doe" ] . ```