You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2020/01/10 00:40:02 UTC
[incubator-datasketches-vector] branch master updated: Fix LGTM
allerts
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-vector.git
The following commit(s) were added to refs/heads/master by this push:
new 32c1443 Fix LGTM allerts
32c1443 is described below
commit 32c1443774472bb7382b7d88fc22d044c8808dc3
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Jan 9 16:39:54 2020 -0800
Fix LGTM allerts
---
.../vector/decomposition/FrequentDirections.java | 14 +++++++-------
.../datasketches/vector/decomposition/PreambleUtil.java | 2 +-
.../datasketches/vector/matrix/MatrixImplOjAlgo.java | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java b/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java
index c3dff17..c86b025 100644
--- a/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java
+++ b/src/main/java/org/apache/datasketches/vector/decomposition/FrequentDirections.java
@@ -134,7 +134,7 @@ public final class FrequentDirections {
return new FrequentDirections(k, d);
}
- final long offsetBytes = preLongs * Long.BYTES;
+ final long offsetBytes = (long)preLongs * Long.BYTES;
final long mtxBytes = srcMem.getCapacity() - offsetBytes;
final Matrix B = Matrix.heapify(srcMem.region(offsetBytes, mtxBytes), type);
assert B != null;
@@ -209,7 +209,7 @@ public final class FrequentDirections {
* @param fd A Frequent Direction sketch to be merged.
*/
public void update(final FrequentDirections fd) {
- if (fd == null || fd.nextZeroRow_ == 0) {
+ if ((fd == null) || (fd.nextZeroRow_ == 0)) {
return;
}
@@ -293,9 +293,9 @@ public final class FrequentDirections {
final double tmpSvAdj = svAdjustment_ + medianSVSq;
final double[] svList = new double[k_];
- for (int i = 0; i < k_ - 1; ++i) {
+ for (int i = 0; i < (k_ - 1); ++i) {
final double val = sv[i];
- double adjSqSV = val * val - medianSVSq;
+ double adjSqSV = (val * val) - medianSVSq;
if (compensative) { adjSqSV += tmpSvAdj; }
svList[i] = adjSqSV < 0 ? 0.0 : Math.sqrt(adjSqSV);
}
@@ -405,7 +405,7 @@ public final class FrequentDirections {
insertN(memObj, memAddr, n_);
insertSVAdjustment(memObj, memAddr, svAdjustment_);
- memOut.putByteArray(preLongs * Long.BYTES,
+ memOut.putByteArray((long)preLongs * Long.BYTES,
B_.toCompactByteArray(nextZeroRow_, d_), 0, mtxBytes);
return outArr;
@@ -460,8 +460,8 @@ public final class FrequentDirections {
for (int i = 0; i < Math.min(k_, n_); ++i) {
if (sv[i] > 0.0) {
double val = sv[i];
- if (val > 0.0 && applyCompensation) {
- val = Math.sqrt(val * val + svAdjustment_);
+ if ((val > 0.0) && applyCompensation) {
+ val = Math.sqrt((val * val) + svAdjustment_);
}
sb.append(" \t").append(i).append(":\t").append(val).append(LS);
diff --git a/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java b/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java
index 6d2762c..fb0bee2 100644
--- a/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java
+++ b/src/main/java/org/apache/datasketches/vector/decomposition/PreambleUtil.java
@@ -131,7 +131,7 @@ public final class PreambleUtil {
sb.append("Bytes 24-31: SV Adjustment : ").append(svAdjustment).append(LS);
}
- final long numBytes = numRows * d * Double.BYTES;
+ final long numBytes = (long)numRows * d * Double.BYTES;
sb.append("TOTAL Sketch Bytes : ").append(mem.getCapacity()).append(LS)
.append(" Preamble Bytes : ").append(preLongs << 3).append(LS)
.append(" Data Bytes : ").append(numBytes).append(LS)
diff --git a/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java b/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java
index 22708a0..577c7a0 100644
--- a/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java
+++ b/src/main/java/org/apache/datasketches/vector/matrix/MatrixImplOjAlgo.java
@@ -115,7 +115,7 @@ public final class MatrixImplOjAlgo extends Matrix {
final long numElements = mtx_.count();
assert numElements == (mtx_.countColumns() * mtx_.countRows());
- final int outBytes = (int) ((preLongs * Long.BYTES) + (numElements * Double.BYTES));
+ final int outBytes = (int) (((long)preLongs * Long.BYTES) + (numElements * Double.BYTES));
final byte[] outByteArr = new byte[outBytes];
final WritableMemory memOut = WritableMemory.wrap(outByteArr);
final Object memObj = memOut.getArray();
@@ -147,7 +147,7 @@ public final class MatrixImplOjAlgo extends Matrix {
assert numElements < mtx_.count();
- final int outBytes = (int) ((preLongs * Long.BYTES) + (numElements * Double.BYTES));
+ final int outBytes = (int) (((long)preLongs * Long.BYTES) + (numElements * Double.BYTES));
final byte[] outByteArr = new byte[outBytes];
final WritableMemory memOut = WritableMemory.wrap(outByteArr);
final Object memObj = memOut.getArray();
@@ -163,7 +163,7 @@ public final class MatrixImplOjAlgo extends Matrix {
MatrixPreambleUtil.insertNumColumnsUsed(memObj, memAddr, numCols);
// write elements in column-major order
- long offsetBytes = preLongs * Long.BYTES;
+ long offsetBytes = (long)preLongs * Long.BYTES;
for (int c = 0; c < numCols; ++c) {
for (int r = 0; r < numRows; ++r) {
memOut.putDouble(offsetBytes, mtx_.doubleValue(r, c));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org