[英]Snakebite HDFS touchz not working
我想使用snakebite檢查hdfs目錄中是否存在文件,並創建它是否不存在。 我在這里關注touchz
上的文檔,並像這樣使用它:
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
看到了該文件。
如何使用蛇咬的touchz
?
蛇咬的touchz
生成一個生成器,該生成器在迭代這些值之前不會做任何事情。
因此,您要么必須遍歷touchz
的返回值,要么要對其進行調用list()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.