|
3 | 3 | import java.util.Arrays;
|
4 | 4 | import water.*;
|
5 | 5 | import water.parser.DParseTask;
|
| 6 | +import static water.parser.DParseTask.fitsIntoInt; |
6 | 7 |
|
7 | 8 | /**
|
8 | 9 | * The scale/bias function, where data is in SIGNED bytes before scaling.
|
9 | 10 | */
|
10 | 11 | public class C4SChunk extends Chunk {
|
11 | 12 | static private final long _NA = Integer.MIN_VALUE;
|
12 |
| - static final int OFF=8+4; |
| 13 | + static final int OFF=8+8; |
13 | 14 | public double _scale;
|
14 |
| - int _bias; |
15 |
| - C4SChunk( byte[] bs, int bias, double scale ) { _mem=bs; _start = -1; _len = (_mem.length-OFF)>>2; |
| 15 | + long _bias; |
| 16 | + C4SChunk( byte[] bs, long bias, double scale ) { _mem=bs; _start = -1; _len = (_mem.length-OFF)>>2; |
16 | 17 | _bias = bias; _scale = scale;
|
17 | 18 | UDP.set8d(_mem,0,scale);
|
18 |
| - UDP.set4 (_mem,8,bias ); |
| 19 | + UDP.set8(_mem, 8, bias); |
19 | 20 | }
|
20 | 21 | @Override protected final long at8_impl( int i ) {
|
21 | 22 | long res = UDP.get4(_mem,(i<<2)+OFF);
|
@@ -45,18 +46,18 @@ public class C4SChunk extends Chunk {
|
45 | 46 | _start = -1;
|
46 | 47 | _len = (_mem.length-OFF)>>2;
|
47 | 48 | _scale= UDP.get8d(_mem,0);
|
48 |
| - _bias = UDP.get4 (_mem,8); |
| 49 | + _bias = UDP.get8(_mem, 8); |
49 | 50 | return this;
|
50 | 51 | }
|
51 | 52 | @Override NewChunk inflate_impl(NewChunk nc) {
|
52 | 53 | double dx = Math.log10(_scale);
|
53 |
| - assert DParseTask.fitsIntoInt(dx); |
54 |
| - Arrays.fill(nc._xs = MemoryManager.malloc4(_len), (int)dx); |
55 |
| - nc._ls = MemoryManager.malloc8(_len); |
56 |
| - for( int i=0; i<_len; i++ ) { |
| 54 | + assert fitsIntoInt(dx); |
| 55 | + nc.set_len(nc.set_sparseLen(0)); |
| 56 | + final int len = len(); |
| 57 | + for( int i=0; i<len; i++ ) { |
57 | 58 | int res = UDP.get4(_mem,(i<<2)+OFF);
|
58 |
| - if( res == _NA ) nc.setNA_impl2(i); |
59 |
| - else nc._ls[i] = res+_bias; |
| 59 | + if( res == _NA ) nc.addNA(); |
| 60 | + else nc.addNum(res+_bias,(int)dx); |
60 | 61 | }
|
61 | 62 | return nc;
|
62 | 63 | }
|
|
0 commit comments