Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leerho committed Jan 24, 2024
1 parent 8614d45 commit e100634
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* @author Kevin Lang
* @author Alexander Saydakov
*/
//
final class KllDoublesHelper {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* @author Kevin Lang
* @author Alexander Saydakov
*/
//
final class KllFloatsHelper {

/**
Expand Down Expand Up @@ -485,10 +484,10 @@ private static void populateFloatWorkArrays(
if (selfPop == 0 && otherPop == 0) { continue; }
if (selfPop > 0 && otherPop == 0) {
System.arraycopy(myCurFloatItemsArr, myCurLevelsArr[lvl], workbuf, worklevels[lvl], selfPop);
}
}
else if (selfPop == 0 && otherPop > 0) {
System.arraycopy(otherFloatItemsArr, otherLevelsArr[lvl], workbuf, worklevels[lvl], otherPop);
}
}
else if (selfPop > 0 && otherPop > 0) {
mergeSortedFloatArrays(
myCurFloatItemsArr, myCurLevelsArr[lvl], selfPop,
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/apache/datasketches/kll/KllItemsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@
@SuppressWarnings("unchecked")
final class KllItemsHelper<T> {

/**
* Create Items Array from given item and weight.
* Used with weighted update only.
* @param item the given item
* @param weight the given weight
* @return the Items Array.
*/
static <T> T[] createItemsArray(final T item, final int weight) {
final int itemsArrLen = Integer.bitCount(weight);
final Object[] itemsArr = new Object[itemsArrLen];
Arrays.fill(itemsArr, item);
return (T[]) itemsArr;
}

/**
* The following code is only valid in the special case of exactly reaching capacity while updating.
* It cannot be used while merging, while reducing k, or anything else.
Expand Down

0 comments on commit e100634

Please sign in to comment.