コード例 #1
0
ファイル: scheme_raw.py プロジェクト: christofd/disco
def input_stream(fd, sze, url, params):
    """Opens a StringIO whose data is everything after the url scheme.

    For example, `raw://hello_world` would return `hello_world` when read by the task.
    """
    scheme, string = schemesplit(url)
    return (StringIO(string), len(string), url)
コード例 #2
0
def input_stream(fd, sze, url, params):
    """Opens a StringIO whose data is everything after the url scheme.

    For example, `raw://hello_world` would return `hello_world` when read by the task.
    """
    from cStringIO import StringIO
    from disco.util import schemesplit
    scheme, string = schemesplit(url)
    return (StringIO(string), len(string), url)
コード例 #3
0
ファイル: scheme_raw.py プロジェクト: AlexArgus/disco
def input_stream(fd, sze, url, params):
    """Opens a StringIO whose data is everything after the url scheme.

    For example, `raw://hello_world` would return `hello_world` when read by the task.
    """
    from disco.compat import StringIO, bytes_to_str
    from disco.util import schemesplit
    scheme, string = schemesplit(url)
    ascii = bytes_to_str(string)
    return (StringIO(ascii), len(ascii), url)
コード例 #4
0
ファイル: scheme_redis.py プロジェクト: AlexArgus/disco
 def __init__(self, path, redis_url):
     _redis_scheme, rest = schemesplit(redis_url)
     host, port, dbid = rest.split(":")
     self.redis = redis.StrictRedis(host=host, port=port, db=dbid)
     self.redis.flushdb()
     self.cursor = '0'
     self.url = redis_url
     from collections import defaultdict
     self.Dict = defaultdict(list)
     super(AtomicDict, self).__init__(path, 'w')
     self.write(redis_url + "\n")
コード例 #5
0
 def __init__(self, path, redis_url):
     _redis_scheme, rest = schemesplit(redis_url)
     host, port, dbid = rest.split(":")
     self.redis = redis.StrictRedis(host=host, port=port, db=dbid)
     self.redis.flushdb()
     self.cursor = '0'
     self.url = redis_url
     from collections import defaultdict
     self.Dict = defaultdict(list)
     super(AtomicDict, self).__init__(path, 'w')
     self.write(redis_url + "\n")
コード例 #6
0
def map_input_stream(stream, size, url, params):
    """
    An :func:`input_stream` which looks at the scheme of ``url``
    and tries to import a function named ``input_stream``
    from the module ``disco.schemes.scheme_SCHEME``,
    where SCHEME is the parsed scheme.
    If no scheme is found in the url, ``file`` is used.
    The resulting input stream is then used.
    """
    from disco.util import schemesplit
    scheme, _url = schemesplit(url)
    scheme_ = 'scheme_%s' % (scheme or 'file')
    mod = __import__('disco.schemes.%s' % scheme_, fromlist=[scheme_])
    Task.insert_globals([mod.input_stream])
    return mod.input_stream(stream, size, url, params)
コード例 #7
0
ファイル: func.py プロジェクト: JensRantil/disco
def map_input_stream(stream, size, url, params):
    """
    An :func:`input_stream` which looks at the scheme of ``url``
    and tries to import a function named ``input_stream``
    from the module ``disco.schemes.scheme_SCHEME``,
    where SCHEME is the parsed scheme.
    If no scheme is found in the url, ``file`` is used.
    The resulting input stream is then used.
    """
    from disco.util import schemesplit
    scheme, _url = schemesplit(url)
    scheme_ = 'scheme_%s' % (scheme or 'file')
    mod = __import__('disco.schemes.%s' % scheme_, fromlist=[scheme_])
    Task.insert_globals([mod.input_stream])
    return mod.input_stream(stream, size, url, params)
コード例 #8
0
ファイル: scheme_redis.py プロジェクト: AlexArgus/disco
 def __init__(self, url):
     _redis_scheme, rest = schemesplit(url)
     host, port, dbid = rest.split(":")
     self.redis = redis.StrictRedis(host=host, port=port, db=dbid)
     self.cursor = '0'
     self.url = url
コード例 #9
0
def open_url(url, *args, **kwargs):
    from disco.util import schemesplit
    scheme, rest = schemesplit(url)
    if not scheme or scheme == 'file':
        return open_local(rest, *args, **kwargs)
    return open_remote(url, *args, **kwargs)
コード例 #10
0
ファイル: __init__.py プロジェクト: Dieterbe/disco
def import_scheme(url):
    scheme, _rest = util.schemesplit(url)
    scheme = 'scheme_%s' % (scheme or 'file')
    return __import__('disco.schemes.%s' % scheme, fromlist=[scheme])
コード例 #11
0
ファイル: scheme_file.py プロジェクト: jamesaimonetti/disco
def input_stream(fd, size, url, params):
    """Opens the url locally on the node."""
    scheme, path = schemesplit(url)
    return open_local(path, url)
コード例 #12
0
def open(url, task=None):
    _hdfs_scheme, address = schemesplit(url)
    namenode_port, rest = schemesplit(address)
    http_url = 'http://' + namenode_port + '/webhdfs/v1/' + rest + '?op=OPEN'
    return comm.open_url(http_url)
コード例 #13
0
def import_scheme(url):
    scheme, _rest = util.schemesplit(url)
    scheme = 'scheme_%s' % (scheme or 'file')
    return __import__('disco.schemes.%s' % scheme, fromlist=[scheme])
コード例 #14
0
ファイル: __init__.py プロジェクト: yuj/disco
def import_scheme(url):
    scheme, _rest = util.schemesplit(url)
    scheme = 'scheme_{0}'.format((scheme or 'file'))
    return __import__('disco.schemes.{0}'.format(scheme), fromlist=[scheme])
コード例 #15
0
def input_stream(fd, size, url, params):
    """Opens the url locally on the node."""
    from disco.comm import open_local
    from disco.util import schemesplit
    scheme, path = schemesplit(url)
    return open_local(path)
コード例 #16
0
ファイル: wordcount_hdfs.py プロジェクト: AlexArgus/disco
def getHdfsMaster(discoMaster):
    from disco.util import schemesplit
    _, rest = schemesplit(discoMaster)
    return rest.split(':')[0] + ':50070'
コード例 #17
0
ファイル: comm.py プロジェクト: tsloughter/disco
def open_url(url, *args, **kwargs):
    from disco.util import schemesplit
    scheme, rest = schemesplit(url)
    if not scheme or scheme == 'file':
        return open_local(rest, *args, **kwargs)
    return open_remote(url, *args, **kwargs)
コード例 #18
0
def getHdfsMaster(discoMaster):
    from disco.util import schemesplit
    _, rest = schemesplit(discoMaster)
    return rest.split(':')[0] + ':50070'
コード例 #19
0
ファイル: scheme_hdfs.py プロジェクト: AlexArgus/disco
def open(url, task=None):
    _hdfs_scheme, address = schemesplit(url)
    namenode_port, rest = schemesplit(address)
    http_url = 'http://' + namenode_port + '/webhdfs/v1/' + rest + '?op=OPEN'
    return comm.open_url(http_url)
コード例 #20
0
 def __init__(self, url):
     _redis_scheme, rest = schemesplit(url)
     host, port, dbid = rest.split(":")
     self.redis = redis.StrictRedis(host=host, port=port, db=dbid)
     self.cursor = '0'
     self.url = url