ATEST-371

This commit is contained in:
Fabian Märki
2016-06-09 10:15:02 +02:00
parent 24daa85e0b
commit 738d87bc16
4 changed files with 15 additions and 15 deletions

View File

@ -289,7 +289,7 @@ It is possible (and recommended) to aggregate queried data.
- **aggregationType**: Specifies the type of aggregation (see [here](https://github.psi.ch/sf_daq/ch.psi.daq.domain/blob/master/src/main/java/ch/psi/daq/domain/query/operation/AggregationType.java)). The default type is *value* aggregation (e.g., sum([1,2,3])=6). Alternatively, it is possible to define *index* aggregation for multiple arrays in combination with binning (e.g., sum([1,2,3], [3,2,1]) = [4,4,4]). - **aggregationType**: Specifies the type of aggregation (see [here](https://github.psi.ch/sf_daq/ch.psi.daq.domain/blob/master/src/main/java/ch/psi/daq/domain/query/operation/AggregationType.java)). The default type is *value* aggregation (e.g., sum([1,2,3])=6). Alternatively, it is possible to define *index* aggregation for multiple arrays in combination with binning (e.g., sum([1,2,3], [3,2,1]) = [4,4,4]).
- **aggregations**: Array of requested aggregations (see [here](https://github.psi.ch/sf_daq/ch.psi.daq.domain/blob/master/src/main/java/ch/psi/daq/domain/query/operation/Aggregation.java) for possible values). These values will be added to the *data* array response. - **aggregations**: Array of requested aggregations (see [here](https://github.psi.ch/sf_daq/ch.psi.daq.domain/blob/master/src/main/java/ch/psi/daq/domain/query/operation/Aggregation.java) for possible values). These values will be added to the *data* array response.
- **nrOfBins**: Activates data binning. Specifies the number of bins the pulse/time range should be divided into. - **nrOfBins**: Activates data binning. Specifies the number of bins the pulse/time range should be divided into.
- **msPerBin**: Activates data binning. Specifies the number of milliseconds per bin for time-range queries (using number of milliseconds makes this binning strategy consistent between channel with different update frequencies). - **durationPerBin**: Activates data binning. Specifies the duration per bin for time-range queries (using duration makes this binning strategy consistent between channel with different update frequencies). The duration is defined as a [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) duration (e.g., `PT1H` for 1 hour, `PT2S` for 2 seconds, `PT0.05S` for 50 milliseconds etc.). The resolution is in milliseconds and thus the minimal duration is 1 millisecond.
- **pulsesPerBin**: Activates data binning. Specifies the number of pulses per bin for pulse-range queries (using number of pulses makes this binning strategy consistent between channel with different update frequencies). - **pulsesPerBin**: Activates data binning. Specifies the number of pulses per bin for pulse-range queries (using number of pulses makes this binning strategy consistent between channel with different update frequencies).
@ -795,9 +795,9 @@ Illustration of array value aggregation with additional binning:
![Value Aggregation with Binning](doc/images/Value_Binning_NrOfBins.png) ![Value Aggregation with Binning](doc/images/Value_Binning_NrOfBins.png)
#### Value Aggregation with Binning (msPerBin/pulsesPerBin) #### Value Aggregation with Binning (durationPerBin/pulsesPerBin)
**msPerBin** specifies the number of milliseconds per bin for time-range queries (using number of milliseconds makes this binning strategy consistent between channel with different update frequencies). **durationPerBin** specifies the duration per bin for time-range queries (using duration makes this binning strategy consistent between channel with different update frequencies). The duration is defined as a [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) duration (e.g., `PT1H` for 1 hour, `PT2S` for 2 seconds, `PT0.05S` for 50 milliseconds etc.). The resolution is in milliseconds and thus the minimal duration is 1 millisecond.
**pulsesPerBin** specifies the number of pulses per bin for pulse-range queries (using number of pulses makes this binning strategy consistent between channel with different update frequencies). **pulsesPerBin** specifies the number of pulses per bin for pulse-range queries (using number of pulses makes this binning strategy consistent between channel with different update frequencies).

View File

@ -56,19 +56,19 @@ public class QueryValidator implements Validator {
if (query.getAggregation() != null) { if (query.getAggregation() != null) {
// check if only one binning element is defined // check if only one binning element is defined
long msPerBin = query.getAggregation().getMsPerBin(); long durationPerBin = query.getAggregation().getDurationPerBin();
long pulsesPerBin = query.getAggregation().getPulsesPerBin(); long pulsesPerBin = query.getAggregation().getPulsesPerBin();
int nrOfBins = query.getAggregation().getNrOfBins(); int nrOfBins = query.getAggregation().getNrOfBins();
if ((msPerBin != Request.NOT_SET && (pulsesPerBin != Request.NOT_SET || nrOfBins != Request.NOT_SET)) if ((durationPerBin != Request.NOT_SET && (pulsesPerBin != Request.NOT_SET || nrOfBins != Request.NOT_SET))
|| (pulsesPerBin != Request.NOT_SET && (msPerBin != Request.NOT_SET || nrOfBins != Request.NOT_SET)) || (pulsesPerBin != Request.NOT_SET && (durationPerBin != Request.NOT_SET || nrOfBins != Request.NOT_SET))
|| (nrOfBins != Request.NOT_SET && (msPerBin != Request.NOT_SET || pulsesPerBin != Request.NOT_SET))) { || (nrOfBins != Request.NOT_SET && (durationPerBin != Request.NOT_SET || pulsesPerBin != Request.NOT_SET))) {
errors.reject("msPerBin", "Only one binning element must be defined."); errors.reject("durationPerBin", "Only one binning element must be defined.");
errors.reject("pulsesPerBin", "Only one binning element must be defined."); errors.reject("pulsesPerBin", "Only one binning element must be defined.");
errors.reject("nrOfBins", "Only one binning element must be defined."); errors.reject("nrOfBins", "Only one binning element must be defined.");
} }
if (query.getRange().isPulseIdRangeDefined() && msPerBin != Request.NOT_SET) { if (query.getRange().isPulseIdRangeDefined() && durationPerBin != Request.NOT_SET) {
errors.reject("msPerBin", "Pulse range queries only support pulse based binning."); errors.reject("durationPerBin", "Pulse range queries only support pulse based binning.");
} }
if (query.getRange().isTimeRangeDefined() && pulsesPerBin != Request.NOT_SET) { if (query.getRange().isTimeRangeDefined() && pulsesPerBin != Request.NOT_SET) {
errors.reject("pulsesPerBin", "Time range queries only support time based binning."); errors.reject("pulsesPerBin", "Time range queries only support time based binning.");

View File

@ -843,7 +843,7 @@ public class QueryRestControllerCsvTest extends AbstractDaqRestTest {
startDate, startDate,
endDate), endDate),
channels); channels);
request.setAggregation(new AggregationDescriptor().setMsPerBin(100).setAggregations(aggregations)); request.setAggregation(new AggregationDescriptor().setDurationPerBin(100).setAggregations(aggregations));
request.setResponse(new CSVHTTPResponse()); request.setResponse(new CSVHTTPResponse());
LinkedHashSet<QueryField> queryFields = new LinkedHashSet<>(); LinkedHashSet<QueryField> queryFields = new LinkedHashSet<>();

View File

@ -598,7 +598,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
new RequestRangeDate( new RequestRangeDate(
startDate, startDate,
endDate), endDate),
new AggregationDescriptor().setMsPerBin(100), new AggregationDescriptor().setDurationPerBin(100),
TEST_CHANNEL_01); TEST_CHANNEL_01);
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
@ -711,7 +711,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
new RequestRangePulseId( new RequestRangePulseId(
10, 10,
11), 11),
new AggregationDescriptor().setMsPerBin(1000), new AggregationDescriptor().setDurationPerBin(1000),
TEST_CHANNEL_NAMES); TEST_CHANNEL_NAMES);
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);
@ -755,7 +755,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest {
new RequestRangePulseId( new RequestRangePulseId(
10, 10,
11), 11),
new AggregationDescriptor().setMsPerBin(1000).setNrOfBins(100), new AggregationDescriptor().setDurationPerBin(1000).setNrOfBins(100),
TEST_CHANNEL_NAMES); TEST_CHANNEL_NAMES);
String content = mapper.writeValueAsString(request); String content = mapper.writeValueAsString(request);