Skip to content

Instantly share code, notes, and snippets.

@raymondtay
Last active September 12, 2019 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymondtay/924f4d389101271fc5ba6825511725fe to your computer and use it in GitHub Desktop.
Save raymondtay/924f4d389101271fc5ba6825511725fe to your computer and use it in GitHub Desktop.
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