Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
[To dev/1.3] Pipe: Added max / min function to aggregate-processor (#15459)#15469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.AggregatedResultOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.CustomizedReadableIntermediateResults; | ||
| import org.apache.tsfile.enums.TSDataType; | ||
| import org.apache.tsfile.utils.Pair; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| public class MaxValueOperator implements AggregatedResultOperator { | ||
| @Override | ||
| public String getName() { | ||
| return "max"; | ||
| } | ||
| @Override | ||
| public void configureSystemParameters(final Map<String, String> systemParams) { | ||
| // Do nothing | ||
| } | ||
| @Override | ||
| public Set<String> getDeclaredIntermediateValueNames() { | ||
| return Collections.singleton("max"); | ||
| } | ||
| @Override | ||
| public Pair<TSDataType, Object> terminateWindow( | ||
| final TSDataType measurementDataType, | ||
| final CustomizedReadableIntermediateResults intermediateResults) { | ||
| return new Pair<>(measurementDataType, intermediateResults.getObject("max")); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.AggregatedResultOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.CustomizedReadableIntermediateResults; | ||
| import org.apache.tsfile.enums.TSDataType; | ||
| import org.apache.tsfile.utils.Pair; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| public class MinValueOperator implements AggregatedResultOperator { | ||
| @Override | ||
| public String getName() { | ||
| return "min"; | ||
| } | ||
| @Override | ||
| public void configureSystemParameters(final Map<String, String> systemParams) { | ||
| // Do nothing | ||
| } | ||
| @Override | ||
| public Set<String> getDeclaredIntermediateValueNames() { | ||
| return Collections.singleton("min"); | ||
| } | ||
| @Override | ||
| public Pair<TSDataType, Object> terminateWindow( | ||
| final TSDataType measurementDataType, | ||
| final CustomizedReadableIntermediateResults intermediateResults) { | ||
| return new Pair<>(measurementDataType, intermediateResults.getObject("min")); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric; | ||
| public class MaxOperator extends AbstractSameTypeNumericOperator { | ||
| @Override | ||
| public String getName() { | ||
| return "max"; | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(int initialInput, long initialTimestamp) { | ||
| intValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(long initialInput, long initialTimestamp) { | ||
| longValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final float initialInput, final long initialTimestamp) { | ||
| floatValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final double initialInput, final long initialTimestamp) { | ||
| doubleValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public void updateValue(final int input, final long timestamp) { | ||
| intValue = Math.max(intValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final long input, final long timestamp) { | ||
| longValue = Math.max(longValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final float input, final long timestamp) { | ||
| floatValue = Math.max(floatValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final double input, final long timestamp) { | ||
| doubleValue = Math.max(doubleValue, input); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric; | ||
| public class MinOperator extends AbstractSameTypeNumericOperator { | ||
| @Override | ||
| public String getName() { | ||
| return "min"; | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final int initialInput, final long initialTimestamp) { | ||
| intValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final long initialInput, final long initialTimestamp) { | ||
| longValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final float initialInput, final long initialTimestamp) { | ||
| floatValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public boolean initAndGetIsSupport(final double initialInput, final long initialTimestamp) { | ||
| doubleValue = initialInput; | ||
| return super.initAndGetIsSupport(initialInput, initialTimestamp); | ||
| } | ||
| @Override | ||
| public void updateValue(final int input, final long timestamp) { | ||
| intValue = Math.min(intValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final long input, final long timestamp) { | ||
| longValue = Math.min(longValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final float input, final long timestamp) { | ||
| floatValue = Math.min(floatValue, input); | ||
| } | ||
| @Override | ||
| public void updateValue(final double input, final long timestamp) { | ||
| doubleValue = Math.min(doubleValue, input); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,6 +25,8 @@ | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.CrestFactorOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.FormFactorOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.KurtosisOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.MaxValueOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.MinValueOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.PeakOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.PulseFactorOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.aggregatedresult.standardstatistics.RootMeanSquareOperator; | ||
| @@ -33,6 +35,8 @@ | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.IntermediateResultOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric.AbsoluteMaxOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric.IntegralPoweredSumOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric.MaxOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.sametype.numeric.MinOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.specifictype.doubletype.FractionPoweredSumOperator; | ||
| import org.apache.iotdb.db.pipe.processor.aggregate.operator.intermediateresult.specifictype.integertype.CountOperator; | ||
| @@ -54,6 +58,8 @@ public Set<AggregatedResultOperator> getAggregatorOperatorSet() { | ||
| new FormFactorOperator(), | ||
| new KurtosisOperator(), | ||
| new PeakOperator(), | ||
| new MaxValueOperator(), | ||
| new MinValueOperator(), | ||
| new PulseFactorOperator(), | ||
| new RootMeanSquareOperator(), | ||
| new SkewnessOperator(), | ||
| @@ -71,6 +77,8 @@ public Set<Supplier<IntermediateResultOperator>> getIntermediateResultOperatorSu | ||
| () -> new IntegralPoweredSumOperator(1), | ||
| () -> new IntegralPoweredSumOperator(2), | ||
| () -> new IntegralPoweredSumOperator(3), | ||
| () -> new IntegralPoweredSumOperator(4)))); | ||
| () -> new IntegralPoweredSumOperator(4), | ||
| MaxOperator::new, | ||
CopilotAI | ||
| MinOperator::new))); | ||
| } | ||
| } | ||
CopilotAIMay 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] For consistency with other similar operator implementations, consider declaring the method parameters as final.