<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Java SDK</title>
    <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/</link>
    <description>Recent content in Java SDK on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/extending/developing-udxs/developing-with-sdk/java-sdk/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Extending: Setting up the Java SDK</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/setting-up-java-sdk/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/setting-up-java-sdk/</guid>
      <description>
        
        
        &lt;p&gt;The OpenText™ Analytics Database Java Software Development Kit (SDK) is distributed as part of the server installation. It contains the source and JAR files you need to create your UDx library. For examples that you can compile and run, see &lt;a href=&#34;../../../../../en/extending/developing-udxs/developing-with-sdk/downloading-and-running-udx-example-code/#&#34;&gt;Downloading and running UDx example code&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;p&gt;At a minimum, install the following on your development machine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The Java Development Kit (JDK) version that matches the Java version you have installed on your database hosts (see &lt;a href=&#34;../../../../../en/extending/udxs/installing-java-on-hosts/&#34;&gt;Installing Java on OpenText™ Analytics Database Hosts&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A copy of the OpenText™ Analytics Database SDK.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Optionally, you can simplify development with a build-management tool, such as &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;sdk-files&#34;&gt;SDK files&lt;/h2&gt;
&lt;p&gt;To use the SDK you need two files from the Java support package:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/opt/vertica/bin/VerticaSDK.jar&lt;/code&gt; contains the OpenText™ Analytics Database Java SDK and other supporting files.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;/opt/vertica/sdk/BuildInfo.java&lt;/code&gt; contains version information about the SDK. You must compile this file and include it within your Java UDx JAR files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you are not doing your development on a database node, you can copy these two files from one of the database nodes to your development system.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;BuildInfo.java&lt;/code&gt; and &lt;code&gt;VerticaSDK.jar&lt;/code&gt; files that you use to compile your UDx must be from the same SDK version. Both files must also match the version of the SDK files on your database hosts. Versioning is only an issue if you are not compiling your UDxs on a database host. If you are compiling on a separate development system, always refresh your copies of these two files and recompile your UDxs just before deploying them.&lt;/p&gt;
&lt;h2 id=&#34;finding-the-current-sdk-version&#34;&gt;Finding the current SDK version&lt;/h2&gt;
&lt;p&gt;You must develop your UDx using the same SDK version as the database in which you plan to use it. To display the SDK version currently installed on your system, run the following command in vsql:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT sdk_version();
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;compiling-buildinfojava&#34;&gt;Compiling BuildInfo.java&lt;/h2&gt;
&lt;p&gt;You need to compile the &lt;code&gt;BuildInfo.java&lt;/code&gt; file into a class file, so you can include it in your Java UDx JAR library. If you are using a database node as a development system, you can either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Copy the &lt;code&gt;BuildInfo.java&lt;/code&gt; file to another location on your host.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you have root privileges, compile the &lt;code&gt;BuildInfo.java&lt;/code&gt; file in place. (Only the root user has privileges to write files to the /opt/vertica/sdk directory.)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Compile the file using the following command. Replace &lt;em&gt;&lt;code&gt;path&lt;/code&gt;&lt;/em&gt; with the path to the file and &lt;em&gt;output-directory&lt;/em&gt; with the directory where you will compile your UDxs.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ javac -classpath /opt/vertica/bin/VerticaSDK.jar \
      /&lt;span class=&#34;code-variable&#34;&gt;path&lt;/span&gt;/BuildInfo.java -d &lt;span class=&#34;code-variable&#34;&gt;output-directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you use an IDE such as Eclipse, you can include the &lt;code&gt;BuildInfo.java&lt;/code&gt; file in your project instead of compiling it separately. You must also add the &lt;code&gt;VerticaSDK.jar&lt;/code&gt; file to the project&#39;s build path. See your IDE&#39;s documentation for details on how to include files and libraries in your projects.&lt;/p&gt;
&lt;h2 id=&#34;running-the-examples&#34;&gt;Running the examples&lt;/h2&gt;
&lt;p&gt;You can download the examples from the GitHub repository (see &lt;a href=&#34;../../../../../en/extending/developing-udxs/developing-with-sdk/downloading-and-running-udx-example-code/#&#34;&gt;Downloading and running UDx example code&lt;/a&gt;). Compiling and running the examples helps you to ensure that your development environment is properly set up.&lt;/p&gt;
&lt;p&gt;If you have not already done so, set the JAVA_HOME environment variable to your JDK (not JRE) directory.&lt;/p&gt;
&lt;p&gt;To compile all of the examples, including the Java examples, issue the following command in the &lt;code&gt;Java-and-C++&lt;/code&gt; directory under the examples directory:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ make
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To compile only the Java examples, issue the following command in the &lt;code&gt;Java-and-C++&lt;/code&gt; directory under the examples directory:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ make JavaFunctions
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Extending: Compiling and packaging a Java library</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/compiling-and-packaging-java-library/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/compiling-and-packaging-java-library/</guid>
      <description>
        
        
        &lt;p&gt;Before you can use your Java UDx, you need to compile it and package it into a JAR file.&lt;/p&gt;
&lt;p&gt;The SDK examples include a working makefile. See &lt;a href=&#34;../../../../../en/extending/developing-udxs/developing-with-sdk/downloading-and-running-udx-example-code/#&#34;&gt;Downloading and running UDx example code&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;compile-your-java-udx&#34;&gt;Compile your Java UDx&lt;/h2&gt;
&lt;p&gt;You must include the SDK JAR file in the CLASSPATH when you compile your Java UDx source files so the Java compiler can resolve the OpenText™ Analytics Database API calls. If you are using the command-line Java compiler on a host in your database cluster, enter this command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ javac -classpath /opt/vertica/bin/VerticaSDK.jar &lt;span class=&#34;code-variable&#34;&gt;factorySource&lt;/span&gt;.java \
      [&lt;span class=&#34;code-variable&#34;&gt;functionSource&lt;/span&gt;.java...] -d &lt;span class=&#34;code-variable&#34;&gt;output-directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If all of your source files are in the same directory, you can use &lt;code&gt;*.java&lt;/code&gt; on the command line instead of listing the files individually.&lt;/p&gt;
&lt;p&gt;If you are using an IDE, verify that a copy of the &lt;code&gt;VerticaSDK.jar&lt;/code&gt; file is in the build path.&lt;/p&gt;
&lt;h2 id=&#34;udx-class-file-organization&#34;&gt;UDx class file organization&lt;/h2&gt;
&lt;p&gt;After you compile your UDx, you must package its class files and the &lt;code&gt;BuildInfo.class&lt;/code&gt; file into a JAR file.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

You can package as many UDxs as you want into the same JAR file. Bundling your UDxs together saves you from having to load multiple libraries.

&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;To use the jar command packaged as part of the JDK, you must organize your UDx class files into a directory structure matching your class package structure. For example, suppose your UDx&#39;s factory class has a fully-qualified name of &lt;code&gt;com.mycompany.udfs.Add2ints&lt;/code&gt;. In this case, your class files must be in the directory hierarchy &lt;code&gt;com/mycompany/udfs&lt;/code&gt; relative to your project&#39;s base directory. In addition, you must have a copy of the &lt;code&gt;BuildInfo.class&lt;/code&gt; file in the path &lt;code&gt;com/vertica/sdk&lt;/code&gt; so that it can be included in the JAR file. This class must appear in your JAR file to indicate the SDK version that was used to compile your Java UDx.&lt;/p&gt;
&lt;p&gt;The JAR file for the Add2ints UDSF example has the following directory structure after compilation:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;com/vertica/sdk/BuildInfo.class
com/mycompany/example/Add2intsFactory.class
com/mycompany/example/Add2intsFactory$Add2ints.class
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;package-your-udx-into-a-jar-file&#34;&gt;Package your UDx into a JAR file&lt;/h2&gt;
&lt;p&gt;To create a JAR file from the command line:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Change to the root directory of your project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the jar command to package the &lt;code&gt;BuildInfo.class&lt;/code&gt; file and all of the classes in your UDx:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# jar -cvf &lt;span class=&#34;code-variable&#34;&gt;libname&lt;/span&gt;.jar com/vertica/sdk/BuildInfo.class \
       &lt;span class=&#34;code-variable&#34;&gt;packagePath&lt;/span&gt;/*.class
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you type this command, &lt;em&gt;&lt;code&gt;libname&lt;/code&gt;&lt;/em&gt; is the filename you have chosen for your JAR file (choose whatever name you like), and &lt;em&gt;&lt;code&gt;packagePath&lt;/code&gt;&lt;/em&gt; is the path to the directory containing your UDx&#39;s class files.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For example, to package the files from the Add2ints example, you use the command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# jar -cvf Add2intsLib.jar com/vertica/sdk/BuildInfo.class \
com/mycompany/example/*.class
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;More simply, if you compiled &lt;code&gt;BuildInfo.class&lt;/code&gt; and your class files into the same root directory, you can use the following command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# jar -cvf Add2intsLib.jar .
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You must include all of the class files that make up your UDx in your JAR file. Your UDx always consists of at least two classes (the factory class and the function class). Even if you defined your function class as an inner class of your factory class, Java generates a separate class file for the inner class.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After you package your UDx into a JAR file, you are ready to deploy it to your database.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Extending: Handling Java UDx dependencies</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/handling-java-udx-dependencies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/handling-java-udx-dependencies/</guid>
      <description>
        
        
        &lt;p&gt;If your Java UDx relies on one or more external libraries, you can handle the dependencies in one of three ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Bundle the JAR files into your UDx JAR file using a tool such as &lt;a href=&#34;http://one-jar.sourceforge.net/&#34;&gt;One-JAR&lt;/a&gt; or Eclipse Runnable JAR Export Wizard.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Unpack the JAR file and then repack its contents in your UDx&#39;s JAR file.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy the libraries to your OpenText™ Analytics Database cluster in addition to your UDx library.Then, use the DEPENDS keyword of the &lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-library/#&#34;&gt;CREATE LIBRARY&lt;/a&gt; statement to instruct the database that the UDx library depends on the external libraries. This keyword acts as a library-specific CLASSPATH setting. The dtabase distributes the support libraries to all of the nodes in the cluster and sets the class path for the UDx so it can find them.&lt;/p&gt;
&lt;p&gt;If your UDx depends on native libraries (SO files), use the DEPENDS keyword to specify their path. When you call System.loadLibrary in your UDx (which you must do before using a native library), this function uses the DEPENDS path to find them. You do not need to also set the LD_LIBRARY_PATH environment variable.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;external-library-example&#34;&gt;External library example&lt;/h2&gt;
&lt;p&gt;The following example demonstrates using an external library with a Java UDx.&lt;/p&gt;
&lt;p&gt;The following sample code defines a simple class, named &lt;code&gt;VowelRemover&lt;/code&gt;. It contains a single method, named &lt;code&gt;removevowels&lt;/code&gt;, that removes all of the vowels (the letters &lt;em&gt;a&lt;/em&gt;, &lt;em&gt;e&lt;/em&gt;, &lt;em&gt;i&lt;/em&gt;, &lt;em&gt;o&lt;/em&gt; &lt;em&gt;u&lt;/em&gt;, and &lt;em&gt;y&lt;/em&gt;) from a string.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;package&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;com.mycompany.libs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;VowelRemover&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;removevowels&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;input&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;input&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;replaceAll&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;(?i)[aeiouy]&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can compile this class and package it into a JAR file with the following commands:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ javac -g com/mycompany/libs/VowelRemover.java
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ jar cf mycompanylibs.jar com/mycompany/libs/VowelRemover.class
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The following code defines a Java UDSF, named &lt;code&gt;DeleteVowels&lt;/code&gt;, that uses the library defined in the preceding example code. &lt;code&gt;DeleteVowels&lt;/code&gt; accepts a single VARCHAR as input, and returns a VARCHAR.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;package&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;com.mycompany.udx&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Import the support class created earlier
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;com.mycompany.libs.VowelRemover&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Import the OpenText&amp;amp;trade; Analytics Database SDK
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;com.vertica.sdk.*&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;DeleteVowelsFactory&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ScalarFunctionFactory&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ScalarFunction&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;createScalarFunction&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ServerInterface&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;arg0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DeleteVowels&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getPrototype&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ServerInterface&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;arg0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ColumnTypes&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;argTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;ColumnTypes&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;returnTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;c1&#34;&gt;// Accept a single string and return a single string.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;        &lt;span class=&#34;n&#34;&gt;argTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;addVarchar&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;returnTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;addVarchar&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getReturnType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ServerInterface&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;srvInterface&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;SizedColumnTypes&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;argTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;SizedColumnTypes&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;returnType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;returnType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;addVarchar&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;c1&#34;&gt;// Output will be no larger than the input.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;        &lt;span class=&#34;n&#34;&gt;argTypes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getColumnType&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getStringLength&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(),&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;RemovedVowels&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;DeleteVowels&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ScalarFunction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;processBlock&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ServerInterface&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;arg0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;BlockReader&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;argReader&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                &lt;span class=&#34;n&#34;&gt;BlockWriter&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;resWriter&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;throws&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;UdfException&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;DestroyInvocation&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;c1&#34;&gt;// Create an instance of the  VowelRemover object defined in
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;            &lt;span class=&#34;c1&#34;&gt;// the library.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;            &lt;span class=&#34;n&#34;&gt;VowelRemover&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;remover&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;VowelRemover&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;k&#34;&gt;do&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;instr&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;argReader&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                &lt;span class=&#34;c1&#34;&gt;// Call the removevowels method defined in the library.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;                &lt;span class=&#34;n&#34;&gt;resWriter&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;setString&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;remover&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;removevowels&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;instr&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                &lt;span class=&#34;n&#34;&gt;resWriter&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;next&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;while&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;argReader&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;next&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;());&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use the following commands to build the example UDSF and package it into a JAR:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The first javac command compiles the SDK’s &lt;code&gt;BuildInfo&lt;/code&gt; class. The database requires all UDx libraries to contain this class. The &lt;code&gt;javac&lt;/code&gt; command’s -d option outputs the class file in the directory structure of your UDSF’s source.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The second &lt;code&gt;javac&lt;/code&gt; command compiles the UDSF class. It adds the previously-created &lt;code&gt;mycompanylibs.jar&lt;/code&gt; file to the class path so compiler can find the the &lt;code&gt;VowelRemover&lt;/code&gt; class.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;code&gt;jar&lt;/code&gt; command packages the &lt;code&gt;BuildInfo&lt;/code&gt; and the classes for the UDx library together.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ javac -g -cp /opt/vertica/bin/VerticaSDK.jar&lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;   /opt/vertica/sdk/com/vertica/sdk/BuildInfo.java -d .
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ javac -g -cp mycompanylibs.jar:/opt/vertica/bin/VerticaSDK.jar&lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;  com/mycompany/udx/DeleteVowelsFactory.java
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ jar cf DeleteVowelsLib.jar com/mycompany/udx/*.class &lt;span class=&#34;se&#34;&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;se&#34;&gt;&lt;/span&gt;   com/vertica/sdk/*.class
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To install the UDx library, you must copy both of the JAR files to a node in the database cluster. Then, connect to the node to execute the CREATE LIBRARY statement.&lt;/p&gt;
&lt;p&gt;The following example demonstrates how to load the UDx library after you copy the JAR files to the home directory of the dbadmin user. The DEPENDS keyword instructs the database that the UDx library depends on the &lt;code&gt;mycompanylibs.jar&lt;/code&gt; file.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sql&#34; data-lang=&#34;sql&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;CREATE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LIBRARY&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DeleteVowelsLib&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;AS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;/home/dbadmin/DeleteVowelsLib.jar&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DEPENDS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;/home/dbadmin/mycompanylibs.jar&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;   &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;LANGUAGE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;JAVA&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;CREATE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LIBRARY&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;CREATE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;FUNCTION&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;deleteVowels&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;AS&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;language&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;java&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;NAME&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;com.mycompany.udx.DeleteVowelsFactory&amp;#39;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;LIBRARY&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DeleteVowelsLib&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;CREATE&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;FUNCTION&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;SELECT&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;deleteVowels&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;I hate vowels!&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;deleteVowels&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;--------------
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;  &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ht&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;n&#34;&gt;vwls&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;row&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
      </description>
    </item>
    
    <item>
      <title>Extending: Java and OpenText&amp;trade; Analytics Database data types</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/java-and-data-types/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/java-and-data-types/</guid>
      <description>
        
        
        &lt;p&gt;The OpenText™ Analytics Database Java SDK converts OpenText™ Analytics Database&#39;s native data types into the appropriate Java data type. The following table lists the OpenText™ Analytics Database data types and their corresponding Java data types.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
OpenText™ Analytics Database Data Type&lt;/th&gt; 

&lt;th &gt;
Java Data Type&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


INTEGER&lt;/td&gt; 

&lt;td &gt;


long&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


FLOAT&lt;/td&gt; 

&lt;td &gt;


double&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
NUMERIC&lt;/td&gt; 

&lt;td &gt;
com.vertica.sdk.VNumeric&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


DATE&lt;/td&gt; 

&lt;td &gt;


java.sql.Date&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


CHAR, VARCHAR, LONG VARCHAR&lt;/td&gt; 

&lt;td &gt;


com.vertica.sdk.VString&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


BINARY, VARBINARY, LONG VARBINARY&lt;/td&gt; 

&lt;td &gt;


com.vertica.sdk.VString&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


TIMESTAMP&lt;/td&gt; 

&lt;td &gt;


java.sql.Timestamp&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;


&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

Some database data types are not supported.

&lt;/div&gt;&lt;/p&gt;
&lt;h2 id=&#34;setting-binary-varbinary-and-long-varbinary-values&#34;&gt;Setting BINARY, VARBINARY, and LONG VARBINARY values&lt;/h2&gt;
&lt;p&gt;The database BINARY, VARBINARY, and LONG VARBINARY data types are converted as the Java UDx SDK &#39;s VString class. You can also set the value of a column with one of these data types with a &lt;code&gt;ByteBuffer&lt;/code&gt; object (or a byte array wrapped in a &lt;code&gt;ByteBuffer&lt;/code&gt;) using the &lt;code&gt;PartitionWriter.setStringBytes()&lt;/code&gt; method. See the Java API UDx entry for &lt;code&gt;PartitionWriter.setStringBytes()&lt;/code&gt; for more information.&lt;/p&gt;
&lt;h2 id=&#34;timestamps-and-time-zones&#34;&gt;Timestamps and time zones&lt;/h2&gt;
&lt;p&gt;When the SDK converts a database timestamp into a Java timestamp, it uses the time zone of the JVM. If the JVM is running in a different time zone than the one used by the database, the results can be confusing.&lt;/p&gt;
&lt;p&gt;The database stores timestamps in the database in UTC. (If a database time zone is set, the conversion is done at query time.) To prevent errors from the JVM time zone, add the following code to the processing method of your UDx:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;TimeZone&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;setDefault&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TimeZone&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;getTimeZone&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;UTC&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;strings&#34;&gt;Strings&lt;/h2&gt;
&lt;p&gt;The Java SDK contains a class named &lt;code&gt;StringUtils&lt;/code&gt; that assists you when manipulating string data. One of its more useful features is its &lt;code&gt;getStringBytes()&lt;/code&gt; method. This method extracts bytes from a &lt;code&gt;String&lt;/code&gt; in a way that prevents the creation of invalid strings. If you attempt to extract a substring that would split part of a multi-byte UTF-8 character, &lt;code&gt;getStringBytes()&lt;/code&gt; truncates it to the nearest whole character.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Extending: Handling NULL values</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/handling-null-values/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/handling-null-values/</guid>
      <description>
        
        
        &lt;p&gt;Your UDxs must be prepared to handle NULL values. These values usually must be handled separately from regular values.&lt;/p&gt;
&lt;h2 id=&#34;reading-null-values&#34;&gt;Reading NULL values&lt;/h2&gt;
&lt;p&gt;Your UDx reads data from instances of the the &lt;code&gt;BlockReader&lt;/code&gt; or &lt;code&gt;PartitionReader&lt;/code&gt; classes. If the value of a column is NULL, the methods you use to get data (such as &lt;code&gt;getLong&lt;/code&gt;) return a Java &lt;code&gt;null&lt;/code&gt; reference. If you attempt to use the value without checking for NULL, the Java runtime will throw a null pointer exception.&lt;/p&gt;
&lt;p&gt;You can test for null values before reading columns by using the data-type-specific methods (such as &lt;code&gt;isLongNull&lt;/code&gt;, &lt;code&gt;isDoubleNull&lt;/code&gt;, and &lt;code&gt;isBooleanNull&lt;/code&gt;). For example, to test whether the INTEGER first column of your UDx&#39;s input is a NULL, you would use the statement:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// See if the Long value in column 0 is a NULL
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;inputReader&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;na&#34;&gt;isLongNull&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// value is null
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;o&#34;&gt;.&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;.&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;writing-null-values&#34;&gt;Writing NULL values&lt;/h2&gt;
&lt;p&gt;You output NULL values using type-specific methods on the &lt;code&gt;BlockWriter&lt;/code&gt; and &lt;code&gt;PartitionWriter&lt;/code&gt; classes (such as &lt;code&gt;setLongNull&lt;/code&gt; and &lt;code&gt;setStringNull&lt;/code&gt;). These methods take the column number to receive the NULL value. In addition, the &lt;code&gt;PartitionWriter&lt;/code&gt; class has data-type specific set value methods (such as &lt;code&gt;setLongValue&lt;/code&gt; and &lt;code&gt;setStringValue&lt;/code&gt;). If you pass these methods a value, they set the output column to that value. If you pass them a Java &lt;code&gt;null&lt;/code&gt; reference, they set the output column to NULL.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Extending: Adding metadata to Java UDx libraries</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/adding-metadata-to-java-udx-libraries/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/adding-metadata-to-java-udx-libraries/</guid>
      <description>
        
        
        &lt;p&gt;You can add metadata, such as author name, the version of the library, a description of your library, and so on to your library. This metadata lets you track the version of your function that is deployed on a Vertica Analytic Database cluster and lets third-party users of your function know who created the function. Your library&#39;s metadata appears in the &lt;a href=&#34;../../../../../en/sql-reference/system-tables/v-monitor-schema/user-libraries/#&#34;&gt;USER_LIBRARIES&lt;/a&gt; system table after your library has been loaded into the Vertica Analytic Database catalog.&lt;/p&gt;

&lt;p&gt;To add metadata to your Java UDx library, you create a subclass of the &lt;code&gt;UDXLibrary&lt;/code&gt; class that contains your library&#39;s metadata. You then include this class within your JAR file. When you load your class into the OpenText™ Analytics Database catalog using the &lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-library/#&#34;&gt;CREATE LIBRARY&lt;/a&gt; statement, looks for a subclass of &lt;code&gt;UDXLibrary&lt;/code&gt; for the library&#39;s metadata.&lt;/p&gt;
&lt;p&gt;In your subclass of &lt;code&gt;UDXLibrary&lt;/code&gt;, you need to implement eight getters that return String values containing the library&#39;s metadata. The getters in this class are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getAuthor()&lt;/code&gt; returns the name you want associated with the creation of the library (your own name or your company&#39;s name for example).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getLibraryBuildTag()&lt;/code&gt; returns whatever String you want to use to represent the specific build of the library (for example, the SVN revision number or a timestamp of when the library was compiled). This is useful for tracking instances of your library as you are developing them.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getLibraryVersion()&lt;/code&gt; returns the version of your library. You can use whatever numbering or naming scheme you want.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getLibrarySDKVersion()&lt;/code&gt; returns the version of the SDK Library for which you&#39;ve compiled the library.&lt;/p&gt;

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

This field isn&#39;t used to determine whether a library is compatible with a version of the database server. The version of the SDK you use to compile your library is embedded in the library when you compile it. It is this information that the database server uses to determine if your library is compatible with it.

&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getSourceUrl()&lt;/code&gt; returns a URL where users of your function can find more information about it. This can be your company&#39;s website, the GitHub page hosting your library&#39;s source code, or whatever site you like.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getDescription()&lt;/code&gt; returns a concise description of your library.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getLicensesRequired()&lt;/code&gt; returns a placeholder for licensing information. You must pass an empty string for this value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;getSignature()&lt;/code&gt; returns a placeholder for a signature that will authenticate your library. You must pass an empty string for this value.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, the following code demonstrates creating a UDXLibrary subclass to be included in the Add2Ints UDSF example JAR file (see &lt;code&gt;/opt/vertica/sdk/examples/JavaUDx/ScalarFunctions&lt;/code&gt; on any database node).&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Import the UDXLibrary class to hold the metadata
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;com.vertica.sdk.UDXLibrary&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Add2IntsLibrary&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;UDXLibrary&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// Return values for the metadata about this library.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getAuthor&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Whizzo Analytics Ltd.&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getLibraryBuildTag&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;1234&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getLibraryVersion&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;1.0&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getLibrarySDKVersion&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;7.0.0&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getSourceUrl&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;http://example.com/add2ints&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getDescription&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;My Awesome Add 2 Ints Library&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getLicensesRequired&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nd&#34;&gt;@Override&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;String&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;getSignature&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When the library containing the Add2IntsLibrary class loaded, the metadata appears in the USER_LIBRARIES system table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE LIBRARY JavaAdd2IntsLib AS :libfile LANGUAGE &amp;#39;JAVA&amp;#39;;
CREATE LIBRARY
=&amp;gt; CREATE FUNCTION JavaAdd2Ints as LANGUAGE &amp;#39;JAVA&amp;#39;  name &amp;#39;com.mycompany.example.Add2IntsFactory&amp;#39; library JavaAdd2IntsLib;
CREATE FUNCTION
=&amp;gt; \x
Expanded display is on.
=&amp;gt; SELECT * FROM USER_LIBRARIES WHERE lib_name = &amp;#39;JavaAdd2IntsLib&amp;#39;;
-[ RECORD 1 ]-----+---------------------------------------------
schema_name       | public
lib_name          | JavaAdd2IntsLib
lib_oid           | 45035996273869844
author            | Whizzo Analytics Ltd.
owner_id          | 45035996273704962
lib_file_name     | public_JavaAdd2IntsLib_45035996273869844.jar
md5_sum           | f3bfc76791daee95e4e2c0f8a8d2737f
sdk_version       | v7.0.0-20131105
revision          | 125200
lib_build_tag     | 1234
lib_version       | 1.0
lib_sdk_version   | 7.0.0
source_url        | http://example.com/add2ints
description       | My Awesome Add 2 Ints Library
licenses_required |
signature         |
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Extending: Java UDx resource management</title>
      <link>/en/extending/developing-udxs/developing-with-sdk/java-sdk/java-udx-resource-management/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/extending/developing-udxs/developing-with-sdk/java-sdk/java-udx-resource-management/</guid>
      <description>
        
        
        &lt;p&gt;Java Virtual Machines (JVMs) allocate a set amount of memory when they start. This set memory allocation complicates memory management for Java UDxs, because memory cannot be dynamically allocated and freed by the UDx as it is processing data. This is differs from C++ UDxs which can dynamically allocate resources.&lt;/p&gt;
&lt;p&gt;To control the amount of memory consumed by Java UDxs, OpenText™ Analytics Database has a memory pool named jvm that it uses to allocate memory for JVMs. If this memory pool is exhausted, queries that call Java UDxs block until enough memory in the pool becomes free to start a new JVM.&lt;/p&gt;
&lt;p&gt;By default, the jvm pool has:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;no memory of its own assigned to it, so it borrows memory from the GENERAL pool.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;its MAXMEMORYSIZE set to either 10% of system memory or 2GB, whichever is smaller.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;its PLANNEDCONCURRENCY set to AUTO, so that it inherits the GENERAL pool&#39;s PLANNEDCONCURRENCY setting.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can view the current settings for the jvm pool by querying the RESOURCE_POOLS table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT MAXMEMORYSIZE,PLANNEDCONCURRENCY FROM V_CATALOG.RESOURCE_POOLS WHERE NAME = &amp;#39;jvm&amp;#39;;
 MAXMEMORYSIZE | PLANNEDCONCURRENCY
---------------+--------------------
 10%           | AUTO
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When a SQL statement calls a Java UDx, the database checks if the jvm memory pool has enough memory to start a new JVM instance to execute the function call. The database starts each new JVM with its heap memory size set to approximately the jvm pool&#39;s MAXMEMORYSIZE parameter divided by its PLANNEDCONCURRENCY parameter. If the memory pool does not contain enough memory, the query blocks until another JVM exits and return their memory to the pool.&lt;/p&gt;
&lt;p&gt;If your Java UDx attempts to consume more memory than has been allocated to the JVM&#39;s heap size, it exits with a memory error. You can attempt to resolve this issue by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;increasing the jvm pool&#39;s MAXMEMORYSIZE parameter.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;decreasing the jvm pool&#39;s PLANNEDCONCURRENCY parameter.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;changing your Java UDx&#39;s code to consume less memory.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;adjusting-the-jvm-pool&#34;&gt;Adjusting the jvm pool&lt;/h2&gt;
&lt;p&gt;When adjusting the jvm pool to your needs, you must consider two factors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;the amount of RAM your Java UDx requires to run&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;how many concurrent Java UDx functions you expect your database to run&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can learn the amount of memory your Java UDx needs using several methods. For example, your code can use Java&#39;s &lt;code&gt;Runtime&lt;/code&gt; class to get an estimate of the total memory it has allocated and then log the value using &lt;code&gt;ServerInterface.log()&lt;/code&gt;. (An instance of this class is passed to your UDx.) If you have multiple Java UDxs in your database, set the jvm pool memory size based on the UDx that uses the most memory.&lt;/p&gt;
&lt;p&gt;The number of concurrent sessions that need to run Java UDxs may not be the same as the global PLANNEDCONCURRENCY setting. For example, you may have just a single user who runs a Java UDx, which means you can lower the jvm pool&#39;s PLANNEDCONCURRENCY setting to 1.&lt;/p&gt;
&lt;p&gt;When you have an estimate for the amount of RAM and the number of concurrent user sessions that need to run Java UDXs, you can adjust the jvm pool to an appropriate size. Set the pool&#39;s MAXMEMORYSIZE to the maximum amount of RAM needed by the most demanding Java UDx multiplied by the number of concurrent user sessions that need to run Java UDxs. Set the pool&#39;s PLANNEDCONCURENCY to the numebr of simultaneous user sessions that need to run Java UDxs.&lt;/p&gt;
&lt;p&gt;For example, suppose your Java UDx requires up to 4GB of memory to run and you expect up to two user sessions use Java UDx&#39;s. You would use the following command to adjust the jvm pool:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER RESOURCE POOL jvm MAXMEMORYSIZE &amp;#39;8G&amp;#39; PLANNEDCONCURRENCY 2;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The MEMORYSIZE is set to 8GB, which is the 4GB maximum memory use by the Java UDx multiplied by the 2 concurrent user sessions.

&lt;div class=&#34;alert admonition note&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Note&lt;/h4&gt;

The PLANNEDCONCURRENCY value is &lt;strong&gt;not&lt;/strong&gt; the number of calls to Java UDx that you expect to happen simultaneously. Instead, it is the number of concurrently open user sessions that call Java UDxs at any time during the session. See below for more information.

&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../../en/admin/managing-db/managing-workloads/#&#34;&gt;Managing workloads&lt;/a&gt; for more information on tuning the jvm and other resource pools.&lt;/p&gt;
&lt;h2 id=&#34;freeing-jvm-memory&#34;&gt;Freeing JVM memory&lt;/h2&gt;
&lt;p&gt;The first time users call a Java UDx during their session, the database allocates memory from the jvm pool and starts a new JVM. This JVM remains running for as long as the user&#39;s session is open so it can process other Java UDx calls. Keeping the JVM running lowers the overhead of executing multiple Java UDxs by the same session. If the JVM did not remain open, each call to a Java UDx would require additional time for the database to allocate resources and start a new JVM. However, having the JVM remain open means that the JVM&#39;s memory remains allocated for the life of the session whether or not it will be used again.&lt;/p&gt;
&lt;p&gt;If the jvm memory pool is depleted, queries containing Java UDxs either block until memory becomes available or eventually fail due a lack of resources. If you find queries blocking or failing for this reason, you can allocate more memory to the jvm pool and increase its PLANNEDCONCURRENCY. Another option is to ask users to call the &lt;a href=&#34;../../../../../en/sql-reference/functions/management-functions/session-functions/release-jvm-memory/#&#34;&gt;RELEASE_JVM_MEMORY&lt;/a&gt; function when they no longer need to run Java UDxs. This function closes any JVM belonging to the user&#39;s session and returns its allocated memory to the jvm memory pool.&lt;/p&gt;
&lt;p&gt;The following example demonstrates querying V_MONITOR.SESSIONS to find the memory allocated to JVMs by all sessions. It also demonstrates how the memory is allocated by a call to a Java UDx, and then freed by calling RELEASE_JVM_MEMORY.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT USER_NAME,EXTERNAL_MEMORY_KB FROM V_MONITOR.SESSIONS;
 user_name | external_memory_kb
-----------+---------------
 dbadmin   |             0
(1 row)

=&amp;gt; -- Call a Java UDx
=&amp;gt; SELECT add2ints(123,456);
 add2ints
----------
      579
(1 row)
=&amp;gt; -- JVM is now running and memory is allocated to it.
=&amp;gt; SELECT USER_NAME,EXTERNAL_MEMORY_KB FROM V_MONITOR.SESSIONS;
 USER_NAME | EXTERNAL_MEMORY_KB
-----------+---------------
 dbadmin   |         79705
(1 row)

=&amp;gt; -- Shut down the JVM and deallocate memory
=&amp;gt; SELECT RELEASE_JVM_MEMORY();
           RELEASE_JVM_MEMORY
-----------------------------------------
 Java process killed and memory released
(1 row)

=&amp;gt; SELECT USER_NAME,EXTERNAL_MEMORY_KB FROM V_MONITOR.SESSIONS;
 USER_NAME | EXTERNAL_MEMORY_KB
-----------+---------------
 dbadmin   |             0
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In rare cases, you may need to close all JVMs. For example, you may need to free memory for an important query, or several instances of a Java UDx may be taking too long to complete. You can use the &lt;a href=&#34;../../../../../en/sql-reference/functions/management-functions/session-functions/release-all-jvm-memory/#&#34;&gt;RELEASE_ALL_JVM_MEMORY&lt;/a&gt; to close all of the JVMs in all user sessions:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT USER_NAME,EXTERNAL_MEMORY_KB FROM V_MONITOR.SESSIONS;
  USER_NAME  | EXTERNAL_MEMORY_KB
-------------+---------------
 ExampleUser |         79705
 dbadmin     |         79705
(2 rows)

=&amp;gt; SELECT RELEASE_ALL_JVM_MEMORY();
                           RELEASE_ALL_JVM_MEMORY
-----------------------------------------------------------------------------
 Close all JVM sessions command sent. Check v_monitor.sessions for progress.
(1 row)

=&amp;gt; SELECT USER_NAME,EXTERNAL_MEMORY_KB FROM V_MONITOR.SESSIONS;
 USER_NAME | EXTERNAL_MEMORY_KB
-----------+---------------
 dbadmin   |             0
(1 row)
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;admonition caution&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Caution&lt;/h4&gt;

This function terminates all JVMs, including ones that are currently executing Java UDXs. This will cause any query that is currently executing a Java UDx to return an error.

&lt;/div&gt;
&lt;h2 id=&#34;notes&#34;&gt;Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The jvm resource pool is used only to allocate memory for the Java UDx function calls in a statement. The rest of the resources required by the SQL statement come from other memory pools.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The first time a Java UDx is called, the database starts a JVM to execute some Java methods to get metadata about the UDx during the query planning phase. The memory for this JVM is also taken from the jvm memory pool.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
