Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/java/org/apache/datasketches/req/BaseReqSketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ abstract class BaseReqSketch implements QuantilesFloatsAPI {
* @return an a priori estimate of relative standard error (RSE, expressed as a number in [0,1]).
*/
public static double getRSE(final int k, final double rank, final boolean hra, final long totalN) {
return getRankUB(k, 2, rank, 1, hra, totalN); //more conservative to assume > 1 level
return getRankUB(k, 2, rank, 1, hra, totalN) - rank; //more conservative to assume > 1 level
}

@Override
Expand Down Expand Up @@ -188,9 +188,8 @@ public boolean isReadOnly() {
*/
public abstract String viewCompactorDetail(String fmt, boolean allData);

static boolean exactRank(final int k, final int levels, final double rank,
final boolean hra, final long totalN) {
final int baseCap = k * INIT_NUMBER_OF_SECTIONS;
static boolean exactRank(final int k, final int levels, final double rank, final boolean hra, final long totalN) {
final long baseCap = (long)k * INIT_NUMBER_OF_SECTIONS;
if ((levels == 1) || (totalN <= baseCap)) { return true; }
final double exactRankThresh = (double)baseCap / totalN;
return (hra ? (rank >= (1.0 - exactRankThresh)) : (rank <= exactRankThresh));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import org.apache.datasketches.common.SketchesArgumentException;
import org.apache.datasketches.quantilescommon.FloatsSortedView;
import org.apache.datasketches.quantilescommon.InequalitySearch;
import org.apache.datasketches.req.BaseReqSketch;
import org.apache.datasketches.req.ReqSketch;
import org.apache.datasketches.req.ReqSketchBuilder;
import org.testng.annotations.Test;

/**
Expand Down Expand Up @@ -114,7 +111,7 @@ public void checkEstimationMode() {
assertEquals(v, 120.0f);
final FloatsSortedView aux = sk.getSortedView();
assertNotNull(aux);
assertTrue(BaseReqSketch.getRSE(sk.getK(), .5, false, 120) > 0);
assertTrue(BaseReqSketch.getRSE(sk.getK(), .5, false, 120) >= 0);
assertTrue(sk.getSerializedSizeBytes() > 0);
}

Expand Down Expand Up @@ -185,7 +182,7 @@ public void checkEmpty() {
try { sk.getQuantiles(new double[] {0.5}); fail(); } catch (IllegalArgumentException e) {}
try { sk.getPMF(new float[] {1f}); fail(); } catch (IllegalArgumentException e) {}
try { sk.getCDF(new float[] {1f}); fail(); } catch (IllegalArgumentException e) {}
assertTrue(BaseReqSketch.getRSE(50, 0.5, true, 0) > 0);
assertTrue(BaseReqSketch.getRSE(50, 0.5, true, 0) >= 0);
assertTrue(sk.getRankUpperBound(0.5, 1) > 0);
}

Expand Down
3 changes: 3 additions & 0 deletions tools/SketchesCheckstyle.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<!--
Licensed to the Apache Software Foundation (ASF) under one
Expand Down
Loading