Class Utils


  • public class Utils
    extends Object
    Contains Ingest related utility functions
    • Constructor Detail

      • Utils

        public Utils()
    • 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 key
        passphrase - private key phrase
        Returns:
        the decrypted private key
      • 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
      • showMemory

        public static void showMemory()
        Util function to show memory usage info and debug memory issue in the SDK
      • getStackTrace

        public static String getStackTrace​(Throwable e)
        Return the stack trace for a given exception