python - Snakebite HDFS touchz 不工作

标签 python hadoop hdfs snakebite

我想使用 snakebite 来检查 hdfs 目录中是否存在文件,如果不存在则创建。我正在关注 touchz here 上的文档并像这样使用它:

def createFile(client):
    if client.test("/user/test/sample.txt", exists=True):
        print "file exists"
    else:
        print "file not exist, create file"
        print client.touchz(["/user/test/sample.txt"])

client = Client(remote_host, 8020, use_trash=False)        
createFile(client)

但是当我去检查时,我没有在 remote_host:/user/test/ 中看到 sample.txt 但是我在使用 hadoop fs -touchz remote_host:/user/test/sample.txt

时看到了文件

如何使用 snakebite 的 touchz

最佳答案

snakebite 的 touchz 生成一个生成器,它在您迭代这些值之前不会执行任何操作。

因此,您要么必须遍历 touchz 的返回值,要么对其调用 list()

关于python - Snakebite HDFS touchz 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40307518/

相关文章:

java - 包含hadoop/*-common.jar仍然是 “java.lang.ClassNotFoundException:org.apache.hadoop.conf.Configuration”

java - 仅一个文件中几个小文件的SequenceFile压缩器

python - jinja2 - 将来自 python 的所有 html 放入一个 PDF(而不是多个)

python - 如何在 keras fit_generator() 中定义 max_queue_size、workers 和 use_multiprocessing?

hadoop - 如何从 Hadoop 序列文件中提取数据?

hdfs - 使用 PyArrow 从 HDFS 读取 Parquet 文件

hadoop - Spring Cloud Dataflow-http |卡夫卡和卡夫卡| hdfs-在HDFS中获取原始消息

python - Django通过外键查询订单(反方向)

python - 无法使用pyttsx3

hadoop - 在配置单元中执行插入覆盖查询时出错