@ Override public AutoBuffer compress ( AutoBuffer ab , AutoBuffer abAux ) { int pos = ab . position ( ) ; if ( _nodeType == 0 ) size ( ) ; // Sets _nodeType & _size both ab . put1 ( _nodeType ) ; // Includes left-child skip-size bits assert _split != null ; // Not a broken root non-decision? assert _split . _col >= 0 ; ab . put2 ( ( short ) _split . _col ) ; ab . put1 ( ( byte ) _split . _nasplit . value ( ) ) ; // Save split-at-value or group if ( _split . _nasplit != DHistogram . NASplitDir . NAvsREST ) { if ( _split . _equal == 0 || _split . _equal == 1 ) ab . put4f ( _splat ) ; else if ( _split . _equal == 2 ) _split . _bs . compress2 ( ab ) ; else _split . _bs . compress3 ( ab ) ; } if ( abAux != null ) { abAux . put4 ( _nid ) ; abAux . put4 ( _tree . node ( _nids [ 0 ] ) . numNodes ( ) ) ; // number of nodes in the left subtree; this used to be 'parent node id' abAux . put4f ( ( float ) _split . _n0 ) ; abAux . put4f ( ( float ) _split . _n1 ) ; abAux . put4f ( ( float ) _split . _p0 ) ; abAux . put4f ( ( float ) _split . _p1 ) ; abAux . put4f ( ( float ) _split . _se0 ) ; abAux . put4f ( ( float ) _split . _se1 ) ; abAux . put4 ( _nids [ 0 ] ) ; abAux . put4 ( _nids [ 1 ] ) ; } Node left = _tree . node ( _nids [ 0 ] ) ; if ( ( _nodeType & 48 ) == 0 ) { // Size bits are optional for left leaves ! int sz = left . size ( ) ; if ( sz < 256 ) ab . put1 ( sz ) ; else if ( sz < 65535 ) ab . put2 ( ( short ) sz ) ; else if ( sz < ( 1 << 24 ) ) ab . put3 ( sz ) ; else ab . put4 ( sz ) ; // 1<<31-1 } // now write the subtree in left . compress ( ab , abAux ) ; Node rite = _tree . node ( _nids [ 1 ] ) ; rite . compress ( ab , abAux ) ; assert _size == ab . position ( ) - pos : "reported size = " + _size + " , real size = " + ( ab . position ( ) - pos ) ; return ab ; }
Compress this tree into the AutoBuffer