Skip to content

Commit

Permalink
refactor: rename percentile to quantile (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Aug 2, 2022
1 parent 382c2f3 commit aca951a
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 167 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
## 6.5.0 [unreleased]

### Breaking Changes

#### FluxDSL
The `percentile()` function renamed to `quantile()`.

### Features
1. [#366](https://github.com/influxdata/influxdb-client-java/pull/356): Added an endpoint to query with InfluxQL (v1) for more info see [README.md](./client).

### Bug Fixes
1. [#390](https://github.com/influxdata/influxdb-client-java/pull/390): Rename `percentile()` function renamed to `quantile()` [FluxDSL]

### Dependencies
Update dependencies:

Expand Down
26 changes: 13 additions & 13 deletions flux-dsl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,26 +519,26 @@ Flux flux = Flux
.min();
```

### percentile
Percentile is both an aggregate operation and a selector operation depending on selected options.
In the aggregate methods, it outputs the value that represents the specified percentile of the non null record as a float [[doc](http://bit.ly/flux-spec#percentile-aggregate)].
- `columns` - specifies a list of columns to aggregate. Defaults to `_value`. [array of strings]
- `percentile` - value between 0 and 1 indicating the desired percentile. [float]
- `method` - percentile provides 3 methods for computation:
- `estimate_tdigest` - an aggregate result that uses a tdigest data structure to compute an accurate percentile estimate on large data sources.
- `exact_mean` - an aggregate result that takes the average of the two points closest to the percentile value.
- `exact_selector` - Percentile
### quantile
quantile is both an aggregate operation and a selector operation depending on selected options.
In the aggregate methods, it outputs the value that represents the specified quantile of the non null record as a float [[doc](http://bit.ly/flux-spec#quantile-aggregate)].
- `column` - specifies a column to aggregate. Defaults to `_value`. [array of strings]
- `quantile` - value between 0 and 1 indicating the desired quantile. [float]
- `method` - quantile provides 3 methods for computation:
- `estimate_tdigest` - an aggregate result that uses a tdigest data structure to compute an accurate quantile estimate on large data sources.
- `exact_mean` - an aggregate result that takes the average of the two points closest to the quantile value.
- `exact_selector` - Quantile
- `compression` - Compression indicates how many centroids to use when compressing the dataset. A larger number produces a more accurate result at the cost of increased memory requirements. Defaults to `1000`. [float]
```java
Flux flux = Flux
.from("telegraf")
.percentile(0.80F);
.quantile(0.80F);

Flux flux = Flux
.from("telegraf")
.percentile()
.withColumns(new String[]{"value2"})
.withPercentile(0.75F)
.quantile()
.withColumn("value2")
.withQuantile(0.75F)
.withMethod(MethodType.EXACT_MEAN)
.withCompression(2_000F);
```
Expand Down
121 changes: 49 additions & 72 deletions flux-dsl/src/main/java/com/influxdb/query/dsl/Flux.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
import com.influxdb.query.dsl.functions.MaxFlux;
import com.influxdb.query.dsl.functions.MeanFlux;
import com.influxdb.query.dsl.functions.MinFlux;
import com.influxdb.query.dsl.functions.PercentileFlux;
import com.influxdb.query.dsl.functions.PivotFlux;
import com.influxdb.query.dsl.functions.QuantileFlux;
import com.influxdb.query.dsl.functions.RangeFlux;
import com.influxdb.query.dsl.functions.ReduceFlux;
import com.influxdb.query.dsl.functions.RenameFlux;
Expand Down Expand Up @@ -122,7 +122,7 @@
* <li>{@link MaxFlux}</li>
* <li>{@link MeanFlux}</li>
* <li>{@link MinFlux}</li>
* <li>{@link PercentileFlux}</li>
* <li>{@link QuantileFlux}</li>
* <li>{@link PivotFlux}</li>
* <li>{@link RangeFlux}</li>
* <li>{@link RenameFlux}</li>
Expand Down Expand Up @@ -1214,118 +1214,95 @@ public final MinFlux min(@Nonnull final String column) {
}

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
* Quantile is both an aggregate operation and a selector operation depending on selected options.
*
* <h3>The parameters had to be defined by:</h3>
* <ul>
* <li>{@link PercentileFlux#withColumns(String[])}</li>
* <li>{@link PercentileFlux#withColumns(Collection)}</li>
* <li>{@link PercentileFlux#withPercentile(Float)}</li>
* <li>{@link PercentileFlux#withCompression(Float)}</li>
* <li>{@link PercentileFlux#withMethod(String)}</li>
* <li>{@link PercentileFlux#withMethod(PercentileFlux.MethodType)}</li>
* <li>{@link PercentileFlux#withPropertyNamed(String)}</li>
* <li>{@link PercentileFlux#withPropertyNamed(String, String)}</li>
* <li>{@link PercentileFlux#withPropertyValueEscaped(String, String)}</li>
* <li>{@link PercentileFlux#withFunction(String, Object)}</li>
* <li>{@link PercentileFlux#withFunctionNamed(String, String)}</li>
* <li>{@link QuantileFlux#withColumn(String)}</li>
* <li>{@link QuantileFlux#withQuantile(Float)}</li>
* <li>{@link QuantileFlux#withCompression(Float)}</li>
* <li>{@link QuantileFlux#withMethod(String)}</li>
* <li>{@link QuantileFlux#withMethod(QuantileFlux.MethodType)}</li>
* <li>{@link QuantileFlux#withPropertyNamed(String)}</li>
* <li>{@link QuantileFlux#withPropertyNamed(String, String)}</li>
* <li>{@link QuantileFlux#withPropertyValueEscaped(String, String)}</li>
* <li>{@link QuantileFlux#withFunction(String, Object)}</li>
* <li>{@link QuantileFlux#withFunctionNamed(String, String)}</li>
* </ul>
*
* @return {@link PivotFlux}
* @return {@link QuantileFlux}
*/
@Nonnull
public final PercentileFlux percentile() {
return new PercentileFlux(this);
public final QuantileFlux quantile() {
return new QuantileFlux(this);
}

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
* Quantile is both an aggregate operation and a selector operation depending on selected options.
*
* @param percentile value between 0 and 1 indicating the desired percentile
* @return {@link PivotFlux}
* @param quantile value between 0 and 1 indicating the desired quantile
* @return {@link QuantileFlux}
*/
@Nonnull
public final PercentileFlux percentile(@Nonnull final Float percentile) {
public final QuantileFlux quantile(@Nonnull final Float quantile) {

return new PercentileFlux(this)
.withPercentile(percentile);
return new QuantileFlux(this)
.withQuantile(quantile);
}

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
* Quantile is both an aggregate operation and a selector operation depending on selected options.
*
* @param percentile value between 0 and 1 indicating the desired percentile
* @param method method to aggregate
* @return {@link PivotFlux}
* @param quantile value between 0 and 1 indicating the desired quantile
* @param method method to aggregate
* @return {@link QuantileFlux}
*/
@Nonnull
public final PercentileFlux percentile(@Nonnull final Float percentile,
@Nonnull final PercentileFlux.MethodType method) {
public final QuantileFlux quantile(@Nonnull final Float quantile,
@Nonnull final QuantileFlux.MethodType method) {

return new PercentileFlux(this)
.withPercentile(percentile)
return new QuantileFlux(this)
.withQuantile(quantile)
.withMethod(method);
}

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
* Quantile is both an aggregate operation and a selector operation depending on selected options.
*
* @param percentile value between 0 and 1 indicating the desired percentile
* @param quantile value between 0 and 1 indicating the desired quantile
* @param method method to aggregate
* @param compression indicates how many centroids to use when compressing the dataset
* @return {@link PivotFlux}
* @return {@link QuantileFlux}
*/
@Nonnull
public final PercentileFlux percentile(@Nonnull final Float percentile,
@Nonnull final PercentileFlux.MethodType method,
@Nonnull final Float compression) {
public final QuantileFlux quantile(@Nonnull final Float quantile,
@Nonnull final QuantileFlux.MethodType method,
@Nonnull final Float compression) {

return new PercentileFlux(this)
.withPercentile(percentile)
return new QuantileFlux(this)
.withQuantile(quantile)
.withMethod(method)
.withCompression(compression);
}

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
* Quantile is both an aggregate operation and a selector operation depending on selected options.
*
* @param columns specifies a list of columns to aggregate
* @param percentile value between 0 and 1 indicating the desired percentile
* @param column specifies a column to aggregate
* @param quantile value between 0 and 1 indicating the desired quantile
* @param method method to aggregate
* @param compression indicates how many centroids to use when compressing the dataset.
* @return {@link PivotFlux}
* @return {@link QuantileFlux}
*/
@Nonnull
public final PercentileFlux percentile(@Nonnull final String[] columns,
@Nonnull final Float percentile,
@Nonnull final PercentileFlux.MethodType method,
@Nonnull final Float compression) {

return new PercentileFlux(this)
.withColumns(columns)
.withPercentile(percentile)
.withMethod(method)
.withCompression(compression);
}
public final QuantileFlux quantile(@Nonnull final String column,
@Nonnull final Float quantile,
@Nonnull final QuantileFlux.MethodType method,
@Nonnull final Float compression) {

/**
* Percentile is both an aggregate operation and a selector operation depending on selected options.
*
* @param columns specifies a list of columns to aggregate
* @param percentile value between 0 and 1 indicating the desired percentile
* @param method method to aggregate
* @param compression indicates how many centroids to use when compressing the dataset.
* @return {@link PivotFlux}
*/
@Nonnull
public final PercentileFlux percentile(@Nonnull final Collection<String> columns,
@Nonnull final Float percentile,
@Nonnull final PercentileFlux.MethodType method,
@Nonnull final Float compression) {

return new PercentileFlux(this)
.withColumns(columns)
.withPercentile(percentile)
return new QuantileFlux(this)
.withColumn(column)
.withQuantile(quantile)
.withMethod(method)
.withCompression(compression);
}
Expand Down
Loading

0 comments on commit aca951a

Please sign in to comment.