Skip to main content
Package com.gpudb

Class GPUdbBase

java.lang.Object
com.gpudb.GPUdbBase
Direct Known Subclasses:

public abstract class GPUdbBase extends Object
Base class for the GPUdb API that provides general functionality not specific to any particular GPUdb request. This class is never instantiated directly; its functionality is accessed via instances of the GPUdb class. Usage patterns: 1. Unsecured setup
         String url = “http://your\_server\_ip\_or\_FQDN:9191”;

         GPUdb.Options options = new GPUdb.Options();
         options.setUsername(“user”);
         options.setPassword(“password”);

         GPUdb gpudb = new GPUdb( url, options );

 
2. Secured setup If options.setBypassSslCertCheck( true ) is set, then all forms of certificate checking whether self-signed or one issued by a known CA will be bypassed and an unsecured connection will be set up. A) This setup will enforce checking the truststore and the connection will fail if a mismatch is found
         String url = “https://your\_server\_ip\_or\_FQDN:8082/gpudb-0”;

         GPUdb.Options options = new GPUdb.Options();
         options.setUsername(“user”);
         options.setPassword(“password”);
         options.setTrustStoreFilePath(“/path/to/truststore.jks”);
         options.setTrustStorePassword(“password_for_truststore”);

         GPUdb gpudb = new GPUdb( url, options );
 
B) This setup will not enforce checking the truststore and the connection will succeed since the truststore will not be verified. if options.setBypassSslCertCheck(true) is there, then all other checks will be left out and the connection will succeed unless there are other errors like wrong credentials, non-responsive server etc. If a truststore (only for self-signed certificates) has to be used, one can set options.setTrustStoreFilePath(“/path/to/truststore.jks”) and options.setTrustStorePassword(“password_for_truststore”), but in this case options.setBypassSslCertCheck( true ) cannot be used.
         String url = “https://your\_server\_ip\_or\_FQDN:8082/gpudb-0”;

         GPUdb.Options options = new GPUdb.Options();
         options.setUsername(“user”);
         options.setPassword(“password”);
         options.setBypassSslCertCheck( true );

         GPUdb gpudb = new GPUdb( url, options );
 
C) This setup will enforce checking any security related configurations and will proceed to set up a secured connection only if the server has SSL set up and a certificate from a well-known CA is available. In this case, the Java runtime makes sure that the server certificate is validated without the user having to specify anything.
         String url = “https://your\_server\_ip\_or\_FQDN:8082/gpudb-0”;

         GPUdb.Options options = new GPUdb.Options();
         options.setUsername(“user”);
         options.setPassword(“password”);

         GPUdb gpudb = new GPUdb( url, options );
 
  • Field Details

  • Constructor Details

  • Method Details

    • getApiVersion

      public static String getApiVersion()
      Gets the version and build number of the GPUdb Java API.
      Returns:
      the version number
    • buildUserAgent

      protected String buildUserAgent()
      Builds the User-Agent string sent with every request. The base format is:
         kinetica-api-java/<api-version> (Java/<java-version>; <os-name>/<os-version>; <os-arch>)
       
      If a client program has registered identifying info via GPUdbBase.Options.setClientInfo(String, String), it is prepended as the leading product token, following the convention used by browsers and other HTTP user agents where the primary agent is listed first and the underlying libraries follow:
         MyApp/1.0 kinetica-api-java/7.2.3.18 (Java/11.0.1; Linux/5.15.0; amd64)
       
    • getUserAgent

      public String getUserAgent()
      Returns the User-Agent header value currently sent with each request from this client.
      Returns:
      the User-Agent string
    • getClientName

      public String getClientName()
      Returns the client program name (the name portion of the leading product token of the User-Agent header), or null if none has been set. Set via GPUdbBase.Options.setClientInfo(String, String) prior to constructing the client.
      Returns:
      the client name, or null
      See Also:
    • getClientVersion

      public String getClientVersion()
      Returns the client program version (the version portion of the leading product token of the User-Agent header), or null if none has been set. Set via GPUdbBase.Options.setClientInfo(String, String) prior to constructing the client.
      Returns:
      the client version, or null
      See Also:
    • list

      @SafeVarargs public static <T> List<T> list(T… values)
      A utility method for creating a list of objects inline. Can be used with certain GPUdb requests for specifying lists of strings or other objects.
      Type Parameters:
      T - the type of objects in the list
      Parameters:
      values - the objects to be added to the list
      Returns:
      the list
    • options

      public static Map<String,String> options(String… values)
      A utility method for creating a map of strings to strings inline. Can be used with certain GPUdb requests for specifying additional named parameters. An even number of string values must be specified; the first in each pair is the key for a map entry, and the second is the value.
      Parameters:
      values - an even number of string values
      Returns:
      the map
      Throws:
      IllegalArgumentException - if an odd number of values is specified
    • finalize

      protected void finalize() throws Throwable
      Clean up resources—namely, the HTTPClient object(s).
      Overrides:
      finalize in class Object
      Throws:
    • removeProtectedHttpHeaders

      protected void removeProtectedHttpHeaders()
    • createAuthorizationHeader

      protected String createAuthorizationHeader()
      Choose and return the authentication mode based on the presence of options in this connection’s options map. Authentication scheme: 1. Choose OAuth2 authentication if oauthToken option is set 2. Choose basic authentication if username/password options is set 3. Choose no authentication
    • getAuthorizationFromHttpHeaders

      protected void getAuthorizationFromHttpHeaders()
    • createHASyncModeHeader

      protected GPUdbBase.HASynchronicityMode createHASyncModeHeader()
    • getURLs

      public List<URL> getURLs()
      Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server. At any given time, one URL will be active and used for all GPUdb calls (call getURL to determine which one), but in the event of failure, the other URLs will be tried in a randomized order, and if a working one is found it will become the new active URL.
      Returns:
      the list of URLs
    • getFailoverURLs

      public List<URL> getFailoverURLs()
      Gets the list of URLs of the active head ranks of all the clusters for the GPUdb server. At any given time, one URL will be active and used for all GPUdb calls (call getURL to determine which one), but in the event of failure, the other URLs will be tried in order, and if a working one is found it will become the new active URL.
      Returns:
      the list of URLs
    • getHmURLs

      public List<URL> getHmURLs()
      Gets the list of URLs for the GPUdb host manager. At any given time, one URL will be active and used for all GPUdb calls (call getHmURL to determine which one), but in the event of failure, the other URLs will be tried in order, and if a working one is found it will become the new active URL.
      Returns:
      the list of URLs
    • getClusterInfo

      public GPUdbBase.ClusterAddressInfo getClusterInfo()
      Gets the active cluster’s information object.
      Returns:
      GPUdbBase.ClusterAddressInfo for the active cluster.
    • getSystemProperties

      public Map<String,String> getSystemProperties()
      Gets the active cluster’s system properties mapping. If this cluster was created without a system properties map, load it now.
      Returns:
      Map of system property settings
    • getURL

      public URL getURL()
      Gets the active URL of the GPUdb server.
      Returns:
      the URL
    • getHmURL

      public URL getHmURL()
      Gets the active URL of the GPUdb host manager.
      Returns:
      the URL
    • getPrimaryUrl

      public URL getPrimaryUrl()
      Gets the URL of the head node of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.
      Returns:
      the primary URL hostname or IP address if there is a primary cluster, null otherwise.
    • getPrimaryHostname

      public String getPrimaryHostname()
      Gets the hostname of the primary cluster of the HA environment, if any cluster is identified as the primary cluster.
      Returns:
      the primary URL hostname or IP address if there is a primary cluster, empty string otherwise.
    • getServerVersion

      public GPUdbBase.GPUdbVersion getServerVersion()
      Gets the version of the database server that this client is connected to. If the server version was not successfully saved, then returns null.
      Returns:
      the server version GPUdbBase.GPUdbVersion, or null.
    • getHASyncMode

      public GPUdbBase.HASynchronicityMode getHASyncMode()
      Gets the current high availability synchronicity override mode.
      Returns:
      the ha synchronicity override mode
      See Also:
    • getUsername

      public String getUsername()
      Gets the username used for authentication to GPUdb. Will be an empty string if none was provided to the GPUdb constructor via GPUdbBase.Options.
      Returns:
      the username
      See Also:
    • getPassword

      public String getPassword()
      Gets the password used for authentication to GPUdb. Will be an empty string if none was provided to the GPUdb constructor via GPUdbBase.Options.
      Returns:
      the password
      See Also:
    • getUseSnappy

      public boolean getUseSnappy()
      Gets the value of the flag indicating whether Snappy compression will be used for certain GPUdb requests that potentially submit large amounts of data. Will be false if not overridden using the GPUdb constructor via GPUdbBase.Options.
      Returns:
      the value of the Snappy compression flag
      See Also:
    • isAutoDiscoveryEnabled

      public boolean isAutoDiscoveryEnabled()
      Gets whether auto-discovery is enabled or not on the current connection.
      Returns:
      true if auto-discovery is enabled; false otherwise
    • getThreadCount

      public int getThreadCount()
      Gets the number of threads used during data encoding and decoding operations. Will be one if not overridden using the GPUdb constructor via GPUdbBase.Options.
      Returns:
      the number of threads
      See Also:
    • getExecutor

      public ExecutorService getExecutor()
      Gets the executor service used for managing threads during data encoding and decoding operations. Will be null if none was provided to the GPUdb constructor via GPUdbBase.Options.
      Returns:
      the executor service
      See Also:
    • getHttpHeaders

      public Map<String,String> getHttpHeaders()
      Gets the map of additional HTTP headers that will be sent to GPUdb with each request. Will be empty if none were provided to the GPUdb constructor via GPUdbBase.Options.
    • getTimeout

      public int getTimeout()
      Gets the timeout value, in milliseconds, after which a lack of response from the GPUdb server will result in requests being aborted. A timeout of zero is interpreted as an infinite timeout. Note that this applies independently to various stages of communication, so overall a request may run for longer than this without being aborted.
      Returns:
      the timeout value
      See Also:
    • getMaxRetries

      public int getMaxRetries()
      Gets the maximum number of retries for HTTP requests.
      Returns:
      the maxRetries value
      See Also:
    • getHARingInfo

      public List<GPUdbBase.ClusterAddressInfo> getHARingInfo()
      Gets a copy of the list of ClusterAddressInfo objects that contain information about the Kinetica ring of clusters that this GPUdb object is connected to.
      Returns:
      the size of the HA cluster
    • getHARingSize

      public int getHARingSize()
      Gets the size of the high availability ring (i.e. how many clusters are in it).
      Returns:
      the size of the HA cluster
    • getBypassSslCertCheck

      public boolean getBypassSslCertCheck()
    • addHttpHeader

      public void addHttpHeader(String header, String value) throws GPUdbException
      Adds an HTTP header to the map of additional HTTP headers to send to GPUdb with each request. If the header is already in the map, its value is replaced with the specified value. The user is not allowed to modify the following headers:
      • Authorization
      • ha_sync_mode
      • Content-type
      Parameters:
      header - the HTTP header (cannot be null)
      value - the value of the HTTP header (cannot be null)
      Throws:
      See Also:
    • removeHttpHeader

      public void removeHttpHeader(String header) throws GPUdbException
      Removes the given HTTP header from the map of additional HTTP headers to send to GPUdb with each request. The user is not allowed to remove the following headers:
      • Authorization
      • ha_sync_mode
      • Content-type
      Parameters:
      header - the HTTP header (cannot be null)
      Throws:
      See Also:
    • setHASyncMode

      public void setHASyncMode(GPUdbBase.HASynchronicityMode syncMode)
      Sets the current high availability synchronicity override mode. Until it is changed, all subsequent endpoint calls made to the server will maintain the given synchronicity across all clusters in the high availability ring. When set to GPUdbBase.HASynchronicityMode.DEFAULT, normal operation will resume (where the high availability process determines which endpoints will be synchronous and which ones will be asynchronous).
      Parameters:
      syncMode - the ha synchronicity override mode
    • setHostManagerPort

      @Deprecated(since=“7.1.0”, forRemoval=true) public GPUdbBase setHostManagerPort(int value) throws IllegalArgumentException
      Deprecated, for removal: This API element is subject to removal in a future version.
      As of version 7.1.0.0, this method will no longer be functional. This method will be a no-op, not changing host manager port. The method will be removed in version 7.2.0.0.
      Parameters:
      value - the host manager port number
      Returns:
      the current GPUdbBase instance
      Throws:
    • getNumClusterSwitches

      protected int getNumClusterSwitches()
      Gets the number of times the client has switched to a different cluster amongst the high availability ring.
    • incrementNumClusterSwitches

      protected void incrementNumClusterSwitches()
      Gets the number of times the client has switched to a different cluster amongst the high availability ring.
    • getHostAddresses

      public List<GPUdbBase.ClusterAddressInfo> getHostAddresses()
    • selectNextCluster

      protected void selectNextCluster()
      Select the next cluster based on the HA failover priority set by the user.
    • switchURL

      protected URL switchURL(URL oldURL, int oldNumClusterSwitches) throws GPUdbBase.GPUdbFailoverDisabledException, GPUdbBase.GPUdbHAUnavailableException
      Switches the URL of the HA ring cluster. Check if we’ve circled back to the old URL. If we’ve circled back to it, then re-shuffle the list of indices so that the next time, we pick up HA clusters in a different random manner and throw an exception.
      Parameters:
      oldURL - the head rank URL in use at the time of the failover that initiated this switch
      oldNumClusterSwitches - the total number of cluster switches that have occurred up to the moment before this thread’s switch was initiated; this will be used to determine whether another thread is already trying to fail over to the next cluster and that this thread should stand down
      Returns:
      the next cluster head rank URL to try
      Throws:
    • initializeHttpPostRequest

      protected org.apache.hc.client5.http.classic.methods.HttpPost initializeHttpPostRequest(URL url) throws Exception
      Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
      Parameters:
      url - the URL to which the connection needs to be made
      Returns:
      the initialized HttpPost connection object
      Throws:
    • initializeHttpPostRequest

      protected org.apache.hc.client5.http.classic.methods.HttpPost initializeHttpPostRequest(URL url, int responseTimeout) throws Exception
      Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
      Parameters:
      url - the URL to which the connection needs to be made
      responseTimeout - a positive integer representing the number of milliseconds to use for response timeout
      Returns:
      the initialized HttpPost connection object
      Throws:
    • initializeHttpConnection

      protected HttpURLConnection initializeHttpConnection(URL url) throws Exception
      Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
      Parameters:
      url - the URL to which the connection needs to be made
      Returns:
      the initialized HTTP connection object
      Throws:
    • initializeHttpConnection

      protected HttpURLConnection initializeHttpConnection(URL url, int connectionTimeout) throws Exception
      Create and initialize an HTTP connection object with the request headers (including authorization header), connection type, time out etc.
      Parameters:
      url - the URL to which the connection needs to be made
      connectionTimeout - a positive integer representing the number of milliseconds to use for connection and read timeouts
      Returns:
      the initialized HTTP connection object
      Throws:
    • insertRecordsFromJson

      public Map<String,Object> insertRecordsFromJson(GPUdbBase.InsertRecordsJsonRequest insertRecordsJsonRequest, GPUdbBase.JsonOptions jsonOptions) throws GPUdbException
      This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table
      Parameters:
      insertRecordsJsonRequest - - an instance of GPUdbBase.InsertRecordsJsonRequest class
      Returns:
      - the JSON response as a Map of String to Object.
      Throws:
      GPUdbException - - in case of an error raised by the underlying endpoint
    • insertRecordsFromJson

      public Map<String,Object> insertRecordsFromJson(String jsonRecords, String tableName) throws GPUdbException
      This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table with all default options
      Parameters:
      jsonRecords - - A single JSON record or an array of records as JSON
      tableName - - the table to insert the records into
      Returns:
      - the JSON response as a Map of String to Object.
      Throws:
      GPUdbException - - in case of an error raised by the underlying endpoint
    • insertRecordsFromJson

      public Map<String,Object> insertRecordsFromJson(String jsonRecords, String tableName, GPUdbBase.JsonOptions jsonOptions, Map<String,String> createTableOptions, Map<String,String> insertRecordsOptions) throws GPUdbException
      This method inserts a JSON payload (either a single JSON record or an array) into a Kinetica table
      Parameters:
      jsonRecords - - A single JSON record or an array of records as JSON
      tableName - - the table to insert the records into
      jsonOptions - - Indicates whether Snappy compression is to be set on or not
      createTableOptions - - an instance of the class InsertRecordsJsonRequest.CreateTableOptions
      insertRecordsOptions - - an instance of the class InsertRecordsJsonRequest.Options
      Returns:
      - the JSON response as a Map of String to Object.
      Throws:
      GPUdbException - - in case of an error raised by the underlying endpoint
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve; a value of null will return all columns
      offset - - the offset to start from
      limit - - the maximum number of records
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit, List<String> orderByColumns) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve; a value of null will return all columns
      offset - - the offset to start from
      limit - - the maximum number of records
      orderByColumns - - the list of columns to order by
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve; a value of null will return all columns
      offset - - the offset to start from
      limit - - the maximum number of records
      expression - - the filter expression
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, List<String> orderByColumns) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve; a value of null will return all columns
      offset - - the offset to start from
      limit - - the maximum number of records
      expression - - the filter expression
      orderByColumns - - the list of columns to order by
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, String havingClause) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve; a value of null will return all columns
      offset - - the offset to start from
      limit - - the maximum number of records
      expression - - the filter expression
      havingClause - - the having clause
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • getRecordsJson

      public GPUdbBase.GetRecordsJsonResponse getRecordsJson(String tableName, List<String> columnNames, long offset, long limit, String expression, List<String> orderByColumns, String havingClause) throws GPUdbException
      This method is used to retrieve records from a Kinetica table in the form of a JSON array (stringified). The only mandatory parameter is the ‘tableName’. The rest are all optional with suitable defaults wherever applicable.
      Parameters:
      tableName - - Name of the table
      columnNames - - the columns names to retrieve
      offset - - the offset to start from
      limit - - the maximum number of records
      expression - - the filter expression
      orderByColumns - - the list of columns to order by
      havingClause - - the having clause
      Returns:
      - an instance of GPUdbBase.GetRecordsJsonResponse class
      Throws:
    • query

      public <T extends Record> GPUdbSqlIterator<T> query(String sql) throws GPUdbException
      This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. See query(String, Object, Map) to execute a SQL statement without reading the resulting data.
      Parameters:
      sql - - The SQL query to execute
      Returns:
      - an instance of GPUdbSqlIterator class
      Throws:
    • query

      public <T extends Record> GPUdbSqlIterator<T> query(String sql, Object parameters) throws GPUdbException
      This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. See query(String, Object, Map) to execute a SQL statement without reading the resulting data.
      Parameters:
      sql - - The SQL query to execute
      parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
      Returns:
      - an instance of GPUdbSqlIterator class
      Throws:
    • query

      public <T extends Record> GPUdbSqlIterator<T> query(String sql, Object parameters, Map<String,String> sqlOptions) throws GPUdbException
      This method is used to send a SQL query to Kinetica and read the records in the returned GPUdbSqlIterator object. See execute(String) to execute a SQL statement without reading the resulting data.
      Parameters:
      sql - - The SQL query to execute
      parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
      sqlOptions - - Optional parameters for the executeSql call. Can be null.
      Returns:
      - an instance of GPUdbSqlIterator class
      Throws:
    • execute

      public long execute(String sql) throws GPUdbException
      This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map) to execute a SQL query to read the resulting data records.
      Parameters:
      sql - - The SQL query to execute
      Returns:
      - number of rows affected by the execution of statement
      Throws:
    • execute

      public long execute(String sql, Object parameters) throws GPUdbException
      This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map) to execute a SQL query to read the resulting data records.
      Parameters:
      sql - - The SQL query to execute
      parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
      Returns:
      - number of rows affected by the execution of statement
      Throws:
    • execute

      public long execute(String sql, Object parameters, Map<String,String> sqlOptions) throws GPUdbException
      This method is used to execute a SQL statement (e.g., DML, DDL). It returns the number of rows affected by the statement. See query(String, Object, Map) to execute a SQL query to read the resulting data records.
      Parameters:
      sql - - The SQL query to execute
      parameters - - Query parameters for the SQL query. Can be null or a String, String[] or List.
      sqlOptions - - Optional parameters for the executeSql call. Can be null.
      Returns:
      - number of rows affected by the execution of statement
      Throws:
    • addKnownType

      public void addKnownType(String typeId, Object typeDescriptor)
      Adds a type descriptor for a GPUdb type (excluding types of join tables), identified by a type ID, to the known type list. If that type is subsequently encountered in results from a GPUdb request for which an explicit type descriptor is not provided, the specified type descriptor will be used for decoding.
      Parameters:
      typeId - the type ID of the type in GPUdb (must not be the type of a join table)
      typeDescriptor - the type descriptor to be used for decoding the type
      Throws:
      IllegalArgumentException - if typeDescriptor is not a Schema, Type, TypeObjectMap, or Class that implements IndexedRecord
    • addKnownType

      public <T> void addKnownType(String typeId, Class<T> objectClass, TypeObjectMap<T> typeObjectMap)
      Adds a type object map for the specified class as a type descriptor for a GPUdb type, identified by a type ID, to the known type list, and also adds the type object map to the known type object map list. If either the type or the specified class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, or in its results, the specified type object map will be used for decoding and encoding.
      Type Parameters:
      T - the class
      Parameters:
      typeId - the type ID of the type in GPUdb
      objectClass - the class
      typeObjectMap - the type object map to be used for encoding and decoding
    • addKnownTypeFromTable

      public void addKnownTypeFromTable(String tableName, Object typeDescriptor) throws GPUdbException
      Adds a type descriptor for the GPUdb type stored in the specified table to the known type list. If that type is subsequently encountered in results from a GPUdb request for which an explicit type descriptor is not provided, the specified type descriptor will be used for decoding. Note that this method makes a request to GPUdb to obtain table information.
      Parameters:
      tableName - the name of the table in GPUdb
      typeDescriptor - the type descriptor to be used for decoding the type
      Throws:
      IllegalArgumentException - if typeDescriptor is not a Schema, Type, TypeObjectMap, or Class that implements IndexedRecord
      GPUdbException - if the table does not exist or is not homogeneous, or if an error occurs during the request for table information
    • addKnownTypeFromTable

      public <T> void addKnownTypeFromTable(String tableName, Class<T> objectClass, TypeObjectMap<T> typeObjectMap) throws GPUdbException
      Adds a type object map for the specified class as a type descriptor for the GPUdb type stored in the specified table to the known type list, and also adds the type object map to the known type object map list. If either the type or the specified class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, or in its results, the specified type object map will be used for decoding and encoding. Note that this method makes a request to GPUdb to obtain table information.
      Type Parameters:
      T - the class
      Parameters:
      tableName - the name of the table in GPUdb
      objectClass - the class
      typeObjectMap - the type object map to be used for encoding and decoding
      Throws:
      GPUdbException - if the table does not exist or is not homogeneous, or if an error occurs during the request for information
    • addKnownTypeObjectMap

      public <T> void addKnownTypeObjectMap(Class<T> objectClass, TypeObjectMap<T> typeObjectMap)
      Adds a type object map for the specified class to the known type object map list. If that class is subsequently encountered in a GPUdb request for which an explicit type object map is not provided, the specified type object map will be used for encoding.
      Type Parameters:
      T - the class
      Parameters:
      objectClass - the class
      typeObjectMap - the type object map to be used for encoding
    • decode

      protected <T> List<T> decode(Object typeDescriptor, List<ByteBuffer> data) throws GPUdbException
    • decode

      protected <T> List<T> decode(String typeId, List<ByteBuffer> data) throws GPUdbException
    • decode

      protected <T> List<T> decode(List<String> typeIds, List<ByteBuffer> data) throws GPUdbException
    • decodeMultiple

      protected <T> List<List<T>> decodeMultiple(Object typeDescriptor, List<List<ByteBuffer>> data) throws GPUdbException
    • decodeMultiple

      protected <T> List<List<T>> decodeMultiple(List<String> typeIds, List<List<ByteBuffer>> data) throws GPUdbException
    • encode

      protected <T> List<ByteBuffer> encode(List<T> data) throws GPUdbException
    • encode

      protected <T> List<ByteBuffer> encode(TypeObjectMap<T> typeObjectMap, List<T> data) throws GPUdbException
    • getTypeDescriptor

      protected Object getTypeDescriptor(String typeId) throws GPUdbException
    • getTypeObjectMap

      protected <T> TypeObjectMap<T> getTypeObjectMap(Class<T> objectClass) throws GPUdbException
    • setTypeDescriptorIfMissing

      protected void setTypeDescriptorIfMissing(String typeId, String label, String typeSchema, Map<String,List<String>> properties)
    • submitRequest

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response) throws GPUdbBase.SubmitException, GPUdbException
      Submits an arbitrary request to GPUdb and saves the response into a pre-created response object. The request and response objects must implement the Avro IndexedRecord interface. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      request - the request object
      response - the response object
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(String endpoint, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbException
      Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public Map<String,Object> submitRequest(String endpoint, String payload, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbException
      Submits a JSON payload to GPUdb via the specified URL and returns the response as a map of key/value pairs, optionally compressing the request before sending. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      payload - the payload as a JSON String
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, insert statistics will be available under the data key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public String submitRequest(String endpoint, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbException
      Submits an arbitrary request to GPUdb and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, the response will be available under the data key, including the response records under the records key and whether more matching records exist to be retrieved under the has_more_records key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public String submitRequest(URL url, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, the response will be available under the data key, including the response records under the records key and whether more matching records exist to be retrieved under the has_more_records key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public Map<String,Object> submitRequest(URL url, String payload, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits a JSON payload to GPUdb via the specified URL and returns the response as a map of key/value pairs, optionally compressing the request before sending. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      payload - the payload as a JSON String
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, insert statistics will be available under the data key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestToHM

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestToHM(String endpoint, org.apache.avro.generic.IndexedRecord request, T response) throws GPUdbBase.SubmitException, GPUdbException
      Submits an arbitrary request to the GPUdb host manager and saves the response into a pre-created response object. The request and response objects must implement the Avro IndexedRecord interface.
      Type Parameters:
      T - the type of the response object
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      request - the request object
      response - the response object
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestToHM

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestToHM(String endpoint, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbException
      Submits an arbitrary request to the GPUdb host manager and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true.
      Type Parameters:
      T - the type of the response object
      Parameters:
      endpoint - the GPUdb endpoint to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      url - the URL to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequest

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequest(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. Optionally, the timeout period can be set in milliseconds. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      url - the URL to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      responseTimeout - a positive integer representing the number of milliseconds to use for response timeout
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      url - the URL to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public Map<String,Object> submitRequestRaw(URL url, String payload, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits a JSON payload to GPUdb via the specified URL and returns the response as a map of key/value pairs, optionally compressing the request before sending. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      payload - the payload as a JSON String
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, insert statistics will be available under the data key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public String submitRequestRaw(URL url, boolean enableCompression) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      enableCompression - whether to compress the request
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, the response will be available under the data key, including the response records under the records key and whether more matching records exist to be retrieved under the has_more_records key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public <T extends org.apache.avro.generic.IndexedRecord> T submitRequestRaw(URL url, org.apache.avro.generic.IndexedRecord request, T response, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits an arbitrary request to GPUdb via the specified URL and saves the response into a pre-created response object, optionally compressing the request before sending. The request and response objects must implement the Avro IndexedRecord interface. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of requests other than getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants and insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Type Parameters:
      T - the type of the response object
      Parameters:
      url - the URL to send the request to
      request - the request object
      response - the response object
      enableCompression - whether to compress the request
      responseTimeout - a positive integer representing the number of milliseconds to use for response timeout
      Returns:
      the response object (same as response parameter)
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public Map<String,Object> submitRequestRaw(URL url, String payload, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits a JSON payload to GPUdb via the specified URL and returns the response as a map of key/value pairs, optionally compressing the request before sending. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of insertRecordsFromJson(com.gpudb.GPUdbBase.InsertRecordsJsonRequest, com.gpudb.GPUdbBase.JsonOptions) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      payload - the payload as a JSON String
      enableCompression - whether to compress the request
      responseTimeout - a positive integer representing the number of milliseconds to use for response timeout
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, insert statistics will be available under the data key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • submitRequestRaw

      public String submitRequestRaw(URL url, boolean enableCompression, int responseTimeout) throws GPUdbBase.SubmitException, GPUdbBase.GPUdbExitException, GPUdbException
      Submits a request to GPUdb via the specified URL and returns the response as a JSON string, optionally compressing the request before sending. The request will only be compressed if enableCompression is true and the GPUdb constructor was called with the Snappy compression flag set to true. NOTE: This method’s primary use is in support of getRecordsJson(java.lang.String, java.util.List<java.lang.String>, long, long) and its other variants. IMPORTANT: This method will *not* attempt to fail over to an available cluster if the current one goes down.
      Parameters:
      url - the URL to send the request to
      enableCompression - whether to compress the request
      responseTimeout - a positive integer representing the number of milliseconds to use for connection timeout
      Returns:
      The response as a JSON map of values. If the top-level status key is OK, the response will be available under the data key, including the response records under the records key and whether more matching records exist to be retrieved under the has_more_records key; if the status is ERROR, the error message will be available under the message key.
      Throws:
      GPUdbBase.SubmitException - if an error occurs while submitting the request
    • ping

      public void ping() throws GPUdbException
      Verifies that GPUdb is running on the server. IMPORTANT: This method will attempt to fail over to an available cluster if the current one goes down.
      Throws:
      GPUdbException - if an error occurs and/or GPUdb is not running on the server
    • ping

      public String ping(URL url)
      Pings the given URL and returns the response. If no response, returns an empty string. Use the timeout of this GPUdb class.
      Returns:
      the ping response, or an empty string if it fails.
    • ping

      public String ping(URL url, int connectionTimeout)
      Pings the given URL and returns the response. If no response, returns an empty string.
      Parameters:
      url - the URL to which the connection needs to be made
      connectionTimeout - a positive integer representing the number of milliseconds to use for connection and read timeouts
      Returns:
      the ping response, or an empty string if it fails.
    • isKineticaRunning

      public boolean isKineticaRunning(URL url)
      Verifies that GPUdb is running at the given URL (does not do any HA failover). Use a very short timeout so that we don’t wait for a long time if the server at the given URL is not accessible.
      Returns:
      true if Kinetica is running, false otherwise.