@@ -44,16 +44,19 @@ public class HistogramProcessor extends IpacTablePartProcessor {
44
44
columns [2 ].getFormatInfo ().setDataFormat ("%.14g" );
45
45
}
46
46
private final String FIXED_SIZE_ALGORITHM = "fixedSizeBins" ;
47
- private final String NUMBER_BINS = "numBins" ;
47
+ private final String FIXED_BIN_SIZE_SELECTION ="fixedBinSizeSelection" ;
48
+ private final String BIN_SIZE = "binSize" ;
48
49
private final String COLUMN = "columnExpression" ;
49
-
50
50
private final String MIN = "min" ;
51
51
private final String MAX = "max" ;
52
52
// private final String ALGORITHM = "algorithm";
53
53
private final String FALSEPOSTIVERATE = "falsePositiveRate" ;
54
54
private final String PRESERVE_EMPTY_BIN ="preserveEmptyBins" ;
55
55
private String algorithm = null ;// FIXED_SIZE_ALGORITHM;
56
- private int numBins ;
56
+ private int numBins =0 ;
57
+ private double binWidth =0.0 ;
58
+ private String binSelection ;
59
+ private String binSize ;
57
60
private double min = Double .NaN ;
58
61
private double max = Double .NaN ;
59
62
private String columnExpression ;
@@ -155,17 +158,32 @@ private void getParameters(TableServerRequest tableServerRequest) {
155
158
156
159
} else if (name .equalsIgnoreCase (MAX )) {
157
160
max = Double .parseDouble (value );
158
- } else if (name .equalsIgnoreCase (NUMBER_BINS )) {
159
- numBins = Integer .parseInt (value );
160
- if (numBins >0 ) algorithm = FIXED_SIZE_ALGORITHM ;
161
- } else if (name .equalsIgnoreCase (FALSEPOSTIVERATE )) {
161
+ } else if (name .equalsIgnoreCase (FIXED_BIN_SIZE_SELECTION )) {
162
+ binSelection = value ;
163
+ // numBins = Integer.parseInt(value);
164
+ // if (numBins>0) algorithm = FIXED_SIZE_ALGORITHM;
165
+ } else if (name .equalsIgnoreCase (BIN_SIZE )) {
166
+ binSize = value ;
167
+ }
168
+ else if (name .equalsIgnoreCase (FALSEPOSTIVERATE )) {
162
169
falsePostiveRate = Double .parseDouble (value );
163
170
}
164
171
else if (name .equalsIgnoreCase (PRESERVE_EMPTY_BIN ) ){
165
172
showEmptyBin = Boolean .parseBoolean (value );
166
173
}
167
174
}
168
175
176
+
177
+ if (binSelection .equalsIgnoreCase ("numBins" )){
178
+ numBins = Integer .parseInt (binSize );
179
+ }
180
+ else if (binSelection .equalsIgnoreCase ("binWidth" ) ) {
181
+ binWidth = Double .parseDouble (binSize );
182
+
183
+ }
184
+ if (numBins >0 || binWidth >0.0 ){
185
+ algorithm = FIXED_SIZE_ALGORITHM ;
186
+ }
169
187
}
170
188
171
189
private void addFormatInfoAtt (DataGroup dg , DataType dt ) {
@@ -233,13 +251,15 @@ private Object[] calculateFixedBinSizeDataArray(double[] columnData) {
233
251
}
234
252
235
253
236
- double binSize = (max -min )/numBins ;
254
+ double binSize =numBins >0 ? (max -min )/numBins :binWidth ;
255
+
256
+ int nBins = numBins >0 ? numBins : (int ) Math .ceil ((max -min )/binSize );
237
257
238
258
// double delta =( max -min)/100*numBins;
239
- long [] numPointsInBin = new long [numBins ];
240
- double [] binMin = new double [numBins ];
259
+ long [] numPointsInBin = new long [nBins ];
260
+ double [] binMin = new double [nBins ];
241
261
242
- double [] binMax = new double [numBins ];
262
+ double [] binMax = new double [nBins ];
243
263
244
264
int iBin ;
245
265
for (int i = 0 ; i < columnData .length ; i ++) {
@@ -249,11 +269,11 @@ private Object[] calculateFixedBinSizeDataArray(double[] columnData) {
249
269
250
270
}
251
271
else if (columnData [i ] == max ) { //put the last data in the last bin
252
- numPointsInBin [numBins - 1 ]++;
272
+ numPointsInBin [nBins - 1 ]++;
253
273
}
254
274
255
275
}
256
- for (int i =0 ; i <numBins ; i ++){
276
+ for (int i =0 ; i <nBins ; i ++){
257
277
binMin [i ]=min +i *binSize ;
258
278
binMax [i ]=binMin [i ]+binSize ;
259
279
}
0 commit comments