You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by si...@apache.org on 2022/05/26 01:15:30 UTC
[pinot] branch master updated: Address comments for DoubleVectorOpUtils (#8777)
This is an automated email from the ASF dual-hosted git repository.
siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 73316a6cf7 Address comments for DoubleVectorOpUtils (#8777)
73316a6cf7 is described below
commit 73316a6cf7016bf028b002a93b27da1391ce88dd
Author: Jia Guo <ji...@linkedin.com>
AuthorDate: Wed May 25 18:15:25 2022 -0700
Address comments for DoubleVectorOpUtils (#8777)
---
.../aggregation/utils/DoubleVectorOpUtils.java | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/utils/DoubleVectorOpUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/utils/DoubleVectorOpUtils.java
index 2a9e0874af..59427b4a79 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/utils/DoubleVectorOpUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/query/aggregation/utils/DoubleVectorOpUtils.java
@@ -27,20 +27,16 @@ public class DoubleVectorOpUtils {
}
public static DoubleArrayList vectorAdd(DoubleArrayList a, DoubleArrayList b) {
- Preconditions.checkState(a.size() == b.size(), "The two operand arrays are not of the same size! provided %s, %s",
- a.size(), b.size());
- for (int i = 0; i < a.size(); i++) {
- a.elements()[i] += b.elements()[i];
- }
- return a;
+ return vectorAdd(a, b.elements());
}
public static DoubleArrayList vectorAdd(DoubleArrayList a, double[] b) {
- Preconditions.checkState(a.size() == b.length, "The two operand arrays are not of the same size! provided %s, %s",
- a.size(), b.length);
- ;
- for (int i = 0; i < a.size(); i++) {
- a.elements()[i] += b[i];
+ double[] elements = a.elements();
+ int length = elements.length;
+ Preconditions.checkState(length == b.length, "The two operand arrays are not of the same size! provided %s, %s",
+ length, b.length);
+ for (int i = 0; i < length; i++) {
+ elements[i] += b[i];
}
return a;
}
@@ -66,7 +62,8 @@ public class DoubleVectorOpUtils {
public static DoubleArrayList incrementElement(DoubleArrayList a, int offset, double val) {
Preconditions.checkState(a.size() > offset, "The offset %s exceeds the array size!", offset);
- a.elements()[offset] += val;
+ double[] elements = a.elements();
+ elements[offset] += val;
return a;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org