Package com.databricks.jdbc.api.impl.volume

## 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
`DBFSVolumeClient​(IDatabricksConnectionContext connectionContext)`
`DBFSVolumeClient​(com.databricks.sdk.WorkspaceClient workspaceClient)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()`
`boolean` `deleteObject​(String catalog, String schema, String volume, String objectPath)` Deletes an object from a specified path within a UC Volume.
`org.apache.http.entity.InputStreamEntity` `getObject​(String catalog, String schema, String volume, String objectPath)` Retrieves an object as an input stream from the UC Volume.
`boolean` `getObject​(String catalog, String schema, String volume, String objectPath, String localPath)` Downloads an object (file) from the UC Volume to a local path.
`org.apache.http.entity.InputStreamEntity` `getVolumeOperationInputStream()`
`List<String>` `listObjects​(String catalog, String schema, String volume, String prefix, boolean caseSensitive)` Lists all objects (files) in the UC Volume that start with a specified prefix.
`boolean` `objectExists​(String catalog, String schema, String volume, String objectPath, boolean caseSensitive)` Checks if a specific object (file) exists in the UC Volume.
`boolean` `prefixExists​(String catalog, String schema, String volume, String prefix, boolean caseSensitive)` Checks if a specific prefix (folder-like structure) exists in the UC Volume.
`boolean` `putObject​(String catalog, String schema, String volume, String objectPath, InputStream inputStream, long contentLength, boolean toOverwrite)` Uploads data from an input stream to a specified path within a UC Volume.
`boolean` `putObject​(String catalog, String schema, String volume, String objectPath, String localPath, boolean toOverwrite)` Uploads data from a local file to a specified path within a UC Volume.
`void` `setVolumeOperationEntityStream​(org.apache.http.HttpEntity httpEntity)`
`boolean` `volumeExists​(String catalog, String schema, String volumeName, boolean caseSensitive)` Checks if a specific volume exists in the given catalog and schema.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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 SQLException

Checks if a specific prefix (folder-like structure) exists in the UC Volume. The prefix must be a part of the file name or path.

Specified by:
  `prefixExists` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `prefix` - the prefix to check, including the relative path from the volume root
  `caseSensitive` - whether the prefix check should be case-sensitive
Returns:
  true if the prefix exists, false otherwise
Throws:
  `SQLException` - if a database access error occurs or the volume is inaccessible

#### objectExists

    public boolean objectExists​(String catalog,
                                String schema,
                                String volume,
                                String objectPath,
                                boolean caseSensitive)
                         throws SQLException

Checks if a specific object (file) exists in the UC Volume. The object path must exactly match an existing file.

Specified by:
  `objectExists` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the path of the object from the volume root
  `caseSensitive` - whether the path check should be case-sensitive
Returns:
  true if the object exists, false otherwise
Throws:
  `SQLException` - if a database access error occurs or the volume is inaccessible

#### volumeExists

    public boolean volumeExists​(String catalog,
                                String schema,
                                String volumeName,
                                boolean caseSensitive)
                         throws SQLException

Checks if a specific volume exists in the given catalog and schema. The volume name must match exactly.

Specified by:
  `volumeExists` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volumeName` - the name of the volume to check
  `caseSensitive` - whether the volume name check should be case-sensitive
Returns:
  true if the volume exists, false otherwise
Throws:
  `SQLException` - if a database access error occurs

#### listObjects

    public List<String> listObjects​(String catalog,
                                    String schema,
                                    String volume,
                                    String prefix,
                                    boolean caseSensitive)
                             throws SQLException

Lists all objects (files) in the UC Volume that start with a specified prefix. The prefix must be a part of the file path from the volume root.

Specified by:
  `listObjects` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `prefix` - the prefix to filter objects by, including the relative path from volume root
  `caseSensitive` - whether the prefix matching should be case-sensitive
Returns:
  a list of object paths that match the specified prefix
Throws:
  `SQLException` - if a database access error occurs or the volume is inaccessible

#### getObject

    public boolean getObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             String localPath)
                      throws DatabricksVolumeOperationException

Downloads an object (file) from the UC Volume to a local path.

Specified by:
  `getObject` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the path of the object in the volume
  `localPath` - the local filesystem path where the object should be saved
Returns:
  true if the download was successful, false otherwise
Throws:
  `DatabricksVolumeOperationException`

#### getObject

    public org.apache.http.entity.InputStreamEntity getObject​(String catalog,
                                                              String schema,
                                                              String volume,
                                                              String objectPath)
                                                       throws DatabricksVolumeOperationException

Retrieves an object as an input stream from the UC Volume. The caller is responsible for closing the returned input stream.

Specified by:
  `getObject` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the path of the object in the volume
Returns:
  an InputStreamEntity containing the object's data
Throws:
  `DatabricksVolumeOperationException`

#### putObject

    public boolean putObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             String localPath,
                             boolean toOverwrite)
                      throws DatabricksVolumeOperationException

Uploads data from a local file to a specified path within a UC Volume.

Specified by:
  `putObject` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the destination path in the volume where the file should be uploaded
  `localPath` - the local filesystem path of the file to upload
  `toOverwrite` - whether to overwrite the object if it already exists
Returns:
  true if the upload was successful, false otherwise
Throws:
  `DatabricksVolumeOperationException`

#### putObject

    public boolean putObject​(String catalog,
                             String schema,
                             String volume,
                             String objectPath,
                             InputStream inputStream,
                             long contentLength,
                             boolean toOverwrite)
                      throws DatabricksVolumeOperationException

Uploads data from an input stream to a specified path within a UC Volume.

Specified by:
  `putObject` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the destination path in the volume where the data should be uploaded
  `inputStream` - the input stream containing the data to upload
  `contentLength` - the length of the data in bytes
  `toOverwrite` - whether to overwrite the object if it already exists
Returns:
  true if the upload was successful, false otherwise
Throws:
  `DatabricksVolumeOperationException`

#### deleteObject

    public boolean deleteObject​(String catalog,
                                String schema,
                                String volume,
                                String objectPath)
                         throws DatabricksVolumeOperationException

Deletes an object from a specified path within a UC Volume.

Specified by:
  `deleteObject` in interface `IDatabricksVolumeClient`
Parameters:
  `catalog` - the catalog name in Unity Catalog
  `schema` - the schema name in the specified catalog
  `volume` - the volume name in the specified schema
  `objectPath` - the path of the object to delete
Returns:
  true if the deletion was successful, false otherwise
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:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`