Class DBFSVolumeClient
- java.lang.Object
-
- com.databricks.jdbc.api.impl.volume.DBFSVolumeClient
-
- All Implemented Interfaces:
IDatabricksVolumeClient,Closeable,AutoCloseable
public class DBFSVolumeClient extends Object implements IDatabricksVolumeClient, Closeable
Implementation of Volume Client that directly calls SQL Exec API for the Volume Operations
-
-
Constructor Summary
Constructors Constructor Description DBFSVolumeClient(IDatabricksConnectionContext connectionContext)DBFSVolumeClient(com.databricks.sdk.WorkspaceClient workspaceClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleandeleteObject(String catalog, String schema, String volume, String objectPath)deleteObject(): Remove an object from a specified path within a UC Volumeorg.apache.http.entity.InputStreamEntitygetObject(String catalog, String schema, String volume, String objectPath)getObject(): Retrieves an object as input stream from the UC VolumebooleangetObject(String catalog, String schema, String volume, String objectPath, String localPath)getObject(): Retrieves an object (file) from the UC Volume and stores it in the local pathorg.apache.http.entity.InputStreamEntitygetVolumeOperationInputStream()List<String>listObjects(String catalog, String schema, String volume, String prefix, boolean caseSensitive)listObjects(): Lists all filenames in the UC Volume that start with a specified prefix.booleanobjectExists(String catalog, String schema, String volume, String objectPath, boolean caseSensitive)objectExists(): Determines if a specific object (file) exists in the UC Volume The object that we are looking for must match the file name exactlybooleanprefixExists(String catalog, String schema, String volume, String prefix, boolean caseSensitive)prefixExists(): Determines if a specific prefix (folder-like structure) exists in the UC Volume The prefix that we are looking for must be a part of the file name.booleanputObject(String catalog, String schema, String volume, String objectPath, InputStream inputStream, long contentLength, boolean toOverwrite)putObject(): Upload data from an input stream to a specified path within a UC Volume.booleanputObject(String catalog, String schema, String volume, String objectPath, String localPath, boolean toOverwrite)putObject(): Upload data from a local path to a specified path within a UC Volume.voidsetVolumeOperationEntityStream(org.apache.http.HttpEntity httpEntity)booleanvolumeExists(String catalog, String schema, String volumeName, boolean caseSensitive)volumeExists(): Determines if a specific volume exists in the given catalog and schema.
-
-
-
Constructor Detail
-
DBFSVolumeClient
public DBFSVolumeClient(com.databricks.sdk.WorkspaceClient workspaceClient)
-
DBFSVolumeClient
public DBFSVolumeClient(IDatabricksConnectionContext connectionContext)
-
-
Method Detail
-
prefixExists
public boolean prefixExists(String catalog, String schema, String volume, String prefix, boolean caseSensitive) throws DatabricksSQLFeatureNotImplementedException
prefixExists(): Determines if a specific prefix (folder-like structure) exists in the UC Volume The prefix that we are looking for must be a part of the file name.- Specified by:
prefixExistsin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageprefix- the prefix to check for existence along with the relative path from the volume as the root directorycaseSensitive- a boolean indicating whether the check should be case-sensitive or not- Returns:
- a boolean indicating whether the prefix exists or not
- Throws:
DatabricksSQLFeatureNotImplementedException
-
objectExists
public boolean objectExists(String catalog, String schema, String volume, String objectPath, boolean caseSensitive) throws DatabricksSQLException
objectExists(): Determines if a specific object (file) exists in the UC Volume The object that we are looking for must match the file name exactly- Specified by:
objectExistsin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the path of the object (file) from the volume as the root directory to check for existence within the volume (inside any sub-folder)caseSensitive- a boolean indicating whether the check should be case-sensitive or not- Returns:
- a boolean indicating whether the object exists or not
- Throws:
DatabricksSQLException
-
volumeExists
public boolean volumeExists(String catalog, String schema, String volumeName, boolean caseSensitive) throws DatabricksSQLException
volumeExists(): Determines if a specific volume exists in the given catalog and schema. The volume that we are looking for must match the volume name exactly.- Specified by:
volumeExistsin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolumeName- the name of the volume to check for existencecaseSensitive- a boolean indicating whether the check should be case-sensitive or not- Returns:
- a boolean indicating whether the volume exists or not
- Throws:
DatabricksSQLException
-
listObjects
public List<String> listObjects(String catalog, String schema, String volume, String prefix, boolean caseSensitive) throws SQLException
listObjects(): Lists all filenames in the UC Volume that start with a specified prefix. The prefix that we are looking for must be a part of the file path from the volume as the root.- Specified by:
listObjectsin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageprefix- the prefix of the filenames to list. This includes the relative path from the volume as the root directorycaseSensitive- a boolean indicating whether the check should be case-sensitive or not- Returns:
- a list of strings indicating the filenames that start with the specified prefix
- Throws:
SQLException
-
getObject
public boolean getObject(String catalog, String schema, String volume, String objectPath, String localPath) throws DatabricksVolumeOperationException
getObject(): Retrieves an object (file) from the UC Volume and stores it in the local path- Specified by:
getObjectin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the path of the object (file) from the volume as the root directorylocalPath- the local path where the retrieved data is to be stored- Returns:
- a boolean value indicating status of the GET operation
- Throws:
DatabricksVolumeOperationException
-
getObject
public org.apache.http.entity.InputStreamEntity getObject(String catalog, String schema, String volume, String objectPath) throws DatabricksVolumeOperationException
getObject(): Retrieves an object as input stream from the UC Volume- Specified by:
getObjectin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the path of the object (file) from the volume as the root directory- Returns:
- an instance of input stream entity
- Throws:
DatabricksVolumeOperationException
-
putObject
public boolean putObject(String catalog, String schema, String volume, String objectPath, String localPath, boolean toOverwrite) throws DatabricksVolumeOperationException
putObject(): Upload data from a local path to a specified path within a UC Volume.- Specified by:
putObjectin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the destination path where the object (file) is to be uploaded from the volume as the root directorylocalPath- the local path from where the data is to be uploadedtoOverwrite- a boolean indicating whether to overwrite the object if it already exists- Returns:
- a boolean value indicating status of the PUT operation
- Throws:
DatabricksVolumeOperationException
-
putObject
public boolean putObject(String catalog, String schema, String volume, String objectPath, InputStream inputStream, long contentLength, boolean toOverwrite) throws DatabricksVolumeOperationException
putObject(): Upload data from an input stream to a specified path within a UC Volume.- Specified by:
putObjectin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the destination path where the object (file) is to be uploaded from the volume as the root directoryinputStream- the input stream from where the data is to be uploadedcontentLength- the length of the input streamtoOverwrite- a boolean indicating whether to overwrite the object if it already exists- Returns:
- a boolean value indicating status of the PUT operation
- Throws:
DatabricksVolumeOperationException
-
deleteObject
public boolean deleteObject(String catalog, String schema, String volume, String objectPath) throws DatabricksVolumeOperationException
deleteObject(): Remove an object from a specified path within a UC Volume- Specified by:
deleteObjectin interfaceIDatabricksVolumeClient- Parameters:
catalog- the catalog name of the cloud storageschema- the schema name of the cloud storagevolume- the UC volume name of the cloud storageobjectPath- the path of the object (file) from the volume as the root directory to delete- Returns:
- a boolean value indicating status of the DELETE operation
- Throws:
DatabricksVolumeOperationException
-
setVolumeOperationEntityStream
public void setVolumeOperationEntityStream(org.apache.http.HttpEntity httpEntity) throws IOException- Throws:
IOException
-
getVolumeOperationInputStream
public org.apache.http.entity.InputStreamEntity getVolumeOperationInputStream()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-