本文整理汇总了Python中pysparkling.Context.takeSample方法的典型用法代码示例。如果您正苦于以下问题:Python Context.takeSample方法的具体用法?Python Context.takeSample怎么用?Python Context.takeSample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysparkling.Context
的用法示例。
在下文中一共展示了Context.takeSample方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_takeSample_partitions
# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import takeSample [as 别名]
def test_takeSample_partitions():
"""The real test here is that only one partition should be
computed and not the other two. Shown in debug logs."""
my_rdd = Context().parallelize([4, 9, 7, 3, 2, 5], 3)
assert my_rdd.takeSample(1)[0] in [4, 9, 7, 3, 2, 5]
示例2: Context
# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import takeSample [as 别名]
from pysparkling import Context
by_subject_rdd = Context().textFile(
's3n://human-microbiome-project/DEMO/HM16STR/46333/by_subject/*'
)
print(by_subject_rdd.takeSample(1))
示例3: test_takeSample
# 需要导入模块: from pysparkling import Context [as 别名]
# 或者: from pysparkling.Context import takeSample [as 别名]
def test_takeSample():
my_rdd = Context().parallelize([4, 7, 2])
assert my_rdd.takeSample(1)[0] in [4, 7, 2]