code: private byte[] bufS(int len, int id_sz, int val_sz,boolean na_sparse){
      long NA = CXIChunk.NA(val_sz);
      int elem_size = id_sz+val_sz;
      byte [] res = MemoryManager.malloc1(CXIChunk._OFF + _sparseLen*elem_size);
      UnsafeUtils.set4(res,0,len);
      res[4] = (byte)id_sz;
      res[5] = (byte)val_sz;
      res[6] = na_sparse?(byte)1:0;
      if(na_sparse)res[6] = (byte)1;
      for(int i = 0; i < _sparseLen; ++i){
        if(id_sz == 2) UnsafeUtils.set2(res,CXIChunk._OFF+i*elem_size+0,(short)_id[i]);
        else UnsafeUtils.set4(res,CXIChunk._OFF+i*elem_size+0,_id[i]);
        long val = isNA2(i)?NA:_ms.get(i);
        switch(val_sz){
          case 0: break; // no value store dfor binary chunks
          case 2: UnsafeUtils.set2(res,CXIChunk._OFF+i*elem_size+id_sz,(short)val); break;
          case 4: UnsafeUtils.set4(res,CXIChunk._OFF+i*elem_size+id_sz,(int)val); break;
          case 8: UnsafeUtils.set8(res,CXIChunk._OFF+i*elem_size+id_sz,val); break;
          default: throw H2O.unimpl();
        }
      }
      return res;
    }
docs: Compute a sparse integer buffer