Package net.snowflake.client.core.bind
Class BindUploader
- java.lang.Object
-
- net.snowflake.client.core.bind.BindUploader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class BindUploader extends Object implements Closeable
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
arrayBindValueCount(Map<String,ParameterBindingDTO> bindValues)
Compute the number of array bind values in the given bind mapvoid
close()
Close uploader, deleting the local temporary directoryint
getFileCount()
Return the number of files that binding data is split into on internal stage.String
getStagePath()
Return the stage path to which binds are uploadedstatic boolean
isArrayBind(Map<String,ParameterBindingDTO> bindValues)
Return whether the bind map uses array bindsstatic BindUploader
newInstance(SFBaseSession session, String stageDir)
Create a new BindUploader which will upload to the given stage path.void
setInputStreamBufferSize(int bufferSize)
Set the approximate maximum size in bytes for a single bind filevoid
upload(Map<String,ParameterBindingDTO> bindValues)
Wrapper around upload() with default compression to true.void
upload(Map<String,ParameterBindingDTO> bindValues, boolean compressData)
Upload bind parameters via streaming.
-
-
-
Method Detail
-
newInstance
public static BindUploader newInstance(SFBaseSession session, String stageDir)
Create a new BindUploader which will upload to the given stage path. Note that no temporary file or directory is created anymore. Instead, streaming uploading is used.- Parameters:
session
- the session to use for uploading bindsstageDir
- the stage path to upload to- Returns:
- BindUploader instance
-
upload
public void upload(Map<String,ParameterBindingDTO> bindValues) throws BindException, SQLException
Wrapper around upload() with default compression to true.- Throws:
BindException
SQLException
-
upload
public void upload(Map<String,ParameterBindingDTO> bindValues, boolean compressData) throws BindException, SQLException
Upload bind parameters via streaming. This replaces previous function upload function where binds were written to a file which was then uploaded with a PUT statement.- Parameters:
bindValues
- the bind map to uploadcompressData
- whether or not to compress data- Throws:
BindException
SQLException
-
close
public void close()
Close uploader, deleting the local temporary directoryThis class can be used in a try-with-resources statement, which ensures that the temporary directory is cleaned up even when exceptions occur
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
setInputStreamBufferSize
public void setInputStreamBufferSize(int bufferSize)
Set the approximate maximum size in bytes for a single bind file- Parameters:
bufferSize
- size in bytes
-
getFileCount
public int getFileCount()
Return the number of files that binding data is split into on internal stage. Used for testing purposes.- Returns:
- number of files that binding data is split into on internal stage
-
getStagePath
public String getStagePath()
Return the stage path to which binds are uploaded- Returns:
- the stage path
-
arrayBindValueCount
public static int arrayBindValueCount(Map<String,ParameterBindingDTO> bindValues)
Compute the number of array bind values in the given bind map- Parameters:
bindValues
- the bind map- Returns:
- 0 if bindValues is null, has no binds, or is not an array bind n otherwise, where n is the number of binds in the array bind
-
isArrayBind
public static boolean isArrayBind(Map<String,ParameterBindingDTO> bindValues)
Return whether the bind map uses array binds- Parameters:
bindValues
- the bind map- Returns:
- whether the bind map uses array binds
-
-