Sesame 3.0 Preview: An Open Source Framework for RDF Data

Sesame 3.0 Preview: An Open Source Framework for RDF Data

fter downloading Sesame 3.0-alpha1, the first thing you might notice is that Sesame 3.0 is packaged slightly differently than in 2.x. The awkwardly named sesame-onejar.jar was replaced by sesame-client.jar and sesame-runtime.jar, the openrdf-workbench.war file is gone, and there is a new server script.

The sesame-client.jar contains the RDF parsers and writers distributed with Sesame along with the repository API, HTTP client, and manager. This is the only jar you need for most RDF programs that don’t embed an RDF store. If your application embeds its own RDF store, you can use the sesame-runtime.jar instead. This jar contains the familiar MemoryStore, NativeStore, RdbmsStore, and more. As with 2.x, Sesame Server and Console are not present in either of these jars, but you can find them in the lib directory of the SKD, along with scripts to run them.

Model API

The new Model interface holds a collection of indexed statements and implements Set with other convenient methods for quick access to the underlying information. You can use the class LinkedHashModel as an implementation and perform many of the basic operations of the MemoryStore, such as adding or removing statements, adding or removing namespace prefixes, and filtering statements by subject, predicate, object, or contexts. The Model, unlike the MemoryStore, does preserve the statement ordering, but unlike the MemoryStore it does not provide concurrent modification, transaction, or query support. The Model is a welcome addition for programs that simply need to read and write RDF files.

By simply including the sesame-client.jar, all RDF parsers, writers, and basic model types such as URI, Literal, Statement, and Model are available. To demonstrate working with RDF files, the code in Listing 1 shows how to read in an RDF file, validate it, and then write it back out in an organized format.

Repository API

The Repository API provides access to local and remote RDF stores. It was updated to clarify some confusing method names and provide a smoother, more integrated interface. For example, you could write the following Sesame 2.x code in one line using the 3.0 API.

// Sesame 2.x Repository APIRepositoryResult result = con.getStatements(subj, pred, null, true);try {  if (result.hasNext())    return result.next().getObject().stringValue();  return null;} finally {  result.close();}// Sesame 3.0 Repository APIreturn con.match(subj, pred, null, true).asModel().objectString();

Every repository now includes RepositoryMetaData to allow an application to inquire about the features and behavior of the underlying RDF store. This provides the supported formats, query languages, functions, inferencing rules, and version used by the (possibly remote) repository.

The new 3.0 Repository API is not backwards compatible with the 2.x API. While many 2.x methods still exist (getStatements are deprecated in 3.0), some incompatibilities require client-side changes. The most prominent change in the Repository API is the Result types of both the RepositoryConnection and Query. Instead of the generic Result type of 2.x, 3.0 uses specific ContextResult and ModelResult. The TupleQuery now returns TupleResult from evaluate() and the GraphQuery now returns GraphResult. These are the most significant API changes in 3.0.

Blank nodes (Bnodes) are no longer globally referencable (as they were in Sesame 2.x); you can now only reference them within the same connection. Applications that used a BNode as a global reference must change to use a URI instead, as Sesame RDF stores might use different BNode IDs in different connections to reference the same internal resource. However, BNodes created outside of the connection automatically maps to a new BNode within that connection.

Author’s Note: A BNode Java object is only valid within the connection it was created or received from.

 

This works similar to how RDF files are added to the RDF store: external BNodes are mapped to internal BNodes, within a particular scope. The following code demonstrates how you can use BNodes with Sesame 3.0.

BNode node = conA.getValueFactory().createBNode();conA.add(node, RDF.TYPE, RDF.LIST);conA.hasMatch(node, RDF.TYPE, RDF.LIST);// [] no results because node was not created with conBconB.hasMatch(node, RDF.TYPE, RDF.LIST); // maybe false// contains the new statement, but with a different nodeIDconB.size(null, RDF.TYPE, RDF.LIST) >= 1;

Transactions

Sesame 3.0 introduces isolation levels to the API. In 2.x each store used its own fixed isolation level (MemoryStore, NativeStore, and RdbmsStore in 2.x used an isolation level similar to read committed). In Sesame 3.0, each connection can choose its own isolation level. These are similar to the ANSI SQL isolation levels, however, Sesame has created its own RDF-specific definitions and provides a few more isolation levels that are relevant to distributed and optimistic stores.

Unlike the ANSI SQL isolation levels, Sesame distinguishes between snapshot and serializable isolation levels. Furthermore, Sesame’s definition of snapshot isolation allows independent RDF stores to use eventual consistency to manage the changes to the store. This makes clusters of RDF stores easier to implement for connections that allow eventual consistency, but still require a consistent non-changing view of the store. Some of Sesame’s lower levels of isolation explicitly permit the use of HTTP caching (with some restrictions). This allows connections that only need weak consistency to operate at a significantly enhanced speed, by not having to check for new modifications every time.

Most of the RDF stores are not yet optimized for each of the isolation levels. By adding them to the API now, system architects and developers can start planning if and how they will implement caching, validation, federation, and distribution of RDF stores. For more details on the exact isolation levels supported, see the JavaDoc that is provided with the release.

Configuration

The Sesame Server and Console have changed the way they manage repository configurations. Previously, in 2.x, the configurations were hidden in a proprietary format that you needed to modify through a Java API. In 3.0, the Java API still exists, but the configurations are stored in RDF files under the configurations directory and you can modify them with any text editor. This makes setting up complicated repositories easier. The Console also continues to support configuration templates with the create command. These templates are stored in RDF under the templates directory. Templates allow you to reuse common configurations and the Console prompts you for simple configuration settings, such as repository id, description, and other known properties. The location of these directories is set using the -d option of the Console or Server.

The following code represents an in-memory RDF store configuration (or template):

 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. @prefix rep: <http://www.openrdf.org/config/repository#>. @prefix sr: <http://www.openrdf.org/config/repository/sail#>. @prefix sail: <http://www.openrdf.org/config/sail#>. @prefix ms: <http://www.openrdf.org/config/sail/memory#>. [] a rep:Repository ;    rep:repositoryTitle "Memory store" ;    rep:repositoryImpl [       rep:repositoryType "openrdf:SailRepository" ;       sr:sailImpl [          sail:sailType "openrdf:MemoryStore" ;          ms:persist true ;          ms:syncDelay 0       ]    ]. 

The following code is a memory RDF store wrapped in a RDFS inferencer and a dataset sail that auto-loads any query-referenced datasets (memory-rdfs-dataset.ttl):

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. @prefix rep: <http://www.openrdf.org/config/repository#>. @prefix sr: <http://www.openrdf.org/config/repository/sail#>. @prefix sail: <http://www.openrdf.org/config/sail#>. @prefix ms: <http://www.openrdf.org/config/sail/memory#>. [] a rep:Repository ;    rep:repositoryTitle "Memory Dataset store" ;    rep:repositoryImpl [       rep:repositoryType "openrdf:SailRepository" ;       sr:sailImpl [          sail:sailType "openrdf:DatasetSail" ;          sail:delegate [             sail:sailType "openrdf:ForwardChainingRDFSInferencer" ;             sail:delegate [                sail:sailType "openrdf:MemoryStore" ;                ms:persist true ;                ms:syncDelay 0             ]          ]       ]    ].

Server

The Sesame Workbench is no longer packaged with Sesame. However, much of the functionality provided by the Workbench is available through the Sesame Server and Console. When the Sesame Server is launched with the -u option (resolve URLs to URI descriptions), the server acts as an RDF resource resolver for URLs that resolve to it. Furthermore, it sorts the RDF triples in the result, to provide a more comprehensive view (you can control the order of the triples by listing the desired order in META-INF/org.openrdf.model.order-predicates). You can use this, combined with the new support for RDFa, to turn an HTML browser into an RDF browser. RDFa is a new standard that allows RDF attributes to embed into XHTML content. Using this standard with an RDF server, the traditional lines between an RDF browser and an HTML browser start to blur, as both an RDF client and an HTML client can use the response. By using predicates like <http://www.w3.org/1999/xhtml#title> and <http://www.w3.org/1999/xhtml/vocab#stylesheet> that are understood by HTML clients, you can improve the raw RDFa result in a visually appealing format.

The Sesame Server and protocol was revamped to support transactions; now, a remote repository behaves the same as a local repository. This allows applications to develop using an embedded RDF store and later move to a remote RDF store, while keeping the same behavior. The protocol was also extended to support server-side prepared queries. Large queries that are executed multiple times within a connection can be stored on the server and parsed only once reducing evaluation overhead.

The Sesame Server was extended to support weak consistency when the -c option (number of seconds clients can use their cache before validating) is given a value greater then zero. This allows clients to store results from the server for a period of time before validating the value on the server, and is appropriate when speed is more important than seeing the effects of all write operations. This enables RDF stores to scale much higher by enabling intermediate proxies to cache the results. The Sesame HTTP repository uses weak consistency (if enabled) when running in auto-commit mode for sizeMatch and hasMatch results. By using an intermediate proxy between the client and server, you can cache other results such as match and query evaluation.

Federation

The Federation SAIL is a new feature that allows you to unify multiple Sesame Repositories as a single Repository. The Federation supports writing to one member and does not fully support transactions across members. You can find sample federation configurations on the Aduna Open Source web site.

The Federation SAIL uses the new sizeMatch method of the RepositoryConnection for query optimizations. This causes noticeable delays when evaluating queries over large repositories. Changing the members to use weak consistency can help, but does not effect the time it takes to optimize new queries with new basic graph patterns. However, the Federation does have a few configuration options that can improve the query performance. The most significant is to ensure the members use the openrdf:SailRepository. This allows the Federation to transfer portions of the query to the members and significantly reduces bandwidth and evaluation latency. Setting the distinct configuration option to true allows you to stream results from the members without further processing; thus reducing memory and CPU usage in the Federation. The localPropertySpace configuration option reduces the cross-member joins done during query evaluation for members partitioned by statement subject. This combined with the openrdf:SailRepository drastically reduces the query processing overhead of multiple members. You can only use this option with predicates that are used with subjects that are co-located in the same member.

The HTTPRepository was overhauled to enable effective use within a Federation. It has two new configuration options that are specifically related to the Federation. These are the readOnly option and the subjectSpace option. The readOnly option prevents clients from writing to the remote store and informs the Federation which member should receive new statements. The subjectSpace option is an optimization that reduces redundant bandwidth by informing the Federation where a statement is located based on its subject.

The Expansion of Sesame

The Sesame API has expanded in both breadth and depth in this 3.0 release. It now covers more configuration options and supports multiple levels of transaction isolation, while still providing more convenient ways to perform RDF analysis and manipulation. The 3.0 branch causes some upgrade problems with the new API and the way BNodes are now being handled. However, many of these changes are necessary to support the wider growing interest in the Sesame platform. The new API represents the growing maturity of the semantic web community and the need for more convenient and reliable tools that will help build the next generation of semantic web applications.

devx-admin

devx-admin

Share the Post:
Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023,

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

Military Drones Revolution

Military Drones: New Mobile Command Centers

The Air Force Special Operations Command (AFSOC) is currently working on a pioneering project that aims to transform MQ-9 Reaper drones into mobile command centers to better manage smaller unmanned

Tech Partnership

US and Vietnam: The Next Tech Leaders?

The US and Vietnam have entered into a series of multi-billion-dollar business deals, marking a significant leap forward in their cooperation in vital sectors like artificial intelligence (AI), semiconductors, and

Huge Savings

Score Massive Savings on Portable Gaming

This week in tech bargains, a well-known firm has considerably reduced the price of its portable gaming device, cutting costs by as much as 20 percent, which matches the lowest

Cloudfare Protection

Unbreakable: Cloudflare One Data Protection Suite

Recently, Cloudflare introduced its One Data Protection Suite, an extensive collection of sophisticated security tools designed to protect data in various environments, including web, private, and SaaS applications. The suite

Drone Revolution

Cool Drone Tech Unveiled at London Event

At the DSEI defense event in London, Israeli defense firms exhibited cutting-edge drone technology featuring vertical-takeoff-and-landing (VTOL) abilities while launching two innovative systems that have already been acquired by clients.

2D Semiconductor Revolution

Disrupting Electronics with 2D Semiconductors

The rapid development in electronic devices has created an increasing demand for advanced semiconductors. While silicon has traditionally been the go-to material for such applications, it suffers from certain limitations.

Cisco Growth

Cisco Cuts Jobs To Optimize Growth

Tech giant Cisco Systems Inc. recently unveiled plans to reduce its workforce in two Californian cities, with the goal of optimizing the company’s cost structure. The company has decided to

FAA Authorization

FAA Approves Drone Deliveries

In a significant development for the US drone industry, drone delivery company Zipline has gained Federal Aviation Administration (FAA) authorization, permitting them to operate drones beyond the visual line of

Mortgage Rate Challenges

Prop-Tech Firms Face Mortgage Rate Challenges

The surge in mortgage rates and a subsequent decrease in home buying have presented challenges for prop-tech firms like Divvy Homes, a rent-to-own start-up company. With a previous valuation of

Lighthouse Updates

Microsoft 365 Lighthouse: Powerful Updates

Microsoft has introduced a new update to Microsoft 365 Lighthouse, which includes support for alerts and notifications. This update is designed to give Managed Service Providers (MSPs) increased control and

Website Lock

Mysterious Website Blockage Sparks Concern

Recently, visitors of a well-known resource website encountered a message blocking their access, resulting in disappointment and frustration among its users. While the reason for this limitation remains uncertain, specialists