A graph of statements held in memory.
|
The MemoryStore is the main storage mechanism for small amounts of data.
Although the MemoryStore inherits from Store, which can be used to group multiple data sources together, it is illegal to call AddSource on a MemoryStore.
Here are some examples of using a MemoryStore:
C# Example |
// Load data from mydata.rdf file MemoryStore store = new MemoryStore(new RdfXmlReader("mydata.rdf")); // Add some statements store.Add(new Statement("http://www.mysite.com", "http://purl.org/dc/elements/1.1/title", (Literal)"My Web Site")); store.Add(new Statement("http://www.mysite.com", "http://purl.org/dc/elements/1.1/description", (Literal)"My site is all about me.")); // You can also use Entity and Literal objects Entity othersite = new Entity("http://www.anothersite.com"); Entity dctitle = new Entity("http://purl.org/dc/elements/1.1/title"); store.Add(new Statement(othersite, dctitle, new Literal("Create a literal object.")); // Get the statements back by looping through the store foreach (Statement statement in store) { Console.WriteLine(statement); } // Or by streaming them to a StatementSink using (StatementSink sink = new N3Writer(Console.Out)) store.Write(sink); // You can get statements back selectively by filtering. This just gets // statements about othersite. using (StatementSink sink = new N3Writer(Console.Out)) store.Select(new Statement(othersite, null, null), sink); // And there are some utility functions like this: foreach (Resource res in store.SelectObjects(othersite, dctitle)) { if (res is Literal) // might also be an Entity Console.WriteLine("Other site's title: " + ((Literal)res).Value); } |
See Also: Inherited members from Store.
MemoryStore
() Creates a new empty MemoryStore. |
MemoryStore
(Statement[]) Creates a MemoryStore initialized with the given array of statements. |
Creates a new MemoryStore and reads the data from a StatementSource, which might be a SemWeb.RdfReader, for instance. |
DataSources [read-only] | System.Collections.Generic.IList<SemWeb.SelectableSource> . To be added. (Inherited from Store.) |
Distinct [read-only] | bool . Gets whether the store returns only distinct statments from Select calls. (Inherited from Store.) |
Item
[int]
[read-only]
default property |
Statement . Returns a statement in the store by index. |
StatementCount [read-only] | int . Gets the number of statements in the store. (Inherited from Store.) |
Add
(Statement) Adds a statement to the store. (Inherited from Store.) |
|
AddReasoner
(SemWeb.Inference.Reasoner) Adds inferencing capabilities to the Select and Query methods of this Store. (Inherited from Store.) |
|
AddSource
(SelectableSource) Adds a data source to this store. (Inherited from Store.) |
|
AddSource
(SelectableSource, string) Adds a named data source to this store. (Inherited from Store.) |
|
Clear
() Clears the contents of the store. (Inherited from Store.) |
|
Contains
(Resource) Tests whether the store contains any statements that mention the given resource. (Inherited from Store.) |
|
Contains
(Statement) Returns whether the store contains a statement, or any
statement that matches the template. (Inherited from Store.) |
|
Dispose
() Releases any external resources associated with the Store. (Inherited from Store.) |
|
GetBNodeFromPersistentId
(string) To be added. (Inherited from Store.) |
|
GetEntities
() Returns an array of all entities mentioned in the store. (Inherited from Store.) |
|
GetEntitiesOfType
(Entity) Returns an array of all entities in the store whose type is known to be the given type. (Inherited from Store.) |
|
GetMetas
() Returns an array of all entities used in the Meta field of any statement in the store. (Inherited from Store.) |
|
GetPersistentBNodeId
(BNode) To be added. (Inherited from Store.) |
|
GetPredicates
() Returns an array of all predicates mentioned in the store. (Inherited from Store.) |
|
Import
(StatementSource) Batch copies the contents of a StatementSource into the ModifyableSource contained in the store. (Inherited from Store.) |
|
MetaQuery
(Statement[], SemWeb.Query.QueryOptions) Tests the querying capabilities of the store. (Inherited from Store.) |
|
Query
(Statement[]) Queries the data sources in the Store and returns the resulting variable bindings. (Inherited from Store.) |
|
Query
(Statement[], SemWeb.Query.QueryOptions, SemWeb.Query.QueryResultSink) Queries the store with a simple graph match query. (Inherited from Store.) |
|
Remove
(Statement) Removes statements from the store. (Inherited from Store.) |
|
RemoveAll
(Statement[]) Removes all statements matching an array of templates. (Inherited from Store.) |
|
Replace
(Entity, Entity) Replaces all occurences of one Entity with another Entity. (Inherited from Store.) |
|
Replace
(Statement, Statement) Replaces a single statement with another statement. (Inherited from Store.) |
|
Select
(SelectFilter) Retuns a SemWeb.SelectResult object that represents the result of the corresponding select call with a StatementSink. (Inherited from Store.) |
|
Select
(Statement) Retuns a SemWeb.SelectResult object that represents the result of matching a statement template against the store. (Inherited from Store.) |
|
Select
(StatementSink) Streams all statements in this store into a StatementSink. (Inherited from Store.) |
|
Select
(SelectFilter, StatementSink) Queries the story for matching statements, with advanced options, and writes the statements to a SemWeb.StatementSink. (Inherited from Store.) |
|
Select
(Statement, StatementSink) Queries the story for matching statements, and writes the statements to a SemWeb.StatementSink. (Inherited from Store.) |
|
SelectObjects
(Entity, Entity) Finds all objects in statements with the given subject and predicate. (Inherited from Store.) |
|
SelectSubjects
(Entity, Resource) Finds all subjects in statements with the given predicate and object. (Inherited from Store.) |
|
ToArray
() Returns the contents of the store as an array of Statements. |
|
Write
(System.IO.TextWriter) Writes the contents of the store to a stream in N3 format. (Inherited from Store.) |
Creates a new empty MemoryStore.
Creates a new MemoryStore and reads the data from a StatementSource, which might be a SemWeb.RdfReader, for instance.
Returns the contents of the store as an array of Statements.
This is the default property for this class.
Returns a statement in the store by index.
Creates a MemoryStore initialized with the given array of statements.