Skip to content

Commit 011f775

Browse files
committed
Fixes the getRSE() function and updates the SketchesCheckstyle.xml.
1 parent 649ca9c commit 011f775

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/java/org/apache/datasketches/req/BaseReqSketch.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract class BaseReqSketch implements QuantilesFloatsAPI {
7171
* @return an a priori estimate of relative standard error (RSE, expressed as a number in [0,1]).
7272
*/
7373
public static double getRSE(final int k, final double rank, final boolean hra, final long totalN) {
74-
return getRankUB(k, 2, rank, 1, hra, totalN); //more conservative to assume > 1 level
74+
return getRankUB(k, 2, rank, 1, hra, totalN) - rank; //more conservative to assume > 1 level
7575
}
7676

7777
@Override
@@ -188,9 +188,8 @@ public boolean isReadOnly() {
188188
*/
189189
public abstract String viewCompactorDetail(String fmt, boolean allData);
190190

191-
static boolean exactRank(final int k, final int levels, final double rank,
192-
final boolean hra, final long totalN) {
193-
final int baseCap = k * INIT_NUMBER_OF_SECTIONS;
191+
static boolean exactRank(final int k, final int levels, final double rank, final boolean hra, final long totalN) {
192+
final long baseCap = (long)k * INIT_NUMBER_OF_SECTIONS;
194193
if ((levels == 1) || (totalN <= baseCap)) { return true; }
195194
final double exactRankThresh = (double)baseCap / totalN;
196195
return (hra ? (rank >= (1.0 - exactRankThresh)) : (rank <= exactRankThresh));

tools/SketchesCheckstyle.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
25

36
<!--
47
Licensed to the Apache Software Foundation (ASF) under one

0 commit comments

Comments
 (0)