Fix LGTM allerts
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 @@
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 @@
* @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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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));