Esempio n. 1
0
 def _delRowsByIdProp(self, iden, prop, valu=None):  # pragma: no cover
     '''
     Delete rows from the storage layer with a given iden & prop, with an
     optional valu constraint.
     '''
     raise s_common.NoSuchImpl(
         name='_delRowsByIdProp',
         mesg='Store does not implement _delRowsByIdProp')
Esempio n. 2
0
 def getSizeByProp(self,
                   prop,
                   valu=None,
                   mintime=None,
                   maxtime=None):  # pragma: no cover
     raise s_common.NoSuchImpl(
         name='getSizeByProp',
         mesg='Store does not implement getSizeByProp')
Esempio n. 3
0
 def _delRowsByProp(self,
                    prop,
                    valu=None,
                    mintime=None,
                    maxtime=None):  # pragma: no cover
     '''
     Delete rows from the storage layer with a given prop and other,
     optional, constraints.
     '''
     raise s_common.NoSuchImpl(
         name='_delRowsByProp',
         mesg='Store does not implement _delRowsByProp')
Esempio n. 4
0
    def getStoreType(self):  # pragma: no cover
        '''
        Get the Store type.

        This may be used by the Cortex to determine what its backing
        store is.

        Returns:
            str: String indicating what the backing storage layer is.
        '''
        raise s_common.NoSuchImpl(name='getStoreType',
                                  mesg='Store does not implement getStoreType')
Esempio n. 5
0
    def _addRows(self, rows):  # pragma: no cover
        '''
        This should perform the actual addition of rows to the storage layer.

        Args:
            rows (list): Rows to add to the Storage layer.

        Returns:
            None
        '''
        raise s_common.NoSuchImpl(name='_addRows',
                                  mesg='Store does not implement _addRows')
Esempio n. 6
0
def iterdata(fd, close_fd=True, **opts):
    '''
    Iterate through the data provided by a file like object.

    Optional parameters may be used to control how the data
    is deserialized.

    Examples:
        The following example show use of the iterdata function.::

            with open('foo.csv','rb') as fd:
                for row in iterdata(fd, format='csv', encoding='utf8'):
                    dostuff(row)

    Args:
        fd (file) : File like object to iterate over.
        close_fd (bool) : Default behavior is to close the fd object.
                          If this is not true, the fd will not be closed.
        **opts (dict): Ingest open directive.  Causes the data in the fd
                       to be parsed according to the 'format' key and any
                       additional arguments.

    Yields:
        An item to process. The type of the item is dependent on the format
        parameters.
    '''
    fmt = opts.get('format', 'lines')
    fopts = fmtopts.get(fmt, {})

    # set default options for format
    for opt, val in fopts.items():
        opts.setdefault(opt, val)

    ncod = opts.get('encoding')
    if ncod is not None:
        fd = codecs.getreader(ncod)(fd)

    fmtr = fmtyielders.get(fmt)
    if fmtr is None:
        raise s_common.NoSuchImpl(name=fmt, knowns=fmtyielders.keys())

    for item in fmtr(fd, opts):
        yield item

    if close_fd:
        fd.close()
Esempio n. 7
0
    def _initCoreStor(self):  # pragma: no cover
        '''
        This is called to initialize any implementation specific resources.

        This is where things like filesystem allocations, DB connections,
        et cetera should be stood up.

        If the Storage layer has additional joinBy* handlers which it needs
        to register (for the purpose of the Cortex.getTufosBy() function),
        it should add them in this function.

        Returns:
            None
        '''
        raise s_common.NoSuchImpl(
            name='_initCoreStor',
            mesg='Store does not implement _initCoreStor')
Esempio n. 8
0
    def getStoreXact(self, size=None, core=None):  # pragma: no cover
        '''
        Get a StoreXact object.

        This is normally called by the getCoreXact function.

        Args:
            size (int): Number of events to cache in the transaction before
                executing them.
            core: Cortex to attach to the transaction.  Required for splice
                event support.

        Returns:
            s_xact.StoreXact: A storage layer specific StoreXact object.
        '''
        raise s_common.NoSuchImpl(name='getStoreXact',
                                  mesg='Store does not implement getStoreXact')
Esempio n. 9
0
    def getRowsByIdProp(self, iden, prop, valu=None):  # pragma: no cover
        '''
        Return rows with the given <iden>,<prop>.

        Args:
            iden (str): Iden to get rows from the storage object for.
            prop (str): Prop to constrain the lift by.
            valu: Optional, value to constrain the lift by.

        Examples:
            Getting rows by iden, prop and doing stuff::

                for row in core.getRowsByIdProp(iden,'foo:bar'):
                    dostuff(row)

        Returns:
            list: List of rows for a given iden, prop, value comtination.
        '''
        raise s_common.NoSuchImpl(
            name='getRowsByIdProp',
            mesg='Store does not implement _getRowsBgetRowsByIdPropyIdProp')
Esempio n. 10
0
def openstore(url, storconf=None, **opts):
    '''
    Opens or creates a Cortex Storage object by URL.

    This does not attempt to open Storage objects over telepath.

    Args:
        url (str): URL which is parsed in order to connect to.
        storconf (dict): Configable options passed to the storage layer.
        **opts (dict): Additional options added to the link tufo from the
            parsed URL.

    Example:
        Opening a object and adding a row::

            tick = s_common.now()
            url = 'sqlite:///./derry.db'
            store = openstore(url)
            store.addRows([('1234', 'syn:test', 'what', tick)])

    Returns:
        synapse.cores.storage.Storage: A storage object implementing a specific backend.

    Raises:
        NoSuchImpl: If the requested protocol has no storage implementation.
    '''
    if not storconf:
        storconf = {}

    link = s_link.chopLinkUrl(url)
    link[1].update(opts)

    ctor = storectors.get(link[0])
    if ctor is None:
        raise s_common.NoSuchImpl(
            name=link[0],
            mesg='No storage ctor registered for {}'.format(link[0]))

    return ctor(link, **storconf)
Esempio n. 11
0
    def getRowsByProp(self,
                      prop,
                      valu=None,
                      mintime=None,
                      maxtime=None,
                      limit=None):  # pragma: no cover
        '''
        Get rows from the Storage layer based on their property value
        and other, optional, constraints.

        Args:
            prop (str): Property to retrieve rows based on.
            valu: Optional, str or integer value to constrain the retrieval by.
            mintime (int): Optional, minimum (inclusive) time to constrain the retrieval by.
            maxtime (int): Optiona, maximum (exclusive) time to constrain the retrieval by.
            limit (int): Maximum number of rows to return.

        Returns:
            list: List of (i, p, v, t) rows.
        '''
        raise s_common.NoSuchImpl(
            name='getRowsByProp',
            mesg='Store does not implement getRowsByProp')
Esempio n. 12
0
    def getRowsById(self, iden):  # pragma: no cover
        '''
        Return all the rows for a given iden.

        Args:
            iden (str): Iden to get rows from the storage object for.

        Examples:
            Getting rows by iden and doing stuff::

                for row in store.getRowsById(iden):
                    stuff()

            Getting rows by iden and making a tufo out of them::

                rows = store.getRowsById(iden)
                tufo = (iden, {p: v for (i, p, v, t) in rows})

        Returns:
            list: List of rows for a given iden.
        '''
        raise s_common.NoSuchImpl(name='getRowsById',
                                  mesg='Store does not implement getRowsById')
Esempio n. 13
0
 def rowsByGe(self, prop, valu, limit=None):  # pragma: no cover
     raise s_common.NoSuchImpl(name='rowsByGe',
                               mesg='Store does not implement rowsByGe')
Esempio n. 14
0
 def _flush(self):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_flush')
Esempio n. 15
0
 def _resize(self, size):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_resize')
Esempio n. 16
0
 def _callSvcMeth(self, name, *args, **kwargs):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_callSvcMethod')
Esempio n. 17
0
 def _getStormCore(self, name=None):
     raise s_common.NoSuchImpl(name='getStormCore')
Esempio n. 18
0
 def _getBlobKeys(self):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_getBlobKeys',
                               mesg='Store does not implement _getBlobKeys')
Esempio n. 19
0
 def _genStoreRows(self, **kwargs):  # pragma: no cover
     raise s_common.NoSuchImpl(
         name='_genStoreRows',
         mesg='Store does not implement _genStoreRows')
Esempio n. 20
0
 def _writeoff(self, offs, byts):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_writeoff')
Esempio n. 21
0
 def _getStormCore(self, name=None):  # pragma: no cover
     raise s_common.NoSuchImpl(name='getStormCore')
Esempio n. 22
0
 def _coreXactBegin(self):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_coreXactBegin')
Esempio n. 23
0
 def _callSvcMeth(self, name, *args, **kwargs):
     raise s_common.NoSuchImpl(name='_callSvcMethod')
Esempio n. 24
0
 def _task_run(self):
     raise s_common.NoSuchImpl(name='_task_run')
Esempio n. 25
0
 def _delRowsById(self, iden):  # pragma: no cover
     '''
     Delete rows from the storage layer with a given iden.
     '''
     raise s_common.NoSuchImpl(name='_delRowsById',
                               mesg='Store does not implement _delRowsById')
Esempio n. 26
0
 def sizeByRange(self, prop, valu, limit=None):  # pragma: no cover
     raise s_common.NoSuchImpl(name='sizeByRange',
                               mesg='Store does not implement sizeByRange')
Esempio n. 27
0
 def _coreXactCommit(self):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_coreXactCommit')
Esempio n. 28
0
 def _joinsByLe(self, prop, valu, limit=None):  # pragma: no cover
     raise s_common.NoSuchImpl(name='joinsByLe',
                               mesg='Store does not implement joinsByLe')
Esempio n. 29
0
 def _stormTufosBy(self, by, prop, valu=None, limit=None):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_stormTufosBy')
Esempio n. 30
0
 def _delBlobValu(self, key):  # pragma: no cover
     raise s_common.NoSuchImpl(name='_delBlobValu',
                               mesg='Store does not implement _delBlobValu')