当前位置: 首页>>代码示例>>Python>>正文


Python Context.saveAsTextFile方法代码示例

本文整理汇总了Python中pysparkling.Context.saveAsTextFile方法的典型用法代码示例。如果您正苦于以下问题:Python Context.saveAsTextFile方法的具体用法?Python Context.saveAsTextFile怎么用?Python Context.saveAsTextFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysparkling.Context的用法示例。


在下文中一共展示了Context.saveAsTextFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_hdfs_file_exists

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_hdfs_file_exists():
    random.seed()

    fn1 = '{}/pysparkling_test_{:d}.txt'.format(
        HDFS_TEST_PATH, random.random() * 999999.0)
    fn2 = '{}/pysparkling_test_{:d}.txt'.format(
        HDFS_TEST_PATH, random.random() * 999999.0)

    rdd = Context().parallelize('Hello World {0}'.format(x) for x in range(10))
    rdd.saveAsTextFile(fn1)

    assert File(fn1).exists() and not File(fn2).exists()
开发者ID:svenkreiss,项目名称:pysparkling,代码行数:14,代码来源:test_textFile.py

示例2: test_gs_textFile_loop

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_gs_textFile_loop():
    random.seed()

    fn = '{}/pysparkling_test_{:d}.txt'.format(
        GS_TEST_PATH, random.random() * 999999.0)

    rdd = Context().parallelize('Line {0}'.format(n) for n in range(200))
    rdd.saveAsTextFile(fn)
    rdd_check = Context().textFile(fn)

    assert (
        rdd.count() == rdd_check.count() and
        all(e1 == e2 for e1, e2 in zip(rdd.collect(), rdd_check.collect()))
    )
开发者ID:svenkreiss,项目名称:pysparkling,代码行数:16,代码来源:test_textFile.py

示例3: test_hdfs_textFile_loop

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_hdfs_textFile_loop():
    random.seed()

    fn = '{}/pysparkling_test_{:d}.txt'.format(
        HDFS_TEST_PATH, random.random() * 999999.0)
    print('HDFS test file: {0}'.format(fn))

    rdd = Context().parallelize('Hello World {0}'.format(x) for x in range(10))
    rdd.saveAsTextFile(fn)
    read_rdd = Context().textFile(fn)
    print(rdd.collect())
    print(read_rdd.collect())
    assert (
        rdd.count() == read_rdd.count() and
        all(r1 == r2 for r1, r2 in zip(rdd.collect(), read_rdd.collect()))
    )
开发者ID:svenkreiss,项目名称:pysparkling,代码行数:18,代码来源:test_textFile.py

示例4: test_hdfs_textFile_loop

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_hdfs_textFile_loop():
    if not HDFS_TEST_PATH:
        raise SkipTest

    random.seed()

    fn = HDFS_TEST_PATH+'/pysparkling_test_{0}.txt'.format(
        int(random.random()*999999.0)
    )

    rdd = Context().parallelize('Hello World {0}'.format(x) for x in range(10))
    rdd.saveAsTextFile(fn)
    read_rdd = Context().textFile(fn)
    assert (
        rdd.count() == read_rdd.count() and
        all(r1 == r2 for r1, r2 in zip(rdd.collect(), read_rdd.collect()))
    )
开发者ID:hvsarma,项目名称:pysparkling,代码行数:19,代码来源:test_textFile.py

示例5: test_hdfs_file_exists

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_hdfs_file_exists():
    if not HDFS_TEST_PATH:
        raise SkipTest

    random.seed()

    fn1 = HDFS_TEST_PATH+'/pysparkling_test_{0}.txt'.format(
        int(random.random()*999999.0)
    )
    fn2 = HDFS_TEST_PATH+'/pysparkling_test_{0}.txt'.format(
        int(random.random()*999999.0)
    )

    rdd = Context().parallelize('Hello World {0}'.format(x) for x in range(10))
    rdd.saveAsTextFile(fn1)

    assert File(fn1).exists() and not File(fn2).exists()
开发者ID:hvsarma,项目名称:pysparkling,代码行数:19,代码来源:test_textFile.py

示例6: test_s3_textFile_loop

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_s3_textFile_loop():
    if not AWS_ACCESS_KEY_ID or not S3_TEST_PATH:
        raise SkipTest

    random.seed()

    fn = S3_TEST_PATH+'/pysparkling_test_{0}.txt'.format(
        int(random.random()*999999.0)
    )

    rdd = Context().parallelize("Line {0}".format(n) for n in range(200))
    rdd.saveAsTextFile(fn)
    rdd_check = Context().textFile(fn)

    assert (
        rdd.count() == rdd_check.count() and
        all(e1 == e2 for e1, e2 in zip(rdd.collect(), rdd_check.collect()))
    )
开发者ID:hvsarma,项目名称:pysparkling,代码行数:20,代码来源:test_textFile.py

示例7: test_gs_textFile_loop

# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import saveAsTextFile [as 别名]
def test_gs_textFile_loop():
    if not OAUTH2_CLIENT_ID or not GS_TEST_PATH:
        raise SkipTest

    random.seed()

    fn = '{}/pysparkling_test_{0}.txt'.format(
        GS_TEST_PATH, int(random.random() * 999999.0)
    )

    rdd = Context().parallelize("Line {0}".format(n) for n in range(200))
    rdd.saveAsTextFile(fn)
    rdd_check = Context().textFile(fn)

    assert (
        rdd.count() == rdd_check.count() and
        all(e1 == e2 for e1, e2 in zip(rdd.collect(), rdd_check.collect()))
    )
开发者ID:alexprengere,项目名称:pysparkling,代码行数:20,代码来源:test_textFile.py


注:本文中的pysparkling.Context.saveAsTextFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。