Package net.snowflake.ingest.utils
Class Utils
- java.lang.Object
-
- net.snowflake.ingest.utils.Utils
-
public class Utils extends Object
Contains Ingest related utility functions
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertNotNull(String name, Object value)Assert when the value is nullstatic voidassertStringNotNullOrEmpty(String name, String value)Assert when the String is null or Emptystatic voidcloseAllocator(org.apache.arrow.memory.BufferAllocator alloc)Release any outstanding memory and then close the buffer allocatorstatic StringconstructAccountUrl(String scheme, String host, int port)Construct account url from input schema, host and portstatic KeyPaircreateKeyPairFromPrivateKey(PrivateKey privateKey)Generate key pair object from private keystatic PropertiescreateProperties(Properties inputProp)Create a Properties for snowflake connectionstatic com.codahale.metrics.Timer.ContextcreateTimerContext(com.codahale.metrics.Timer timer)Create a new timer context if input is not nullstatic StringgetStackTrace(Throwable e)Return the stack trace for a given exceptionstatic booleanisNullOrEmpty(String string)Utility function to check whether a string is null or emptystatic PrivateKeyparseEncryptedPrivateKey(String key, String passphrase)Parse an encrypted private keystatic PrivateKeyparsePrivateKey(String key)Parse an unencrypted private keystatic voidshowMemory()Util function to show memory usage info and debug memory issue in the SDKstatic byte[]toByteArray(int value)Convert int value to a byte arraystatic byte[]toByteArray(long value)Convert long value to a byte array
-
-
-
Method Detail
-
assertStringNotNullOrEmpty
public static void assertStringNotNullOrEmpty(String name, String value) throws SFException
Assert when the String is null or Empty- Parameters:
name-value-- Throws:
SFException
-
assertNotNull
public static void assertNotNull(String name, Object value) throws SFException
Assert when the value is null- Parameters:
name-value-- Throws:
SFException
-
createProperties
public static Properties createProperties(Properties inputProp)
Create a Properties for snowflake connection- Parameters:
inputProp- input property map- Returns:
- a Properties instance
-
constructAccountUrl
public static String constructAccountUrl(String scheme, String host, int port)
Construct account url from input schema, host and port
-
parsePrivateKey
public static PrivateKey parsePrivateKey(String key)
Parse an unencrypted private key- Parameters:
key- unencrypted private key- Returns:
- the unencrypted private key
-
parseEncryptedPrivateKey
public static PrivateKey parseEncryptedPrivateKey(String key, String passphrase)
Parse an encrypted private key- Parameters:
key- encrypted private keypassphrase- private key phrase- Returns:
- the decrypted private key
-
createKeyPairFromPrivateKey
public static KeyPair createKeyPairFromPrivateKey(PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException
Generate key pair object from private key- Parameters:
privateKey- private key- Returns:
- a key pair object
- Throws:
NoSuchAlgorithmException- if can't create key factory by using RSA algorithmInvalidKeySpecException- if private key or public key is invalid
-
createTimerContext
public static com.codahale.metrics.Timer.Context createTimerContext(com.codahale.metrics.Timer timer)
Create a new timer context if input is not null
-
toByteArray
public static byte[] toByteArray(long value)
Convert long value to a byte array
-
toByteArray
public static byte[] toByteArray(int value)
Convert int value to a byte array
-
isNullOrEmpty
public static boolean isNullOrEmpty(String string)
Utility function to check whether a string is null or empty
-
closeAllocator
public static void closeAllocator(org.apache.arrow.memory.BufferAllocator alloc)
Release any outstanding memory and then close the buffer allocator
-
showMemory
public static void showMemory()
Util function to show memory usage info and debug memory issue in the SDK
-
-