Last active
September 12, 2019 03:55
-
-
Save raymondtay/924f4d389101271fc5ba6825511725fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.databricks | |
import java.io.{File, FileNotFoundException} | |
import com.databricks.backend.daemon.dbutils.{FileInfo, MountInfo} | |
import com.databricks.dbutils_v1.DbfsUtils | |
import io.thalesdigital.common.services.DiskService.logger | |
import org.apache.hadoop.fs.FileSystem | |
trait LocalFileSystem extends DbfsUtils { | |
def cacheFiles(files: String*): Boolean = ??? | |
def cacheTable(tableName: String): Boolean = ??? | |
def cp(from: String,to: String,recurse: Boolean): Boolean = ??? | |
def dbfs: org.apache.hadoop.fs.FileSystem = ??? | |
def head(file: String,maxBytes: Int): String = ??? | |
private def attemptListing(dir: File): Either[Throwable, Seq[FileInfo]] = { | |
Either.cond(dir.exists() && dir.isDirectory, | |
dir.listFiles.map(f => new FileInfo(f.getAbsolutePath, f.getName, f.length())), | |
new FileNotFoundException("Trying to list a non existing file/directory.") | |
) | |
} | |
def ls(dir: String): Seq[FileInfo] = { | |
val d = new File(dir) | |
attemptListing(d) match { | |
case Left(error) => Seq.empty[FileInfo] | |
case Right(files) => files | |
} | |
} | |
def mkdirs(dir: String): Boolean = new File(dir).mkdirs() | |
def mount(source: String,mountPoint: String,encryptionType: String,owner: String,extraConfigs: scala.collection.Map[String,String]): Boolean = ??? | |
def mounts(): Seq[com.databricks.backend.daemon.dbutils.MountInfo] = ??? | |
def mv(from: String,to: String,recurse: Boolean): Boolean = ??? | |
def put(file: String,contents: String,overwrite: Boolean): Boolean = ??? | |
def refreshMounts(): Boolean = ??? | |
def rm(dir: String,recurse: Boolean): Boolean = ??? | |
def uncacheFiles(files: String*): Boolean = ??? | |
def uncacheTable(tableName: String): Boolean = ??? | |
def unmount(mountPoint: String): Boolean = ??? | |
// Members declared in com.databricks.dbutils_v1.WithHelpMethods | |
def help(moduleOrMethod: String): Unit = ??? | |
def help(): Unit = ??? | |
} | |
object LocalFileSystem extends LocalFileSystem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment