streamcorpus_pipeline/_kvlayer.py
def get_kvlayer_stream_item_by_doc_id(client, doc_id):
    '''Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`.

    Namely, it returns an iterator over all documents with the given
    docid. The docid should be an md5 hash of the document's abs_url.

    :param client: kvlayer client object
    :type client: :class:`kvlayer.AbstractStorage`
    :param str doc_id: doc id of documents to retrieve
    :return: generator of :class:`streamcorpus.StreamItem`
    '''
    if client is None:
        client = kvlayer.client()
        client.setup_namespace(STREAM_ITEM_TABLE_DEFS,
                               STREAM_ITEM_VALUE_DEFS)
    doc_id_range = make_doc_id_range(doc_id)
    for k, v in client.scan(STREAM_ITEMS_TABLE, doc_id_range):
        if v is not None:
            errors, bytestr = streamcorpus.decrypt_and_uncompress(v)
            yield streamcorpus.deserialize(bytestr)
def get_kvlayer_stream_item_by_doc_id(client, doc_id):
    '''Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`.

    Namely, it returns an iterator over all documents with the given
    docid. The docid should be an md5 hash of the document's abs_url.

    :param client: kvlayer client object
    :type client: :class:`kvlayer.AbstractStorage`
    :param str doc_id: doc id of documents to retrieve
    :return: generator of :class:`streamcorpus.StreamItem`
    '''
    if client is None:
        client = kvlayer.client()
        client.setup_namespace(STREAM_ITEM_TABLE_DEFS,
                               STREAM_ITEM_VALUE_DEFS)
    doc_id_range = make_doc_id_range(doc_id)
    for k, v in client.scan(STREAM_ITEMS_TABLE, doc_id_range):
        if v is not None:
            errors, bytestr = streamcorpus.decrypt_and_uncompress(v)
            yield streamcorpus.deserialize(bytestr)
Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`.

    Namely, it returns an iterator over all documents with the given
    docid. The docid should be an md5 hash of the document's abs_url.

    :param client: kvlayer client object
    :type client: :class:`kvlayer.AbstractStorage`
    :param str doc_id: doc id of documents to retrieve
    :return: generator of :class:`streamcorpus.StreamItem`