如何使用Databricks FileStore中的文件 [英] How to use file from Databricks FileStore
本文介绍了如何使用Databricks FileStore中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试使用.dat
文件进行ip查找.文件位于Scala代码中的Databricks文件存储中:
Trying to use a .dat
file for ip lookup. File is on Databricks file store from Scala code:
def getCountryCode(ip: String) {
val filePath = "FileStore/maxmind/GeoIPCountry.dat"
val ipLookups = new IpLookups(geoFile = Option(new File(filePath)),
ispFile = None, orgFile = None, domainFile = None, memCache = false, lruCache = 0)
val location = ipLookups.performLookups(ip)._1.head
println(location.countryCode)
}
我遇到一个例外:
java.io.FileNotFoundException: FileStore/maxmind/GeoIPCountry.dat (No such file or directory)
该方法适用于具有相对/绝对路径的本地环境
Method works on local environment with relative/absolute paths
推荐答案
使用FUSE挂载的文件系统上文件的标准路径:
Use fully qualified path to the file on the FUSE mounted file system:
val filePath = "/dbfs/FileStore/maxmind/GeoIPCountry.dat"
参考:使用本地文件I/O API .
这篇关于如何使用Databricks FileStore中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文