@@ -19,6 +19,8 @@ public class ColumnDecoderDummycode extends ColumnDecoder {
1919
2020 private int [] _clPos = null ;
2121 private int [] _cuPos = null ;
22+ // category index for dedicated single-column decoders (-1 if not used)
23+ private int _category = -1 ;
2224
2325 protected ColumnDecoderDummycode (Types .ValueType [] schema , int [] colList ) {
2426 super (schema , colList );
@@ -33,39 +35,65 @@ public FrameBlock columnDecode(MatrixBlock in, FrameBlock out) {
3335
3436 @ Override
3537 public void columnDecode (MatrixBlock in , FrameBlock out , int rl , int ru ) {
36- for ( int i =rl ; i <ru ; i ++ )
37- for ( int j =0 ; j <_colList .length ; j ++ )
38- for ( int k =_clPos [j ]; k <_cuPos [j ]; k ++ )
39- if ( in .get (i , k -1 ) != 0 ) {
40- int col = _colList [j ] - 1 ;
41- out .set (i , col ,
42- UtilFunctions .doubleToObject (out .getSchema ()[col ], k -_clPos [j ]+1 ));
43- }
38+ if (_category >= 0 ) {
39+ int col = _colList [0 ] - 1 ;
40+ Object val = UtilFunctions .doubleToObject (out .getSchema ()[col ], _category );
41+ for (int i = rl ; i < ru ; i ++)
42+ if (in .get (i , _clPos [0 ]-1 ) == 1 )
43+ synchronized (out ) { out .set (i , col , val ); }
44+ }
45+ else {
46+ for ( int i =rl ; i <ru ; i ++ )
47+ for ( int j =0 ; j <_colList .length ; j ++ )
48+ for ( int k =_clPos [j ]; k <_cuPos [j ]; k ++ )
49+ if ( in .get (i , k -1 ) != 0 ) {
50+ int col = _colList [j ] - 1 ;
51+ Object val = UtilFunctions .doubleToObject (out .getSchema ()[col ], k -_clPos [j ]+1 );
52+ synchronized (out ) { out .set (i , col , val ); }
53+ }
54+ }
4455 }
4556
4657 @ Override
4758 public ColumnDecoder subRangeDecoder (int colStart , int colEnd , int dummycodedOffset ) {
48- List <Integer > dcList = new ArrayList <>();
49- List <Integer > clPosList = new ArrayList <>();
50- List <Integer > cuPosList = new ArrayList <>();
59+ // special case: request for exactly one encoded column
60+ if (colEnd - colStart == 1 ) {
61+ int encCol = colStart ;
62+ for (int j =0 ; j <_clPos .length ; j ++)
63+ if (encCol >= _clPos [j ] && encCol < _cuPos [j ]) {
64+ ColumnDecoderDummycode dec = new ColumnDecoderDummycode (
65+ new Types .ValueType []{_schema [_colList [j ]-1 ]},
66+ new int []{_colList [j ]});
67+ dec ._clPos = new int []{1 };
68+ dec ._cuPos = new int []{2 };
69+ dec ._category = encCol - _clPos [j ] + 1 ;
70+ return dec ;
71+ }
72+ return null ;
73+ }
74+ else {
75+ List <Integer > dcList = new ArrayList <>();
76+ List <Integer > clPosList = new ArrayList <>();
77+ List <Integer > cuPosList = new ArrayList <>();
5178
52- for ( int j =0 ; j <_colList .length ; j ++ ) {
53- int colID = _colList [j ];
54- if (colID >= colStart && colID < colEnd ) {
55- dcList .add (colID - (colStart - 1 ));
56- clPosList .add (_clPos [j ] - dummycodedOffset );
57- cuPosList .add (_cuPos [j ] - dummycodedOffset );
79+ for ( int j =0 ; j <_colList .length ; j ++ ) {
80+ int colID = _colList [j ];
81+ if (colID >= colStart && colID < colEnd ) {
82+ dcList .add (colID - (colStart - 1 ));
83+ clPosList .add (_clPos [j ] - dummycodedOffset );
84+ cuPosList .add (_cuPos [j ] - dummycodedOffset );
85+ }
5886 }
59- }
60- if (dcList .isEmpty ())
61- return null ;
87+ if (dcList .isEmpty ())
88+ return null ;
6289
63- ColumnDecoderDummycode dec = new ColumnDecoderDummycode (
64- Arrays .copyOfRange (_schema , colStart - 1 , colEnd - 1 ),
65- dcList .stream ().mapToInt (i -> i ).toArray ());
66- dec ._clPos = clPosList .stream ().mapToInt (i -> i ).toArray ();
67- dec ._cuPos = cuPosList .stream ().mapToInt (i -> i ).toArray ();
68- return dec ;
90+ ColumnDecoderDummycode dec = new ColumnDecoderDummycode (
91+ Arrays .copyOfRange (_schema , colStart - 1 , colEnd - 1 ),
92+ dcList .stream ().mapToInt (i -> i ).toArray ());
93+ dec ._clPos = clPosList .stream ().mapToInt (i -> i ).toArray ();
94+ dec ._cuPos = cuPosList .stream ().mapToInt (i -> i ).toArray ();
95+ return dec ;
96+ }
6997 }
7098
7199 @ Override
0 commit comments