You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by "leerho (via GitHub)" <gi...@apache.org> on 2023/06/01 00:44:25 UTC

[GitHub] [datasketches-java] leerho opened a new pull request, #448: Revert items changes prepare4.1.0

leerho opened a new pull request, #448:
URL: https://github.com/apache/datasketches-java/pull/448

   Removed partial ItemsSketch work.
   
   Left some TODOs as place holders.
   
   Left improvements over 4.0.0.
   
   This becomes the basis for 3.1.0 changes.
   
   Runs all unit tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] leerho merged pull request #448: Revert items changes prepare4.1.0

Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho merged PR #448:
URL: https://github.com/apache/datasketches-java/pull/448


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] leerho commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213824250


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -31,19 +31,22 @@
 import static org.apache.datasketches.common.Util.isOdd;
 import static org.apache.datasketches.kll.KllPreambleUtil.DATA_START_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.DATA_START_ADR_SINGLE_ITEM;
-import static org.apache.datasketches.kll.KllPreambleUtil.DOUBLES_SKETCH_BIT_MASK;
 import static org.apache.datasketches.kll.KllPreambleUtil.EMPTY_BIT_MASK;
+import static org.apache.datasketches.kll.KllPreambleUtil.FAMILY_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.FLAGS_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.KLL_FAMILY;
 import static org.apache.datasketches.kll.KllPreambleUtil.K_SHORT_ADR;
+import static org.apache.datasketches.kll.KllPreambleUtil.M_BYTE_ADR;
+import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_EMPTY_SINGLE;
 import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_FULL;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_EMPTY_FULL;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_SINGLE;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_UPDATABLE;
+import static org.apache.datasketches.kll.KllPreambleUtil.SER_VER_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.SINGLE_ITEM_BIT_MASK;
 import static org.apache.datasketches.kll.KllPreambleUtil.UPDATABLE_BIT_MASK;
-import static org.apache.datasketches.kll.KllPreambleUtil.setMemoryDoubleSketchFlag;
+//import static org.apache.datasketches.kll.KllPreambleUtil.setMemoryDoubleSketchFlag;

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] leerho commented on pull request #448: Revert items changes prepare4.1.0

Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#issuecomment-1573002445

   You must have removed this because it doesn't show up on github
   
   On Thu, Jun 1, 2023 at 5:13 PM Alexander Saydakov ***@***.***>
   wrote:
   
   > ***@***.**** commented on this pull request.
   > ------------------------------
   >
   > In src/main/java/org/apache/datasketches/kll/KllHelper.java
   > <https://github.com/apache/datasketches-java/pull/448#discussion_r1213791700>
   > :
   >
   > >      }
   > +    //TODO add items
   >
   > what does this mean?
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/datasketches-java/pull/448#pullrequestreview-1456477575>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/ADCXRQSV6SAJNXW7JQ5TMA3XJEVZLANCNFSM6AAAAAAYWF5KLU>
   > .
   > You are receiving this because you authored the thread.Message ID:
   > ***@***.***>
   >
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213791700


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -237,10 +244,11 @@ static void compressWhileUpdatingSketch(final KllSketch sketch) {
       }
       for (int lvl = 0; lvl < level; lvl++) {
         newIndex = myLevelsArr[lvl] + halfAdjPop; //adjust boundary
-        sketch.setLevelsArrayAt(lvl, newIndex);
+        fltSk.setLevelsArrayAt(lvl, newIndex);
       }
-      sketch.setFloatItemsArray(myFloatItemsArr);
+      fltSk.setFloatItemsArray(myFloatItemsArr);
     }
+    //TODO add items

Review Comment:
   what does this mean?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] github-code-scanning[bot] commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1212451635


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -562,20 +605,24 @@
   static byte[] toCompactByteArrayImpl(final KllSketch sketch) {
     if (sketch.isEmpty()) { return fastEmptyCompactByteArray(sketch); }
     if (sketch.isSingleItem()) { return fastSingleItemCompactByteArray(sketch); }
+
     final byte[] byteArr = new byte[sketch.getCurrentCompactSerializedSizeBytes()];
     final WritableMemory wmem = WritableMemory.writableWrap(byteArr);
     loadFirst8Bytes(sketch, wmem, false);
     if (sketch.getN() == 0) { return byteArr; } //empty
-    final boolean doubleType = (sketch.sketchType == DOUBLES_SKETCH);
+    final KllDoublesSketch dblSk = (sketch.sketchType == DOUBLES_SKETCH) ? (KllDoublesSketch)sketch : null;
+    final KllFloatsSketch fltSk = (sketch.sketchType == FLOATS_SKETCH) ? (KllFloatsSketch)sketch : null;
+    //TODO add items
 
     //load data
     int offset = DATA_START_ADR_SINGLE_ITEM;
     final int[] myLevelsArr = sketch.getLevelsArray();
     if (sketch.getN() == 1) { //single item
-      if (doubleType) {
-        wmem.putDouble(offset,  sketch.getDoubleItemsArray()[myLevelsArr[0]]);
-      } else {
-        wmem.putFloat(offset, sketch.getFloatItemsArray()[myLevelsArr[0]]);
+      switch (sketch.sketchType) {
+        case DOUBLES_SKETCH : wmem.putDouble(offset,  dblSk.getDoubleItemsArray()[myLevelsArr[0]]); break;

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [dblSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/550)



##########
src/main/java/org/apache/datasketches/kll/KllFloatsProxy.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.datasketches.kll;
+
+import static org.apache.datasketches.kll.KllSketch.Error.TGT_IS_READ_ONLY;
+import static org.apache.datasketches.kll.KllSketch.Error.kllSketchThrow;
+
+import org.apache.datasketches.memory.MemoryRequestServer;
+import org.apache.datasketches.memory.WritableMemory;
+
+abstract class KllFloatsProxy extends KllSketch {
+
+  KllFloatsProxy(final WritableMemory wmem, final MemoryRequestServer memReqSvr) {
+    super(SketchType.FLOATS_SKETCH, wmem, memReqSvr);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract float[] getFloatItemsArray();
+
+  abstract float getFloatSingleItem();
+
+  abstract float getMaxFloatItem();
+
+  abstract float getMinFloatItem();
+
+  abstract void setFloatItemsArray(float[] floatItems);
+
+  abstract void setFloatItemsArrayAt(int index, float item);
+
+  abstract void setMaxFloatItem(float item);
+
+  abstract void setMinFloatItem(float item);
+
+  /**
+   * Merges another sketch into this one.
+   * Attempting to merge a KllDoublesSketch with a KllFloatsSketch will
+   * throw an exception.
+   * @param other sketch to merge into this one
+   */
+  public final void merge(final KllFloatsSketch other) {

Review Comment:
   ## Confusing overloading of methods
   
   Method KllFloatsProxy.merge(..) could be confused with overloaded method [KllSketch.merge](1), since dispatch depends on static types.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/548)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -665,28 +743,44 @@
     } else {
       sb.append("   Compact Storage Bytes  : ").append(sketch.getCurrentCompactSerializedSizeBytes()).append(Util.LS);
     }
-
-    if (doubleType) {
-      sb.append("   Min Item               : ").append(sketch.getMinDoubleItem()).append(Util.LS);
-      sb.append("   Max Item               : ").append(sketch.getMaxDoubleItem()).append(Util.LS);
-    } else {
-      sb.append("   Min Item               : ").append(sketch.getMinFloatItem()).append(Util.LS);
-      sb.append("   Max Item               : ").append(sketch.getMaxFloatItem()).append(Util.LS);
+    KllDoublesSketch dblSk = null;
+    KllFloatsSketch fltSk = null;
+    //final KllItemsSketch itmSk = null;
+
+    if (sketchType == DOUBLES_SKETCH) {
+      dblSk = (KllDoublesSketch) sketch;
+      sb.append("   Min Item               : ").append(dblSk.getMinDoubleItem()).append(Util.LS);
+      sb.append("   Max Item               : ").append(dblSk.getMaxDoubleItem()).append(Util.LS);
+    } else if (sketchType == FLOATS_SKETCH) {
+      fltSk = (KllFloatsSketch) sketch;
+      sb.append("   Min Item               : ").append(fltSk.getMinFloatItem()).append(Util.LS);
+      sb.append("   Max Item               : ").append(fltSk.getMaxFloatItem()).append(Util.LS);
     }
+//    else {
+//      itmSk = (KllItemsSketch) sketch;
+//      sb.append("   Min Item               : ").append(itmSk.getMinItem()).append(Util.LS);
+//      sb.append("   Max Item               : ").append(itmSk.getMaxItem()).append(Util.LS);
+//    }
     sb.append("### End sketch summary").append(Util.LS);
 
     double[] myDoubleItemsArr = null;
     float[] myFloatItemsArr = null;
-    if (doubleType) {
-      myDoubleItemsArr = sketch.getDoubleItemsArray();
-    } else {
-      myFloatItemsArr = sketch.getFloatItemsArray();
-    }
+    Object[] myItemsArr = null;
+
     if (withLevels) {
       sb.append(outputLevels(k, m, numLevels, levelsArr));
     }
     if (withData) {
-      sb.append(outputData(doubleType, numLevels, levelsArr, myFloatItemsArr, myDoubleItemsArr));
+      if (sketchType == DOUBLES_SKETCH) {
+        myDoubleItemsArr = dblSk.getDoubleItemsArray();
+        sb.append(outputDoublesData(numLevels, levelsArr, myDoubleItemsArr));
+      } else if (sketchType == FLOATS_SKETCH) {
+        myFloatItemsArr = fltSk.getFloatItemsArray();

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [fltSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/554)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -793,18 +907,21 @@
     float[] myNewFloatItemsArr = null;
     double[] myNewDoubleItemsArr = null;
 
-    if (sketch.sketchType == DOUBLES_SKETCH) {
-      minDouble = sketch.getMinDoubleItem();
-      maxDouble = sketch.getMaxDoubleItem();
-      myCurDoubleItemsArr = sketch.getDoubleItemsArray();
+    if (sketchType == DOUBLES_SKETCH) {
+      minDouble = dblSk.getMinDoubleItem();
+      maxDouble = dblSk.getMaxDoubleItem();
+      myCurDoubleItemsArr = dblSk.getDoubleItemsArray();
       //assert we are following a certain growth scheme
       assert myCurDoubleItemsArr.length == myCurTotalItemsCapacity;
-    } else { //FLOATS_SKETCH
-      minFloat = sketch.getMinFloatItem();
-      maxFloat = sketch.getMaxFloatItem();
-      myCurFloatItemsArr = sketch.getFloatItemsArray();
+    } else if (sketchType == FLOATS_SKETCH) {
+      minFloat = fltSk.getMinFloatItem();

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [fltSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/555)



##########
src/main/java/org/apache/datasketches/kll/KllDoublesProxy.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.datasketches.kll;
+
+import static org.apache.datasketches.kll.KllSketch.Error.TGT_IS_READ_ONLY;
+import static org.apache.datasketches.kll.KllSketch.Error.kllSketchThrow;
+
+import org.apache.datasketches.memory.MemoryRequestServer;
+import org.apache.datasketches.memory.WritableMemory;
+
+abstract class KllDoublesProxy extends KllSketch {
+
+  KllDoublesProxy(final WritableMemory wmem, final MemoryRequestServer memReqSvr) {
+    super(SketchType.DOUBLES_SKETCH, wmem, memReqSvr);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract double[] getDoubleItemsArray();
+
+  abstract double getDoubleSingleItem();
+
+  abstract double getMaxDoubleItem();
+
+  abstract double getMinDoubleItem();
+
+  abstract void setDoubleItemsArray(double[] doubleItems);
+
+  abstract void setDoubleItemsArrayAt(int index, double item);
+
+  abstract void setMaxDoubleItem(double item);
+
+  abstract void setMinDoubleItem(double item);
+
+  /**
+   * Merges another sketch into this one.
+   * Attempting to merge a KllDoublesSketch with a KllFloatsSketch will
+   * throw an exception.
+   * @param other sketch to merge into this one
+   */
+  public final void merge(final KllDoublesSketch other) {

Review Comment:
   ## Confusing overloading of methods
   
   Method KllDoublesProxy.merge(..) could be confused with overloaded method [KllSketch.merge](1), since dispatch depends on static types.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/547)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -590,63 +637,94 @@
       offset += len * Integer.BYTES;
 
       //LOAD MIN, MAX Items FOLLOWED BY ITEMS ARRAY
-      if (doubleType) {
-        wmem.putDouble(offset,sketch.getMinDoubleItem());
-        offset += Double.BYTES;
-        wmem.putDouble(offset, sketch.getMaxDoubleItem());
-        offset += Double.BYTES;
-        wmem.putDoubleArray(offset, sketch.getDoubleItemsArray(), myLevelsArr[0], sketch.getNumRetained());
-      } else {
-        wmem.putFloat(offset, sketch.getMinFloatItem());
-        offset += Float.BYTES;
-        wmem.putFloat(offset, sketch.getMaxFloatItem());
-        offset += Float.BYTES;
-        wmem.putFloatArray(offset, sketch.getFloatItemsArray(), myLevelsArr[0], sketch.getNumRetained());
+      switch (sketch.sketchType) {
+        case DOUBLES_SKETCH : {
+          wmem.putDouble(offset,dblSk.getMinDoubleItem());

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [dblSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/552)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -590,63 +637,94 @@
       offset += len * Integer.BYTES;
 
       //LOAD MIN, MAX Items FOLLOWED BY ITEMS ARRAY
-      if (doubleType) {
-        wmem.putDouble(offset,sketch.getMinDoubleItem());
-        offset += Double.BYTES;
-        wmem.putDouble(offset, sketch.getMaxDoubleItem());
-        offset += Double.BYTES;
-        wmem.putDoubleArray(offset, sketch.getDoubleItemsArray(), myLevelsArr[0], sketch.getNumRetained());
-      } else {
-        wmem.putFloat(offset, sketch.getMinFloatItem());
-        offset += Float.BYTES;
-        wmem.putFloat(offset, sketch.getMaxFloatItem());
-        offset += Float.BYTES;
-        wmem.putFloatArray(offset, sketch.getFloatItemsArray(), myLevelsArr[0], sketch.getNumRetained());
+      switch (sketch.sketchType) {
+        case DOUBLES_SKETCH : {
+          wmem.putDouble(offset,dblSk.getMinDoubleItem());
+          offset += Double.BYTES;
+          wmem.putDouble(offset, dblSk.getMaxDoubleItem());
+          offset += Double.BYTES;
+          wmem.putDoubleArray(offset, dblSk.getDoubleItemsArray(), myLevelsArr[0], sketch.getNumRetained());
+          break;
+        }
+        case FLOATS_SKETCH  : {
+          wmem.putFloat(offset, fltSk.getMinFloatItem());

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [fltSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/553)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -562,20 +605,24 @@
   static byte[] toCompactByteArrayImpl(final KllSketch sketch) {
     if (sketch.isEmpty()) { return fastEmptyCompactByteArray(sketch); }
     if (sketch.isSingleItem()) { return fastSingleItemCompactByteArray(sketch); }
+
     final byte[] byteArr = new byte[sketch.getCurrentCompactSerializedSizeBytes()];
     final WritableMemory wmem = WritableMemory.writableWrap(byteArr);
     loadFirst8Bytes(sketch, wmem, false);
     if (sketch.getN() == 0) { return byteArr; } //empty
-    final boolean doubleType = (sketch.sketchType == DOUBLES_SKETCH);
+    final KllDoublesSketch dblSk = (sketch.sketchType == DOUBLES_SKETCH) ? (KllDoublesSketch)sketch : null;
+    final KllFloatsSketch fltSk = (sketch.sketchType == FLOATS_SKETCH) ? (KllFloatsSketch)sketch : null;
+    //TODO add items
 
     //load data
     int offset = DATA_START_ADR_SINGLE_ITEM;
     final int[] myLevelsArr = sketch.getLevelsArray();
     if (sketch.getN() == 1) { //single item
-      if (doubleType) {
-        wmem.putDouble(offset,  sketch.getDoubleItemsArray()[myLevelsArr[0]]);
-      } else {
-        wmem.putFloat(offset, sketch.getFloatItemsArray()[myLevelsArr[0]]);
+      switch (sketch.sketchType) {
+        case DOUBLES_SKETCH : wmem.putDouble(offset,  dblSk.getDoubleItemsArray()[myLevelsArr[0]]); break;
+        case FLOATS_SKETCH  : wmem.putFloat(offset, fltSk.getFloatItemsArray()[myLevelsArr[0]]); break;

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [fltSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/570)



##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -849,14 +969,14 @@
     //update our sketch with new expanded spaces
     sketch.setNumLevels(myNewNumLevels);
     sketch.setLevelsArray(myNewLevelsArr);
-    if (sketch.sketchType == DOUBLES_SKETCH) {
-      sketch.setMinDoubleItem(minDouble);
-      sketch.setMaxDoubleItem(maxDouble);
-      sketch.setDoubleItemsArray(myNewDoubleItemsArr);
+    if (sketchType == DOUBLES_SKETCH) {
+      dblSk.setMinDoubleItem(minDouble);
+      dblSk.setMaxDoubleItem(maxDouble);
+      dblSk.setDoubleItemsArray(myNewDoubleItemsArr);
     } else { //Float sketch
-      sketch.setMinFloatItem(minFloat);
-      sketch.setMaxFloatItem(maxFloat);
-      sketch.setFloatItemsArray(myNewFloatItemsArr);
+      fltSk.setMinFloatItem(minFloat);

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [fltSk](1) may be null at this access because of [this](2) assignment.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/556)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] leerho commented on pull request #448: Revert items changes prepare4.1.0

Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#issuecomment-1572924155

   This is the basis for 4.1.0.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] leerho commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "leerho (via GitHub)" <gi...@apache.org>.
leerho commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213824545


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -347,7 +355,7 @@ static GrowthStats getGrowthSchemeForGivenN(
       println("Given N         : " + gStats.givenN);
       printf("%10s %10s %20s %13s %15s\n", "NumLevels", "MaxItems", "MaxN", "CompactBytes", "UpdatableBytes");
     }
-    final int typeBytes = (sketchType == DOUBLES_SKETCH) ? Double.BYTES : Float.BYTES;
+    final int typeBytes = sketchType == DOUBLES_SKETCH ? Double.BYTES : Float.BYTES;
     do {
       gStats.numLevels++; //

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#issuecomment-1574323351

   I tried reading and writing KLL float and double sketches from C++ in Java and the other way around. This seems to work fine.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213792410


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -347,7 +355,7 @@ static GrowthStats getGrowthSchemeForGivenN(
       println("Given N         : " + gStats.givenN);
       printf("%10s %10s %20s %13s %15s\n", "NumLevels", "MaxItems", "MaxN", "CompactBytes", "UpdatableBytes");
     }
-    final int typeBytes = (sketchType == DOUBLES_SKETCH) ? Double.BYTES : Float.BYTES;
+    final int typeBytes = sketchType == DOUBLES_SKETCH ? Double.BYTES : Float.BYTES;
     do {
       gStats.numLevels++; //

Review Comment:
   empty comment?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213791914


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -31,19 +31,22 @@
 import static org.apache.datasketches.common.Util.isOdd;
 import static org.apache.datasketches.kll.KllPreambleUtil.DATA_START_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.DATA_START_ADR_SINGLE_ITEM;
-import static org.apache.datasketches.kll.KllPreambleUtil.DOUBLES_SKETCH_BIT_MASK;
 import static org.apache.datasketches.kll.KllPreambleUtil.EMPTY_BIT_MASK;
+import static org.apache.datasketches.kll.KllPreambleUtil.FAMILY_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.FLAGS_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.KLL_FAMILY;
 import static org.apache.datasketches.kll.KllPreambleUtil.K_SHORT_ADR;
+import static org.apache.datasketches.kll.KllPreambleUtil.M_BYTE_ADR;
+import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_EMPTY_SINGLE;
 import static org.apache.datasketches.kll.KllPreambleUtil.PREAMBLE_INTS_FULL;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_EMPTY_FULL;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_SINGLE;
 import static org.apache.datasketches.kll.KllPreambleUtil.SERIAL_VERSION_UPDATABLE;
+import static org.apache.datasketches.kll.KllPreambleUtil.SER_VER_BYTE_ADR;
 import static org.apache.datasketches.kll.KllPreambleUtil.SINGLE_ITEM_BIT_MASK;
 import static org.apache.datasketches.kll.KllPreambleUtil.UPDATABLE_BIT_MASK;
-import static org.apache.datasketches.kll.KllPreambleUtil.setMemoryDoubleSketchFlag;
+//import static org.apache.datasketches.kll.KllPreambleUtil.setMemoryDoubleSketchFlag;

Review Comment:
   should this be removed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on a diff in pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on code in PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#discussion_r1213791700


##########
src/main/java/org/apache/datasketches/kll/KllHelper.java:
##########
@@ -237,10 +244,11 @@ static void compressWhileUpdatingSketch(final KllSketch sketch) {
       }
       for (int lvl = 0; lvl < level; lvl++) {
         newIndex = myLevelsArr[lvl] + halfAdjPop; //adjust boundary
-        sketch.setLevelsArrayAt(lvl, newIndex);
+        fltSk.setLevelsArrayAt(lvl, newIndex);
       }
-      sketch.setFloatItemsArray(myFloatItemsArr);
+      fltSk.setFloatItemsArray(myFloatItemsArr);
     }
+    //TODO add items

Review Comment:
   what does this mean?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[GitHub] [datasketches-java] AlexanderSaydakov commented on pull request #448: Revert items changes prepare4.1.0

Posted by "AlexanderSaydakov (via GitHub)" <gi...@apache.org>.
AlexanderSaydakov commented on PR #448:
URL: https://github.com/apache/datasketches-java/pull/448#issuecomment-1574324935

   I don't see why some package private methods are needed such as getMinFloatItem and getMinDoubleItem


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org