You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org> on 2023/06/04 05:08:06 UTC

[GitHub] [datasketches-java] github-code-scanning[bot] commented on a diff in pull request #447: Interim 1 towards KllItemsSketch - works

github-code-scanning[bot] commented on code in PR #447:
URL: https://github.com/apache/datasketches-java/pull/447#discussion_r1216203600


##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);
+
+  abstract void setMaxItem(T item);
+
+  abstract void setMinItem(T 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 KllItemsSketch<T> other) {

Review Comment:
   ## Confusing overloading of methods
   
   Method KllItemsProxy.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/563)



##########
src/test/java/org/apache/datasketches/kll/KllDoublesSketchTest.java:
##########
@@ -415,7 +415,7 @@
     sketch1.update(1);
     final byte[] bytes = sketch1.toByteArray();
     final KllDoublesSketch sketch2 = KllDoublesSketch.heapify(Memory.wrap(bytes));
-    assertEquals(bytes.length, sketch1.getSerializedSizeBytes());
+    assertEquals(bytes.length, sketch1.getCurrentCompactSerializedSizeBytes());

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [KllSketch.getCurrentCompactSerializedSizeBytes](1) should be avoided because it has been deprecated.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/71)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);
+
+  abstract void setMaxItem(T item);
+
+  abstract void setMinItem(T item);

Review Comment:
   ## Useless parameter
   
   The parameter 'item' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/565)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);
+
+  abstract void setMaxItem(T item);

Review Comment:
   ## Useless parameter
   
   The parameter 'item' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/566)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);

Review Comment:
   ## Useless parameter
   
   The parameter 'index' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/567)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);
+
+  abstract void setMaxItem(T item);
+
+  abstract void setMinItem(T 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 KllItemsSketch<T> other) {

Review Comment:
   ## Useless parameter
   
   The parameter 'other' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/564)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);

Review Comment:
   ## Useless parameter
   
   The parameter 'Items' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/569)



##########
src/main/java/org/apache/datasketches/kll/KllItemsProxy.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+abstract class KllItemsProxy<T> extends KllSketch {
+
+  KllItemsProxy() {
+    super(SketchType.ITEMS_SKETCH, null, null);
+  }
+
+  /**
+   * @return full size of internal items array including garbage.
+   */
+  abstract T[] getItemsArray();
+
+  abstract T getSingleItem();
+
+  abstract T getMaxItem();
+
+  abstract T getMinItem();
+
+  abstract void setItemsArray(T[] Items);
+
+  abstract void setItemsArrayAt(int index, T item);

Review Comment:
   ## Useless parameter
   
   The parameter 'item' is never used.
   
   [Show more details](https://github.com/apache/datasketches-java/security/code-scanning/568)



-- 
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