如何使用 Databricks FileStore 中的文件
How to use file from Databricks FileStore
正在尝试使用 .dat
文件进行 ip 查找。文件位于 Scala 代码的 Databricks 文件存储中:
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)
方法适用于具有 relative/absolute 路径的本地环境
使用 FUSE 安装文件系统上文件的完全限定路径:
val filePath = "/dbfs/FileStore/maxmind/GeoIPCountry.dat"
正在尝试使用 .dat
文件进行 ip 查找。文件位于 Scala 代码的 Databricks 文件存储中:
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)
方法适用于具有 relative/absolute 路径的本地环境
使用 FUSE 安装文件系统上文件的完全限定路径:
val filePath = "/dbfs/FileStore/maxmind/GeoIPCountry.dat"