The store class is used to group data sources and to provide inferencing capabilities over data sources.
|
See Also: Inherited members from object.
Store
() Creates an empty store with no data storage backing. |
Creates a store that wraps the given SelectableSource. |
Creates a Store that loads the statements from the StatementSource into memory. |
DataSources [read-only] | System.Collections.Generic.IList<SemWeb.SelectableSource> . To be added. |
Distinct [read-only] | bool . Gets whether the store returns only distinct statments from Select calls. |
StatementCount [read-only] | int . Gets the number of statements in the store. |
Add
(Statement) Adds a statement to the store. |
|
AddReasoner
(SemWeb.Inference.Reasoner) Adds inferencing capabilities to the Select and Query methods of this Store. |
|
AddSource
(SelectableSource) Adds a data source to this store. |
|
AddSource
(SelectableSource, string) Adds a named data source to this store. |
|
Clear
() Clears the contents of the store. |
|
Contains
(Resource) Tests whether the store contains any statements that mention the given resource. |
|
Contains
(Statement) Returns whether the store contains a statement, or any
statement that matches the template. |
|
static |
Create
(string) Creates a Store in the factory design pattern. |
static |
CreateForInput
(string) Creates a StatementSource in the factory design pattern from which statements will be read. |
static |
CreateForOutput
(string) Creates a SemWeb.StatementSink into which statements will be added. |
static |
DefaultContains
(SelectableSource, Statement) A default implementation of the Contains operation for implementors of SelectableSource. |
static |
DefaultReplace
(ModifiableSource, Entity, Entity) To be added. |
static |
DefaultReplace
(ModifiableSource, Statement, Statement) To be added. |
static |
DefaultSelect
(SelectableSource, SelectFilter, StatementSink) This method provides a default implementation of the Select method that takes a SelectFilter argument. |
Dispose
() Releases any external resources associated with the Store. |
|
GetBNodeFromPersistentId
(string) To be added. |
|
GetEntities
() Returns an array of all entities mentioned in the store. |
|
GetEntitiesOfType
(Entity) Returns an array of all entities in the store whose type is known to be the given type. |
|
GetMetas
() Returns an array of all entities used in the Meta field of any statement in the store. |
|
GetPersistentBNodeId
(BNode) To be added. |
|
GetPredicates
() Returns an array of all predicates mentioned in the store. |
|
Import
(StatementSource) Batch copies the contents of a StatementSource into the ModifyableSource contained in the store. |
|
MetaQuery
(Statement[], SemWeb.Query.QueryOptions) Tests the querying capabilities of the store. |
|
Query
(Statement[]) Queries the data sources in the Store and returns the resulting variable bindings. |
|
Query
(Statement[], SemWeb.Query.QueryOptions, SemWeb.Query.QueryResultSink) Queries the store with a simple graph match query. |
|
Remove
(Statement) Removes statements from the store. |
|
RemoveAll
(Statement[]) Removes all statements matching an array of templates. |
|
Replace
(Entity, Entity) Replaces all occurences of one Entity with another Entity. |
|
Replace
(Statement, Statement) Replaces a single statement with another statement. |
|
Select
(SelectFilter) Retuns a SemWeb.SelectResult object that represents the result of the corresponding select call with a StatementSink. |
|
Select
(Statement) Retuns a SemWeb.SelectResult object that represents the result of matching a statement template against the store. |
|
Select
(StatementSink) Streams all statements in this store into a StatementSink. |
|
Select
(SelectFilter, StatementSink) Queries the story for matching statements, with advanced options, and writes the statements to a SemWeb.StatementSink. |
|
Select
(Statement, StatementSink) Queries the story for matching statements, and writes the statements to a SemWeb.StatementSink. |
|
SelectObjects
(Entity, Entity) Finds all objects in statements with the given subject and predicate. |
|
SelectSubjects
(Entity, Resource) Finds all subjects in statements with the given predicate and object. |
|
Write
(System.IO.TextWriter) Writes the contents of the store to a stream in N3 format. |
Clears the contents of the store.
Returns an array of all entities in the store whose type is known to be the given type.
Adds a statement to the store.
The Subject, Predicate, Object, and Meta fields of the statement must not be null or an ArgumentNullException is thrown.
An InvalidOperationException is thrown if more than one data source has been added to the Store with AddSource (in which case SemWeb would not know which data source to add the statement to) or if the data source added is not a SemWeb.ModifiableSource.
Removes statements from the store.
Batch copies the contents of a StatementSource into the ModifyableSource contained in the store.
An InvalidOperationException is thrown if more than one data source has been added to the Store with AddSource or if the data source added is not a SemWeb.ModifiableSource.
Returns whether the store contains a statement, or any statement that matches the template.
Queries the story for matching statements, and writes the statements to a SemWeb.StatementSink.
Finds all objects in statements with the given subject and predicate.
Note:
This method is not recommended when the store can contain a large number of statements, as every matching entity must be loaded into memory before this method returns.
Finds all subjects in statements with the given predicate and object.
Note:
This method is not recommended when the store can contain a large number of statements, as every matching entity must be loaded into memory before this method returns.
Gets the number of statements in the store.
Writes the contents of the store to a stream in N3 format.
Returns an array of all entities mentioned in the store.
Returns an array of all predicates mentioned in the store.
Replaces all occurences of one Entity with another Entity.
All occurences of find in statements in the Store are replaced with references to replacement.
An InvalidOperationException is thrown if any data source added to the Store with AddSource does not implement SemWeb.ModifiableSource.
Creates an empty store with no data storage backing.
Creates a StatementSource in the factory design pattern from which statements will be read.
The specifier string is in one of the following formats. When a filename is expected, a dash can be used to indicate standard input.
spec | Meaning |
---|---|
mem | A new SemWeb.MemoryStore. |
xml:[filename] | A SemWeb.RdfXmlReader to read the RDF/XML file. Example: "xml:mydata.rdf" |
n3:[filename] turtle:[filename] nt:[filename] ntriples:[filename] |
A SemWeb.N3Reader to read the N3/Turtle/NTriples file. Example: "n3:mydata.n3" |
sqlite:[table]:[connection string] |
A SemWeb.Stores.SQLStore connected to the SQLite database given in the connection string, using the tables prefixed by the table parameter. The returned store can be both read from and written to, despite the name of this method. Example: "sqlite:rdf:Uri=file:mydatabase.sqlite;Version=3" |
mysql:[table]:[connection string] | A SemWeb.Stores.SQLStore connected to the MySQL database given in the connection string, using the tables prefixed by the table parameter. The returned store can be both read from and written to, despite the name of this method. Example: "mysql:rdf:Database=databasename;Server=localhost;User Id=username" |
postgresql:[table]:[connection string] | A SemWeb.Stores.SQLStore connected to the PostgreSQL database given in the connection string, using the tables prefixed by the table parameter. The returned store can be both read from and written to, despite the name of this method. Example: "postgresql:rdf:Server=localhost;Port=5432;Database=SemanticWeb;User Id=user" |
sparql-http:[URL] | A SemWeb.Remote.SparqlHttpSource, which accesses a remote data source using the SPARQL Protocol. Example: "sparql-http:http://www.govtrack.us/sparql" |
The SQL stores can be both read from and written to, despite the name of this method.
Creates a SemWeb.StatementSink into which statements will be added.
The specifier string is in one of the following formats. When a filename is expected, a dash can be used to indicate standard output.
spec | Meaning |
---|---|
mem | A new SemWeb.MemoryStore. |
xml:[filename] | A SemWeb.RdfXmlWriter opened on the given file. Example: "xml:mydata.rdf" |
n3:[filename] turtle:[filename] nt:[filename] ntriples:[filename] |
A SemWeb.N3Writer opened on the given file, writing in the indicated format. Example: "turtle:mydata.turtle" |
SQL-based stores | For Sqlite, MySQL, and PostgreSQL-based stores, use the spec string described in SemWeb.Store.CreateForInput(string). These stores can be both read from and written to, despite the name of this method. |
Retuns a SemWeb.SelectResult object that represents the result of matching a statement template against the store.
On calling this method, the data in this store is not immediately accessed. The matching statements are loaded the first time they are requested through the returned SemWeb.SelectResult object. Those statements are accessed in one of three ways:
SemWeb.SelectResult implements IEnumerable, so the result object can be used in foreach loops, shown in this example:
C# Example |
foreach (Statement s in mystore.Select(Statement.All)) { Console.WriteLine(s.ToString()); } |
The drawback of this method is that all of the matching statements are loaded into memory before the loop begins, and so this method is not recommended when the number of matching statements may be very large.
The SemWeb.SelectResult.Load() method loads all of the matching statements into a SemWeb.MemoryStore. The MemoryStore can then be used to perform further Selects, or to get the matching statements as an array. This method is not advised when the number of matching statements may be very large.
SemWeb.SelectResult implements SemWeb.StatementSource, and the SemWeb.StatementSource.Select(SemWeb.StatementSink) method on the returned object will stream the matching statements directly from this store to the provided SemWeb.StatementSink without keeping the statements in memory.
template is a statement template, which means any field in template may be null, and those fields are excluded from the statement filter. For example, setting the Subject and Predicate fields but leaving the Object and Meta fields null will match all statements in the store that have the given Subject and Predicate, and anything in their Object and Meta fields.
Streams all statements in this store into a StatementSink.
Replaces a single statement with another statement.
Store implementations may choose to optimize this method over a call to Remove followed by Add.
An InvalidOperationException is thrown if any data source added to the Store with AddSource does not implement SemWeb.ModifiableSource.
Returns an array of all entities used in the Meta field of any statement in the store.
Removes all statements matching an array of templates.
Releases any external resources associated with the Store.
A default implementation of the Contains operation for implementors of SelectableSource.
Gets whether the store returns only distinct statments from Select calls.
Queries the story for matching statements, with advanced options, and writes the statements to a SemWeb.StatementSink.
Retuns a SemWeb.SelectResult object that represents the result of the corresponding select call with a StatementSink.
This method provides a default implementation of the Select method that takes a SelectFilter argument.
Tests whether the store contains any statements that mention the given resource.
Tests the querying capabilities of the store.
Queries the store with a simple graph match query.
Creates a store that wraps the given SelectableSource.
Creates a Store that loads the statements from the StatementSource into memory.
Adds inferencing capabilities to the Select and Query methods of this Store.
Adds a data source to this store.
Adds a named data source to this store.
The data source is added to the store and is identified by uri. An ArgumentException is thrown if uri has already been used in a previous call to this method.
In calls to Contains(Statement), Select, Add, Remove, RemoveAll, and Replace(Statement,Statement), the Meta field of the statement argument is used to choose which data source added with AddSource to query for information. When the supplied Meta field is null or when no named data sources have been added to the Store through a call to this method, all data sources are queried. However, when named data sources have been added with this method and the supplied Meta field is SemWeb.Statement.DefaultMeta, only unnamed data sources added through the other AddSource method (SemWeb.Store.AddSource(SemWeb.SelectableSource)) are queried, and when the supplied SemWeb.Statement.DefaultMeta's URI matches the URI of a named data source added through this method, only that data source is queried.
Creates a Store in the factory design pattern.
spec is a newline- or pipe- ("|") delimited string of specification strings to be passed to SemWeb.Store.CreateForInput(string).
For each of those substrings, SemWeb.Store.CreateForInput(string) is called on that string. If the result is a SemWeb.SelectableSource, it is added to the returned Store with AddSource. If the data source is a SemWeb.StatementSource but not a SemWeb.SelectableSource, like an SemWeb.RdfReader, the contents of the data source are first loaded into a SemWeb.MemoryStore and the SemWeb.MemoryStore is then added to the Store to be returned.
In addition, spec can be prefixed with "rdfs+" so that an SemWeb.Inference.RDFS reasoning engine is added to the Store with AddReasoner.
The following are example specification strings:
Example |
mysql:rdf:Database=databasename;Server=localhost;User Id=username (creates a Store around a SQLStore) rdfs+mysql:rdf:Database=databasename;Server=localhost;User Id=username (creates a Store around an SQLStore and applies RDFS reasoning) n3:filename.n3 (loads the file into memory and returns a Store containing the data) n3:file1.n3|n3:file2.n3|... (loads each of the files into memory and returns a Store containing all of them) |
To be added.
To be added.
To be added.
To be added.
Queries the data sources in the Store and returns the resulting variable bindings.
To be added.