Prerequisite
You can use the client by installing and includingMaven
or Gradle
.
For information on how to install Maven, visit Installing Apache Maven.
Example of how to including the Maven dependency to use the client:
Example of how to including the Gradle dependency to use the client:
Usage
Here’s an example of how to use thepinot-java-client
to query Pinot.
Connection Factory
The client provides aConnectionFactory
class to create connections to a Pinot cluster. To create a connection, include a comma-separated list of the brokers in the cluster. For example, ("broker-1:1234", "broker-2:1234", ...);
Query methods
Query using one of the following methods:- For blocking queries, use the following request format:
Connection.execute(org.apache.pinot.client.Request)
- For asynchronous queries that return a future object, use the following request format:
Connection.executeAsync(org.apache.pinot.client.Request)
PreparedStatement
(which isn’t stored, so won’t decrease the subsequent query performance).
Result set
Access results using variousget
methods on the first ResultSet
with the getResultSet(int)
method.
Authentication
Pinot supports basic HTTP authorization, which can be enabled for your cluster using configuration. To support basic HTTP authorization in your client-side Java applications, make sure you are using Pinot Java Client 0.10.0+ or building from the latest Pinot snapshot. The following code snippet shows you how to connect to and query a Pinot cluster that has basic HTTP authorization enabled when using the Java client.Configuring client time-out
The following timeouts can be set:- brokerConnectTimeoutMs (default 2000)
- brokerReadTimeoutMs (default 60000)
- brokerHandshakeTimeoutMs (default 2000)
- controllerConnectTimeoutMs (default 2000)
- controllerReadTimeoutMs (default 60000)
- controllerHandshakeTimeoutMs (default 2000)
Obtaining Username and Password
You can cenerate an API token in the Data Portal or using the REST API. Then, obtain the username and password from the service token Th username and password are used to authorize your API requests.Finding Your Broker URL
To find the correct Broker URL for your table in StarTree Cloud:- Access the Data Portal.
- Click on Tables.
- Select the specific table you want to query.
- From the browser address bar, copy the URL to your Pinot cluster. For example, if the URL shown is
https://dp.1abcde6.cp.s7e.startree.cloud/tables
, then the Broker URL for the table will bebroker.pinot.1abcde6.cp.s7e.startree.cloud
.