Class InfluxQLQueryApiImpl

All Implemented Interfaces:
InfluxQLQueryApi

public class InfluxQLQueryApiImpl extends AbstractQueryApi implements InfluxQLQueryApi
  • Constructor Details

  • Method Details

    • query

      @Nonnull public InfluxQLQueryResult query(@Nonnull InfluxQLQuery influxQlQuery)
      Description copied from interface: InfluxQLQueryApi
      Executes an InfluxQL query against the legacy endpoint.
      Specified by:
      query in interface InfluxQLQueryApi
      Parameters:
      influxQlQuery - the query
      Returns:
      the result
    • query

      @Nonnull public InfluxQLQueryResult query(@Nonnull InfluxQLQuery influxQlQuery, @Nullable InfluxQLQueryResult.Series.ValueExtractor valueExtractor)
      Description copied from interface: InfluxQLQueryApi
      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);
                       }
                   }
           );
       
      Specified by:
      query in interface InfluxQLQueryApi
      Parameters:
      influxQlQuery - the query
      valueExtractor - a callback, to convert column values
      Returns:
      the result