def testSequenceAddAndRetrieveAndRemove(self):
     st = NDBStore(identifier = 'banana')
     for index in range(len(_TRIPLES)):
         st.add(_TRIPLES[index], None)
         self.assertEquals(1, len(st))
         self._assertSameSet(_TRIPLES[index:index+1], st.triples((None, None, None), None))
         st.remove(_TRIPLES[index], None)
         self.assertEquals(0, len(st))
         self._assertSameSet([], st.triples((None, None, None), None))
Example #2
0
def connect(identifier):
    '''Encapsulates common configuration for Graphs stored in NDB
       @param identifier : ID of the stored Graph to access, example: "default"
       @return: An NDBStore for accessing the given Graph
    '''
    if identifier not in ['metrics', 'default', 'newdata']:
        logging.warn('Unexpected graph identifier: {}'.format(identifier))
    if identifier not in ['default', 'newdata']:
        return NDBStore(identifier=identifier,
                        configuration=_STANDARD_CONFIGURATION)
    if _max_timestamp(_B) > _max_timestamp(_A):
        default = _B
        newdata = _A
    else:
        default = _A
        newdata = _B
    if identifier == 'default':
        return default
    assert identifier == 'newdata'
    return newdata
 def testDestroy(self):
     st = NDBStore(identifier = 'banana')
     st.addN([(s, p, o, None) for (s, p, o) in _TRIPLES])
     st.destroy(None)
     self._assertSameSet(set(), st.triples((None, None, None), None))
 def testTriples(self):
     st = NDBStore(identifier = 'banana')
     st.addN([(s, p, o, None) for (s, p, o) in _TRIPLES])
     patterns = itertools.product(*zip(_TRIPLES[0], _TRIPLES[-1], [None, None, None]))
     for pattern in patterns:
         self._assertSameMatches(st, pattern)
 def testAddN(self):
     st = NDBStore(identifier = 'banana')
     st.addN([(s, p, o, None) for (s, p, o) in _TRIPLES])
     self.assertEquals(len(_TRIPLES), len(st))
     self._assertSameSet(_TRIPLES, st.triples((None, None, None), None))
 def testSingleAddAndRetrieve(self):
     st = NDBStore(identifier = 'banana')
     st.add(_TRIPLES[0], None)
     self.assertEquals(1, len(st))
     self._assertSameSet(_TRIPLES[0:1], st.triples((None, None, None), None))
Example #7
0
@author: Niels Christensen
'''
from rdflib_appengine.ndbstore import NDBStore
from rdflib import Graph
from dotruralsepake.rdf.ontology import SEPAKE, SEPAKEMETRICS
import logging
from datetime import datetime

_STANDARD_CONFIGURATION = {
    'no_of_shards_per_predicate_dict': {
        SEPAKE.htmlDescription: 16,
        SEPAKEMETRICS.focushit: 16
    },
}

_A = NDBStore(identifier='A', configuration=_STANDARD_CONFIGURATION)
_B = NDBStore(identifier='B', configuration=_STANDARD_CONFIGURATION)


def connect(identifier):
    '''Encapsulates common configuration for Graphs stored in NDB
       @param identifier : ID of the stored Graph to access, example: "default"
       @return: An NDBStore for accessing the given Graph
    '''
    if identifier not in ['metrics', 'default', 'newdata']:
        logging.warn('Unexpected graph identifier: {}'.format(identifier))
    if identifier not in ['default', 'newdata']:
        return NDBStore(identifier=identifier,
                        configuration=_STANDARD_CONFIGURATION)
    if _max_timestamp(_B) > _max_timestamp(_A):
        default = _B