Class InfluxDBClientImpl

java.lang.Object
com.influxdb.v3.client.internal.InfluxDBClientImpl
All Implemented Interfaces:
InfluxDBClient, AutoCloseable

public final class InfluxDBClientImpl extends Object implements InfluxDBClient
Implementation of the InfluxDBClient. It is thread-safe and can be safely shared between threads.

Please use InfluxDBClient to create an instance.

  • Constructor Details

    • InfluxDBClientImpl

      public InfluxDBClientImpl(@Nonnull ClientConfig config)
      Creates an instance using the specified config.

      Please use InfluxDBClient to create an instance.

      Parameters:
      config - the client config.
  • Method Details

    • writeRecord

      public void writeRecord(@Nullable String record)
      Description copied from interface: InfluxDBClient
      Write a record specified in the InfluxDB Line Protocol to the InfluxDB server.
      Specified by:
      writeRecord in interface InfluxDBClient
      Parameters:
      record - the record specified in the InfluxDB Line Protocol, can be null
    • writeRecord

      public void writeRecord(@Nullable String record, @Nonnull WriteOptions options)
      Description copied from interface: InfluxDBClient
      Write a record specified in the InfluxDB Line Protocol to the InfluxDB server.
      Specified by:
      writeRecord in interface InfluxDBClient
      Parameters:
      record - the record specified in the InfluxDB Line Protocol, can be null
      options - the options for writing data to InfluxDB
    • writeRecords

      public void writeRecords(@Nonnull List<String> records)
      Description copied from interface: InfluxDBClient
      Write records specified in the InfluxDB Line Protocol to the InfluxDB server.
      Specified by:
      writeRecords in interface InfluxDBClient
      Parameters:
      records - the records specified in the InfluxDB Line Protocol, cannot be null
    • writeRecords

      public void writeRecords(@Nonnull List<String> records, @Nonnull WriteOptions options)
      Description copied from interface: InfluxDBClient
      Write records specified in the InfluxDB Line Protocol to the InfluxDB server.
      Specified by:
      writeRecords in interface InfluxDBClient
      Parameters:
      records - the records specified in the InfluxDB Line Protocol, cannot be null
      options - the options for writing data to InfluxDB
    • writePoint

      public void writePoint(@Nullable Point point)
      Description copied from interface: InfluxDBClient
      Write a Point to the InfluxDB server.
      Specified by:
      writePoint in interface InfluxDBClient
      Parameters:
      point - the Point to write, can be null

      Note: the timestamp passed will be converted to nanoseconds since the Unix epoch by NanosecondConverter helper class.
      Warning: Fields with null values in a Point are not written to InfluxDB. If such fields are later queried explicitly, for example: SELECT normalField, nullField FROM my_table an error will be thrown.

    • writePoint

      public void writePoint(@Nullable Point point, @Nonnull WriteOptions options)
      Description copied from interface: InfluxDBClient
      Write a Point to the InfluxDB server.
      Specified by:
      writePoint in interface InfluxDBClient
      Parameters:
      point - the Point to write, can be null
      options - the options for writing data to InfluxDB

      Note: the timestamp passed will be converted to nanoseconds since the Unix epoch by NanosecondConverter helper class.
      Warning: Fields with null values in a Point are not written to InfluxDB. If such fields are later queried explicitly, for example: SELECT normalField, nullField FROM my_table an error will be thrown.

    • writePoints

      public void writePoints(@Nonnull List<Point> points)
      Description copied from interface: InfluxDBClient
      Write a list of Point to the InfluxDB server.
      Specified by:
      writePoints in interface InfluxDBClient
      Parameters:
      points - the list of Point to write, cannot be null

      Note: the timestamp passed will be converted to nanoseconds since the Unix epoch by NanosecondConverter helper class.
      Warning: If the provided list contains only one Point, and that Point contains fields with null values, those fields are not written to InfluxDB. If such fields are later queried explicitly, for example: SELECT normalField, nullField FROM my_table an error will be thrown.

    • writePoints

      public void writePoints(@Nonnull List<Point> points, @Nonnull WriteOptions options)
      Description copied from interface: InfluxDBClient
      Write a list of Point to the InfluxDB server.
      Specified by:
      writePoints in interface InfluxDBClient
      Parameters:
      points - the list of Point to write, cannot be null
      options - the options for writing data to InfluxDB

      Note: the timestamp passed will be converted to nanoseconds since the Unix epoch by NanosecondConverter helper class.
      Warning: If the provided list contains only one Point, and that Point contains fields with null values, those fields are not written to InfluxDB. If such fields are later queried explicitly, for example: SELECT normalField, nullField FROM my_table an error will be thrown.

    • query

      @Nonnull public Stream<Object[]> query(@Nonnull String query)
      Description copied from interface: InfluxDBClient
      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
            }
       });
       
      Specified by:
      query in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      Returns:
      Batches of rows returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • query

      @Nonnull public Stream<Object[]> query(@Nonnull String query, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      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
            }
       });
       
      Specified by:
      query in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      options - the options for querying data from InfluxDB
      Returns:
      Batches of rows returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • query

      @Nonnull public Stream<Object[]> query(@Nonnull String query, @Nonnull Map<String,Object> parameters)
      Description copied from interface: InfluxDBClient
      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 where host=$host",
                                                       Map.of("host", "server-a")) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      query in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      parameters - query named parameters
      Returns:
      Batches of rows returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • query

      @Nonnull public Stream<Object[]> query(@Nonnull String query, @Nonnull Map<String,Object> parameters, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      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 where host=$host",
                                                       Map.of("host", "server-a"), options)) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      query in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      parameters - query named parameters
      options - the options for querying data from InfluxDB
      Returns:
      Batches of rows returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • queryRows

      @Nonnull public Stream<Map<String,Object>> queryRows(@Nonnull String query)
      Description copied from interface: InfluxDBClient
      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<Map<String, Object>> rows = client.queryRows("select * from cpu where host=intel")) {
            rows.forEach(row -> {
                // process row
            });
       };
       
      Specified by:
      queryRows in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      Returns:
      Batches of rows returned by the query
    • queryRows

      @Nonnull public Stream<Map<String,Object>> queryRows(@Nonnull String query, @Nonnull Map<String,Object> parameters)
      Description copied from interface: InfluxDBClient
      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<Map<String, Object>> rows = client.queryRows("select * from cpu where host=$host",
                                                                            Map.of("host", "server-a"))) {
            rows.forEach(row -> {
                // process row
            })
       };
       
      Specified by:
      queryRows in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      parameters - query named parameters
      Returns:
      Batches of rows returned by the query
    • queryRows

      @Nonnull public Stream<Map<String,Object>> queryRows(@Nonnull String query, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      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<Map<String, Object>> rows = client.queryRows("select * from cpu where host=intel",
                                                                            options)) {
            rows.forEach(row -> {
                // process row
            })
       };
       
      Specified by:
      queryRows in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      options - the options for querying data from InfluxDB
      Returns:
      Batches of rows returned by the query
    • queryRows

      @Nonnull public Stream<Map<String,Object>> queryRows(@Nonnull String query, @Nonnull Map<String,Object> parameters, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      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<Map<String, Object>> rows = client.queryRows("select * from cpu where host=$host",
                                                                            Map.of("host", "server-a"), options)) {
            rows.forEach(row -> {
                // process row
            })
       };
       
      Specified by:
      queryRows in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      parameters - query named parameters
      options - the options for querying data from InfluxDB
      Returns:
      Batches of rows returned by the query
    • queryPoints

      @Nonnull public Stream<PointValues> queryPoints(@Nonnull String query)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx into Point structure using FlightSQL.

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

       try (Stream<PointValues> rows = client.queryPoints("select * from cpu", options)) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      queryPoints in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      Returns:
      Batches of PointValues returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • queryPoints

      @Nonnull public Stream<PointValues> queryPoints(@Nonnull String query, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx into Point structure using FlightSQL.

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

       try (Stream<PointValues> rows = client.queryPoints("select * from cpu", options)) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      queryPoints in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      options - the options for querying data from InfluxDB
      Returns:
      Batches of PointValues returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • queryPoints

      @Nonnull public Stream<PointValues> queryPoints(@Nonnull String query, @Nonnull Map<String,Object> parameters)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx into Point structure using FlightSQL.

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

       try (Stream<PointValues> rows = client.queryPoints("select * from cpu where host=$host",
                                                                Map.of("host", "server-a"))) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      queryPoints in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      parameters - query named parameters
      Returns:
      Batches of PointValues returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • queryPoints

      @Nonnull public Stream<PointValues> queryPoints(@Nonnull String query, @Nonnull Map<String,Object> parameters, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx into Point structure using FlightSQL.

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

       try (Stream<PointValues> rows = client.queryPoints("select * from cpu where host=$host",
                                                                Map.of("host", "server-a"),
                                                                options)) {
            rows.forEach(row -> {
                // process row
            }
       });
       
      Specified by:
      queryPoints in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      parameters - query named parameters
      options - the options for querying data from InfluxDB
      Returns:
      Batches of PointValues returned by the query

      Note: the timestamp will be returned as a number of nanoseconds since the Unix epoch

    • queryBatches

      @Nonnull public Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches(@Nonnull String query)
      Description copied from interface: InfluxDBClient
      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
            }
       });
       
      Specified by:
      queryBatches in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      Returns:
      Batches of rows returned by the query
    • queryBatches

      @Nonnull public Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches(@Nonnull String query, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx using FlightSQL.
       try (Stream<VectorSchemaRoot> batches = client.queryBatches("select * from cpu", options)) {
            batches.forEach(batch -> {
                // process batch
            }
       });
       
      Specified by:
      queryBatches in interface InfluxDBClient
      Parameters:
      query - the 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 public Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches(@Nonnull String query, @Nonnull Map<String,Object> parameters)
      Description copied from interface: InfluxDBClient
      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 where host=$host",
                                                                         Map.of("host", "server-a"))) {
            batches.forEach(batch -> {
                // process batch
            }
       });
       
      Specified by:
      queryBatches in interface InfluxDBClient
      Parameters:
      query - the SQL query string to execute, cannot be null
      parameters - query named parameters
      Returns:
      Batches of rows returned by the query
    • queryBatches

      @Nonnull public Stream<org.apache.arrow.vector.VectorSchemaRoot> queryBatches(@Nonnull String query, @Nonnull Map<String,Object> parameters, @Nonnull QueryOptions options)
      Description copied from interface: InfluxDBClient
      Query data from InfluxDB IOx using FlightSQL.
       try (Stream<VectorSchemaRoot> batches = client.queryBatches("select * from cpu where host=$host",
                                                                         Map.of("host", "server-a"),
                                                                         options)) {
            batches.forEach(batch -> {
                // process batch
            }
       });
       
      Specified by:
      queryBatches in interface InfluxDBClient
      Parameters:
      query - the query string to execute, cannot be null
      parameters - query named parameters
      options - the options for querying data from InfluxDB
      Returns:
      Batches of rows returned by the query
    • getServerVersion

      public String getServerVersion()
      Description copied from interface: InfluxDBClient
      Get InfluxDB server version.
      Specified by:
      getServerVersion in interface InfluxDBClient
      Returns:
      a string representing the server version. Returns null if the server version can't be determined.
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception