30
30
* It works for two algorithm, fixed bin size algorithm and variable bin size algorithm. If the bin size is available
31
31
* from the input parameter, it will calculate the fixed bin size histogram. If the bin size is not available, it will
32
32
* calculate variable bin size histogram.
33
+ *
34
+ * By default it keeps empty bins if any. This could be controlled by a parameter, reserveEmptyBins in the UI if needed.
35
+ *
36
+ * CHANGE HISTORY:
37
+ *
38
+ * 5/23/17
39
+ * IRSA-371 Changed the showEmptyBin to true. It was false previously.
40
+ *
33
41
*/
34
42
public class HistogramProcessor extends IpacTablePartProcessor {
35
43
private static final String SEARCH_REQUEST = "searchRequest" ;
@@ -52,6 +60,7 @@ public class HistogramProcessor extends IpacTablePartProcessor {
52
60
// private final String ALGORITHM = "algorithm";
53
61
private final String FALSEPOSTIVERATE = "falsePositiveRate" ;
54
62
private final String PRESERVE_EMPTY_BIN ="preserveEmptyBins" ;
63
+ private boolean showEmptyBin = true ;
55
64
private String algorithm = null ;// FIXED_SIZE_ALGORITHM;
56
65
private int numBins =0 ;
57
66
private double binWidth =0.0 ;
@@ -61,7 +70,7 @@ public class HistogramProcessor extends IpacTablePartProcessor {
61
70
private double max = Double .NaN ;
62
71
private String columnExpression ;
63
72
private double falsePostiveRate = 0.05 ;
64
- private boolean showEmptyBin = false ;
73
+
65
74
66
75
private static String [] getInputFilePath (String inputFileName ) {
67
76
String [] dirs = inputFileName .split ("/" );
@@ -170,12 +179,16 @@ private void getParameters(TableServerRequest tableServerRequest) {
170
179
else if (name .equalsIgnoreCase (FALSEPOSTIVERATE )) {
171
180
falsePostiveRate = Double .parseDouble (value );
172
181
}
182
+ /*05/23/17
183
+ The UI does not have this parameter specified and passed.
184
+ The default now changed to show all the bins. The code
185
+ leave as is in case UI may need this field in the future.
186
+ */
173
187
else if (name .equalsIgnoreCase (PRESERVE_EMPTY_BIN ) ){
174
188
showEmptyBin = Boolean .parseBoolean (value );
175
189
}
176
190
}
177
191
178
-
179
192
if (binSelection !=null ){
180
193
if (binSelection .equalsIgnoreCase ("numBins" )) {
181
194
@@ -260,7 +273,6 @@ private Object[] calculateFixedBinSizeDataArray(double[] columnData) {
260
273
261
274
int nBins = numBins >0 ? numBins : (int ) Math .ceil ((max -min )/binSize );
262
275
263
- // double delta =( max -min)/100*numBins;
264
276
long [] numPointsInBin = new long [nBins ];
265
277
double [] binMin = new double [nBins ];
266
278
@@ -421,15 +433,10 @@ private Object[] calculateVariableBinSizeDataArray(double[] columnData) throws D
421
433
binMin [0 ] = min ;
422
434
//assign the left edge to the binMin
423
435
System .arraycopy (bins , 0 , binMin , 1 , nBin -1 );
424
- // for (int i = 1; i < nBin; i++) {
425
- // binMin[i] = bins[i - 1];
426
- // }
427
436
428
437
//assign the right edge to the binMax
429
438
System .arraycopy (bins , 0 , binMax , 0 , nBin );
430
- // for (int i = 0; i < nBin; i++) {
431
- // binMax[i] = bins[i];
432
- // }
439
+
433
440
}
434
441
435
442
if (showEmptyBin ){
@@ -500,7 +507,7 @@ public double[] getBins(double[] columnData) throws DataAccessException {
500
507
}
501
508
502
509
//-----------------------------------------------------------------
503
- // Recover changepoints by iteratively peeling off the last block
510
+ // Recover change points by iteratively peeling off the last block
504
511
//-----------------------------------------------------------------
505
512
ArrayList <Integer > changePointList = new ArrayList <>();
506
513
int ind = n ;
0 commit comments