Class: Reddy::MemoryStore
- Inherits:
-
AbstractStore
- Object
- AbstractStore
- Reddy::MemoryStore
- Defined in:
- lib/reddy/store/memory_store.rb
Overview
An integer-key-optimized-context-aware-in-memory store.
Uses nested dictionaries to store triples and context. Each triple is stored in six such indices as follows cspo[s][o] = 1 and cpos[p][s] = 1 and cosp[o][p] = 1 as well as spo[p] = [c] and pos[o] = [c] and pos[s] = [c]
Context information is used to track the ‘source’ of the triple data for merging, unmerging, remerging purposes. context aware store stores consume more memory size than non context stores.
Querying or removing triples using the store identifier (or nil) as context operate across all contexts within the store; otherwise, operations are specifiec to the specified context.
Based on Python RdfLib IOMemory
Instance Attribute Summary collapse
-
#default_context ⇒ Object
Returns the value of attribute default_context.
Attributes inherited from AbstractStore
Instance Method Summary collapse
-
#context_aware? ⇒ Boolean
Supports contexts.
-
#formula_aware? ⇒ Boolean
Supports formulae.
-
#initialize(identifier = nil, configuration = {}) ⇒ MemoryStore
constructor
A new instance of MemoryStore.
Methods inherited from AbstractStore
#bind, #bnodes, context_aware?, formula_aware?, #inspect, #item, #namespace, #objects, #predicates, #prefix, #size, #subjects
Constructor Details
#initialize(identifier = nil, configuration = {}) ⇒ MemoryStore
Returns a new instance of MemoryStore.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/reddy/store/memory_store.rb', line 27 def initialize(identifier = nil, configuration = {}) super # indexed by [context][subject][predicate][object] = 1 @cspo = {} # indexed by [context][predicate][object][subject] = 1 @cpos = {} # indexed by [context][object][subject][predicate] = 1 @cosp = {} # indexed by [subject][predicate][object] = [context] @spo = {} # indexed by [predicate][object][subject] = [context] @pos = {} # indexed by [object][subject][predicate] = [context] @osp = {} # indexes integer keys to identifiers @forward = {} # reverse index of forward @reverse = {} end |
Instance Attribute Details
#default_context ⇒ Object
Returns the value of attribute default_context.
19 20 21 |
# File 'lib/reddy/store/memory_store.rb', line 19 def default_context @default_context end |
Instance Method Details
#context_aware? ⇒ Boolean
Supports contexts
22 |
# File 'lib/reddy/store/memory_store.rb', line 22 def context_aware?; true; end |
#formula_aware? ⇒ Boolean
Supports formulae
25 |
# File 'lib/reddy/store/memory_store.rb', line 25 def formula_aware?; true; end |