Interface InfluxDBClient

  • All Superinterfaces:
    AutoCloseable
    All Known Implementing Classes:
    InfluxDBClientImpl

    public interface InfluxDBClient
    extends AutoCloseable
    The InfluxDBClient interface provides a client for interact with InfluxDB 3. This client supports both writing data to InfluxDB and querying data using the FlightSQL client, which allows you to execute SQL queries against InfluxDB IOx.
    • Method Detail

      • writeRecord

        void writeRecord​(@Nullable
                         String record)
        Write a record specified in the InfluxDB Line Protocol to the InfluxDB server.
        Parameters:
        record - the record specified in the InfluxDB Line Protocol, can be null
      • writeRecord

        void writeRecord​(@Nullable
                         String record,
                         @Nonnull
                         WriteOptions options)
        Write a record specified in the InfluxDB Line Protocol to the InfluxDB server.
        Parameters:
        record - the record specified in the InfluxDB Line Protocol, can be null
        options - the options for writing data to InfluxDB
      • writeRecords

        void writeRecords​(@Nonnull
                          List<String> records)
        Write records specified in the InfluxDB Line Protocol to the InfluxDB server.
        Parameters:
        records - the records specified in the InfluxDB Line Protocol, cannot be null
      • writeRecords

        void writeRecords​(@Nonnull
                          List<String> records,
                          @Nonnull
                          WriteOptions options)
        Write records specified in the InfluxDB Line Protocol to the InfluxDB server.
        Parameters:
        records - the records specified in the InfluxDB Line Protocol, cannot be null
        options - the options for writing data to InfluxDB
      • writePoint

        void writePoint​(@Nullable
                        Point point)
        Write a Point to the InfluxDB server.
        Parameters:
        point - the Point to write, can be null
      • writePoint

        void writePoint​(@Nullable
                        Point point,
                        @Nonnull
                        WriteOptions options)
        Write a Point to the InfluxDB server.
        Parameters:
        point - the Point to write, can be null
        options - the options for writing data to InfluxDB
      • writePoints

        void writePoints​(@Nonnull
                         List<Point> points)
        Write a list of Point to the InfluxDB server.
        Parameters:
        points - the list of Point to write, cannot be null
      • writePoints

        void writePoints​(@Nonnull
                         List<Point> points,
                         @Nonnull
                         WriteOptions options)
        Write a list of Point to the InfluxDB server.
        Parameters:
        points - the list of Point to write, cannot be null
        options - the options for writing data to InfluxDB
      • query

        @Nonnull
        Stream<Object[]> query​(@Nonnull
                               String query)
        Query data from InfluxDB IOx using FlightSQL.

        The result stream should be closed after use, you can use try-resource pattern to close it automatically:

         try (Stream<Object[]> rows = client.query("select * from cpu")) {
              rows.forEach(row -> {
                  // process row
              }
         });
         
        Parameters:
        query - the SQL query string to execute, cannot be null
        Returns:
        Batches of rows returned by the query
      • query

        @Nonnull
        Stream<Object[]> query​(@Nonnull
                               String query,
                               @Nonnull
                               QueryOptions options)
        Query data from InfluxDB IOx using FlightSQL.

        The result stream should be closed after use, you can use try-resource pattern to close it automatically:

         try (Stream<Object[]> rows = client.query("select * from cpu", options)) {
              rows.forEach(row -> {
                  // process row
              }
         });
         
        Parameters:
        query - the SQL query string to execute, cannot be null
        options - the options for querying data from InfluxDB
        Returns:
        Batches of rows returned by the query
      • queryBatches

        @Nonnull
        Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches​(@Nonnull
                                                                      String query)
        Query data from InfluxDB IOx using FlightSQL.

        The result stream should be closed after use, you can use try-resource pattern to close it automatically:

         try (Stream<VectorSchemaRoot> batches = client.queryBatches("select * from cpu")) {
              batches.forEach(batch -> {
                  // process batch
              }
         });
         
        Parameters:
        query - the SQL query string to execute, cannot be null
        Returns:
        Batches of rows returned by the query
      • queryBatches

        @Nonnull
        Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches​(@Nonnull
                                                                      String query,
                                                                      @Nonnull
                                                                      QueryOptions options)
        Query data from InfluxDB IOx using FlightSQL.
         try (Stream<VectorSchemaRoot> batches = client.queryBatches("select * from cpu", options)) {
              batches.forEach(batch -> {
                  // process batch
              }
         });
         
        Parameters:
        query - the SQL query string to execute, cannot be null
        options - the options for querying data from InfluxDB
        Returns:
        Batches of rows returned by the query
      • getInstance

        @Nonnull
        static InfluxDBClient getInstance​(@Nonnull
                                          String host,
                                          @Nullable
                                          char[] token,
                                          @Nullable
                                          String database)
        Creates a new instance of the InfluxDBClient for interacting with an InfluxDB server, simplifying common operations such as writing, querying.
        Parameters:
        host - the URL of the InfluxDB server
        token - the authentication token for accessing the InfluxDB server, can be null
        database - the database to be used for InfluxDB operations, can be null
        Returns:
        new instance of the InfluxDBClient
      • getInstance

        @Nonnull
        static InfluxDBClient getInstance​(@Nonnull
                                          ClientConfig config)
        Creates a new instance of the InfluxDBClient for interacting with an InfluxDB server, simplifying common operations such as writing, querying. For possible configuration options see ClientConfig.
        Parameters:
        config - the configuration for the InfluxDB client
        Returns:
        new instance of the InfluxDBClient