Interface InfluxQLQueryApi

All Known Implementing Classes:
InfluxQLQueryApiImpl

@ThreadSafe public interface InfluxQLQueryApi
The InfluxQL can be used with /query compatibility endpoint which uses the database and retention policy specified in the query request to map the request to an InfluxDB bucket.
For more information, see:
  • Method Details

    • query

      @Nonnull InfluxQLQueryResult query(@Nonnull InfluxQLQuery influxQlQuery)
      Executes an InfluxQL query against the legacy endpoint.
      Parameters:
      influxQlQuery - the query
      Returns:
      the result
    • query

      @Nonnull InfluxQLQueryResult query(@Nonnull InfluxQLQuery influxQlQuery, @Nullable InfluxQLQueryResult.Series.ValueExtractor valueExtractor)
      Executes an InfluxQL query against the legacy endpoint. The value extractor is called for each resulting column to convert the string value returned by query into a custom type.

      Example:

       InfluxQLQueryResult result = influxQLQueryApi.query(
                   new InfluxQLQuery("SELECT FIRST(\"free\") FROM \"influxql\"", DATABASE_NAME)
                           .setPrecision(InfluxQLQuery.InfluxQLPrecision.SECONDS),
                   (columnName, rawValue, resultIndex, seriesName) -> {
                       switch (columnName) {
                           case "time":
                               return Instant.ofEpochSecond(Long.parseLong(rawValue));
                           case "first":
                               return new BigDecimal(rawValue);
                           default:
                               throw new IllegalArgumentException("unexpected column " + columnName);
                       }
                   }
           );
       
      Parameters:
      influxQlQuery - the query
      valueExtractor - a callback, to convert column values
      Returns:
      the result