code: private byte[] bufS(final int valsz){
      int log = 0;
      while((1 << log) < valsz)++log;
      assert valsz == 0 || (1 << log) == valsz;
      final int ridsz = _len >= 65535?4:2;
      final int elmsz = ridsz + valsz;
      int off = CXIChunk.OFF;
      byte [] buf = MemoryManager.malloc1(off + _sparseLen*elmsz,true);
      for( int i=0; i<_sparseLen; i++, off += elmsz ) {
        if(ridsz == 2)
          UDP.set2(buf,off,(short)_id[i]);
        else
          UDP.set4(buf,off,_id[i]);
        if(valsz == 0){
          assert _xs[i] == 0 && _ls[i] == 1;
          continue;
        }
        assert _xs[i] == Integer.MIN_VALUE || _xs[i] >= 0:"unexpected exponent " + _xs[i]; // assert we have int or NA
        final long lval = _xs[i] == Integer.MIN_VALUE?NAS[log]:_ls[i]*PrettyPrint.pow10i(_xs[i]);
        switch(valsz){
          case 1:
            buf[off+ridsz] = (byte)lval;
            break;
          case 2:
            short sval = (short)lval;
            UDP.set2(buf,off+ridsz,sval);
            break;
          case 4:
            int ival = (int)lval;
            UDP.set4(buf, off+ridsz, ival);
            break;
          case 8:
            UDP.set8(buf, off+ridsz, lval);
            break;
          default:
            throw H2O.unimpl();
        }
      }
      assert off==buf.length;
      return buf;
    }
docs: Compute a sparse integer buffer