/** Adds invalid value to the column. */ public void addInvalidCol(int colIdx) { ++_colIdx; if (colIdx >= _ncolumns) return; ++_invalidValues[colIdx]; if (_phase == Pass.ONE) return; switch (_colTypes[colIdx]) { case BYTE: case DBYTE: _ab.put1(-1); break; case SHORT: case DSHORT: _ab.put2((short) -1); break; case INT: _ab.put4(Integer.MIN_VALUE); break; case LONG: _ab.put8(Long.MIN_VALUE); break; case FLOAT: _ab.put4f(Float.NaN); break; case DOUBLE: _ab.put8d(Double.NaN); break; case STRINGCOL: // TODO, replace with empty space! _ab.put1(-1); break; default: assert false : "illegal case: " + _colTypes[colIdx]; } }
@SuppressWarnings("fallthrough") public void addNumCol(int colIdx, long number, int exp) { ++_colIdx; if (colIdx >= _ncolumns) return; switch (_phase) { case ONE: double d = number * pow10(exp); if (d < _min[colIdx]) _min[colIdx] = d; if (d > _max[colIdx]) _max[colIdx] = d; _mean[colIdx] += d; if (exp != 0) { if (exp < _scale[colIdx]) _scale[colIdx] = exp; if (_colTypes[colIdx] != DCOL) { if (Math.abs(number) > MAX_FLOAT_MANTISSA || exp < -35 || exp > 35) _colTypes[colIdx] = DCOL; else _colTypes[colIdx] = FCOL; } } else if (_colTypes[colIdx] < ICOL) { _colTypes[colIdx] = ICOL; } break; case TWO: switch (_colTypes[colIdx]) { case BYTE: _ab.put1((byte) (number * pow10i(exp - _scale[colIdx]) - _bases[colIdx])); break; case SHORT: _ab.put2((short) (number * pow10i(exp - _scale[colIdx]) - _bases[colIdx])); break; case INT: _ab.put4((int) (number * pow10i(exp - _scale[colIdx]) - _bases[colIdx])); break; case LONG: _ab.put8(number * pow10i(exp - _scale[colIdx])); break; case FLOAT: _ab.put4f((float) (number * pow10(exp))); break; case DOUBLE: _ab.put8d(number * pow10(exp)); break; case DBYTE: _ab.put1((short) (number * pow10i(exp - _scale[colIdx]) - _bases[colIdx])); break; case DSHORT: // scale is computed as negative in the first pass, // therefore to compute the positive exponent after scale, we add scale and the original // exponent _ab.put2((short) (number * pow10i(exp - _scale[colIdx]) - _bases[colIdx])); break; case STRINGCOL: break; } // update sigma if (!Double.isNaN(_mean[colIdx])) { d = number * pow10(exp) - _mean[colIdx]; _sigma[colIdx] += d * d; } break; default: assert (false); } }