Skip to content
Permalink
Browse files
Fixed issues from latest comments.
  • Loading branch information
leerho committed Mar 30, 2022
1 parent 995ed82 commit 71af0d94f36e370e4a0eff8ced3ae89121070743
Showing 7 changed files with 105 additions and 96 deletions.
@@ -36,8 +36,8 @@
import static org.apache.datasketches.kll.KllPreambleUtil.insertNumLevels;
import static org.apache.datasketches.kll.KllPreambleUtil.insertPreInts;
import static org.apache.datasketches.kll.KllPreambleUtil.insertSerVer;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR32;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR33;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_DIRECT;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_DOUBLE;

import org.apache.datasketches.Family;
import org.apache.datasketches.memory.MemoryRequestServer;
@@ -301,8 +301,8 @@ public KllDoublesSketchIterator iterator() {
* @param other sketch to merge into this one
*/
public void merge(final KllSketch other) {
if (!other.isDirect()) { kllSketchThrow(ERR32); }
if (!other.isDoublesSketch()) { kllSketchThrow(ERR33); }
if (!other.isDirect()) { kllSketchThrow(ERR_SRC_IS_NOT_DIRECT); }
if (!other.isDoublesSketch()) { kllSketchThrow(ERR_SRC_IS_NOT_DOUBLE); }
mergeDoubleImpl(other);
}

@@ -35,8 +35,8 @@
import static org.apache.datasketches.kll.KllPreambleUtil.insertNumLevels;
import static org.apache.datasketches.kll.KllPreambleUtil.insertPreInts;
import static org.apache.datasketches.kll.KllPreambleUtil.insertSerVer;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR32;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR34;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_DIRECT;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_FLOAT;

import org.apache.datasketches.Family;
import org.apache.datasketches.memory.MemoryRequestServer;
@@ -301,8 +301,8 @@ public KllFloatsSketchIterator iterator() {
* @param other sketch to merge into this one
*/
public void merge(final KllSketch other) {
if (!other.isDirect()) { kllSketchThrow(ERR32); }
if (!other.isFloatsSketch()) { kllSketchThrow(ERR34); }
if (!other.isDirect()) { kllSketchThrow(ERR_SRC_IS_NOT_DIRECT); }
if (!other.isFloatsSketch()) { kllSketchThrow(ERR_SRC_IS_NOT_FLOAT); }
mergeFloatImpl(other);
}

@@ -31,7 +31,7 @@
import static org.apache.datasketches.kll.KllPreambleUtil.insertNumLevels;
import static org.apache.datasketches.kll.KllSketch.SketchType.DOUBLES_SKETCH;
import static org.apache.datasketches.kll.KllSketch.SketchType.FLOATS_SKETCH;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR30;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_TGT_IS_IMMUTABLE;

import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.WritableMemory;
@@ -165,14 +165,14 @@ int getNumLevels() {

@Override
void incN() {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
long n = extractN(wmem);
insertN(wmem, ++n);
}

@Override
void incNumLevels() {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
int numLevels = extractNumLevels(wmem);
insertNumLevels(wmem, ++numLevels);
}
@@ -184,7 +184,7 @@ boolean isLevelZeroSorted() {

@Override
void setDoubleItemsArray(final double[] doubleItems) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
itemsArrUpdatable.putDoubleArray(0, doubleItems, 0, doubleItems.length);
}

@@ -195,13 +195,13 @@ void setDoubleItemsArrayAt(final int index, final double value) {

@Override
void setDyMinK(final int dyMinK) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
insertDyMinK(wmem, dyMinK);
}

@Override
void setFloatItemsArray(final float[] floatItems) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
itemsArrUpdatable.putFloatArray(0, floatItems, 0, floatItems.length);
}

@@ -217,7 +217,7 @@ void setItemsArrayUpdatable(final WritableMemory itemsMem) {

@Override
void setLevelsArray(final int[] levelsArr) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
levelsArrUpdatable.putIntArray(0, levelsArr, 0, levelsArr.length);
}

@@ -247,31 +247,31 @@ void setLevelsArrayUpdatable(final WritableMemory levelsMem) {

@Override
void setLevelZeroSorted(final boolean sorted) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
insertLevelZeroSortedFlag(wmem, sorted);
}

@Override
void setMaxDoubleValue(final double value) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
minMaxArrUpdatable.putDouble(Double.BYTES, value);
}

@Override
void setMaxFloatValue(final float value) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
minMaxArrUpdatable.putFloat(Float.BYTES, value);
}

@Override
void setMinDoubleValue(final double value) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
minMaxArrUpdatable.putDouble(0, value);
}

@Override
void setMinFloatValue(final float value) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
minMaxArrUpdatable.putFloat(0, value);
}

@@ -282,13 +282,13 @@ void setMinMaxArrayUpdatable(final WritableMemory minMaxMem) {

@Override
void setN(final long n) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
insertN(wmem, n);
}

@Override
void setNumLevels(final int numLevels) {
if (!updatable) { kllSketchThrow(ERR30); }
if (!updatable) { kllSketchThrow(ERR_TGT_IS_IMMUTABLE); }
insertNumLevels(wmem, numLevels);
}

@@ -23,9 +23,9 @@
import static java.lang.Math.min;
import static org.apache.datasketches.kll.KllPreambleUtil.DEFAULT_K;
import static org.apache.datasketches.kll.KllPreambleUtil.DEFAULT_M;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR33;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR35;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR50;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_DOUBLE;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_CANNOT_BE_DIRECT;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_MUST_NOT_CALL;

import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.memory.Memory;
@@ -289,8 +289,8 @@ public KllDoublesSketchIterator iterator() {
* @param other sketch to merge into this one
*/
public void merge(final KllSketch other) {
if (other.isDirect()) { kllSketchThrow(ERR35); }
if (!other.isDoublesSketch()) { kllSketchThrow(ERR33); }
if (other.isDirect()) { kllSketchThrow(ERR_SRC_CANNOT_BE_DIRECT); }
if (!other.isDoublesSketch()) { kllSketchThrow(ERR_SRC_IS_NOT_DOUBLE); }
mergeDoubleImpl(other);
}

@@ -310,22 +310,22 @@ public void update(final double value) {
double getDoubleItemsArrayAt(final int index) { return doubleItems_[index]; }

@Override //Dummy
float[] getFloatItemsArray() { kllSketchThrow(ERR50); return null; }
float[] getFloatItemsArray() { kllSketchThrow(ERR_MUST_NOT_CALL); return null; }

@Override //Dummy
float getFloatItemsArrayAt(final int index) { kllSketchThrow(ERR50); return Float.NaN; }
float getFloatItemsArrayAt(final int index) { kllSketchThrow(ERR_MUST_NOT_CALL); return Float.NaN; }

@Override //Used internally
double getMaxDoubleValue() { return maxDoubleValue_; }

@Override //Dummy
float getMaxFloatValue() { kllSketchThrow(ERR50); return (float) maxDoubleValue_; }
float getMaxFloatValue() { kllSketchThrow(ERR_MUST_NOT_CALL); return (float) maxDoubleValue_; }

@Override //Used internally
double getMinDoubleValue() { return minDoubleValue_; }

@Override //Dummy
float getMinFloatValue() { kllSketchThrow(ERR50); return (float) minDoubleValue_; }
float getMinFloatValue() { kllSketchThrow(ERR_MUST_NOT_CALL); return (float) minDoubleValue_; }

@Override //Used internally
void setDoubleItemsArray(final double[] doubleItems) { doubleItems_ = doubleItems; }
@@ -334,21 +334,21 @@ public void update(final double value) {
void setDoubleItemsArrayAt(final int index, final double value) { doubleItems_[index] = value; }

@Override //Dummy
void setFloatItemsArray(final float[] floatItems) { kllSketchThrow(ERR50); }
void setFloatItemsArray(final float[] floatItems) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Dummy
void setFloatItemsArrayAt(final int index, final float value) { kllSketchThrow(ERR50); }
void setFloatItemsArrayAt(final int index, final float value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Used internally
void setMaxDoubleValue(final double value) { maxDoubleValue_ = value; }

@Override //Dummy
void setMaxFloatValue(final float value) { kllSketchThrow(ERR50); }
void setMaxFloatValue(final float value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Used internally
void setMinDoubleValue(final double value) { minDoubleValue_ = value; }

@Override //Dummy
void setMinFloatValue(final float value) { kllSketchThrow(ERR50); }
void setMinFloatValue(final float value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

}
@@ -23,9 +23,9 @@
import static java.lang.Math.min;
import static org.apache.datasketches.kll.KllPreambleUtil.DEFAULT_K;
import static org.apache.datasketches.kll.KllPreambleUtil.DEFAULT_M;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR34;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR35;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR50;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_IS_NOT_FLOAT;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_SRC_CANNOT_BE_DIRECT;
import static org.apache.datasketches.kll.KllSketch.ERRNO.ERR_MUST_NOT_CALL;

import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.memory.Memory;
@@ -289,8 +289,8 @@ public KllFloatsSketchIterator iterator() {
* @param other sketch to merge into this one
*/
public void merge(final KllFloatsSketch other) {
if (other.isDirect()) { kllSketchThrow(ERR35); }
if (!other.isFloatsSketch()) { kllSketchThrow(ERR34); }
if (other.isDirect()) { kllSketchThrow(ERR_SRC_CANNOT_BE_DIRECT); }
if (!other.isFloatsSketch()) { kllSketchThrow(ERR_SRC_IS_NOT_FLOAT); }
mergeFloatImpl(other);
}

@@ -304,10 +304,10 @@ public void update(final float value) {
}

@Override //Dummy
double[] getDoubleItemsArray() { kllSketchThrow(ERR50); return null; }
double[] getDoubleItemsArray() { kllSketchThrow(ERR_MUST_NOT_CALL); return null; }

@Override //Dummy
double getDoubleItemsArrayAt(final int index) { kllSketchThrow(ERR50); return Double.NaN; }
double getDoubleItemsArrayAt(final int index) { kllSketchThrow(ERR_MUST_NOT_CALL); return Double.NaN; }

@Override //Used internally
float[] getFloatItemsArray() { return floatItems_; }
@@ -316,22 +316,22 @@ public void update(final float value) {
float getFloatItemsArrayAt(final int index) { return floatItems_[index]; }

@Override //Dummy
double getMaxDoubleValue() { kllSketchThrow(ERR50); return maxFloatValue_; }
double getMaxDoubleValue() { kllSketchThrow(ERR_MUST_NOT_CALL); return maxFloatValue_; }

@Override //Used internally
float getMaxFloatValue() { return maxFloatValue_; }

@Override //Dummy
double getMinDoubleValue() { kllSketchThrow(ERR50); return minFloatValue_; }
double getMinDoubleValue() { kllSketchThrow(ERR_MUST_NOT_CALL); return minFloatValue_; }

@Override //Used internally
float getMinFloatValue() { return minFloatValue_; }

@Override //Dummy
void setDoubleItemsArray(final double[] doubleItems) { kllSketchThrow(ERR50); }
void setDoubleItemsArray(final double[] doubleItems) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Dummy
void setDoubleItemsArrayAt(final int index, final double value) { kllSketchThrow(ERR50); }
void setDoubleItemsArrayAt(final int index, final double value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Used internally
void setFloatItemsArray(final float[] floatItems) { floatItems_ = floatItems; }
@@ -340,13 +340,13 @@ public void update(final float value) {
void setFloatItemsArrayAt(final int index, final float value) { floatItems_[index] = value; }

@Override //Dummy
void setMaxDoubleValue(final double value) { kllSketchThrow(ERR50); }
void setMaxDoubleValue(final double value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Used internally
void setMaxFloatValue(final float value) { maxFloatValue_ = value; }

@Override //Dummy
void setMinDoubleValue(final double value) { kllSketchThrow(ERR50); }
void setMinDoubleValue(final double value) { kllSketchThrow(ERR_MUST_NOT_CALL); }

@Override //Used internally
void setMinFloatValue(final float value) { minFloatValue_ = value; }

0 comments on commit 71af0d9

Please sign in to comment.