Beispiel #1
0
 // Slow-path append data
 private void append2slowUUID() {
   if (_ds == null && _ls != null) { // This can happen for columns with all NAs and then a UUID
     _xs = null;
     alloc_doubles(sparseLen());
     Arrays.fill(_ls, C16Chunk._LO_NA);
     Arrays.fill(_ds, Double.longBitsToDouble(C16Chunk._HI_NA));
   }
   if (_ls != null && _ls.length > 0) {
     _ls = MemoryManager.arrayCopyOf(_ls, sparseLen() << 1);
     _ds = MemoryManager.arrayCopyOf(_ds, sparseLen() << 1);
   } else {
     alloc_mantissa(4);
     alloc_doubles(4);
   }
   assert sparseLen() == 0 || _ls.length > sparseLen()
       : "_ls.length = " + _ls.length + ", _len = " + sparseLen();
 }
Beispiel #2
0
  // Slow-path append data
  private void append2slow() {
    if (sparseLen() > FileVec.DFLT_CHUNK_SIZE)
      throw new ArrayIndexOutOfBoundsException(sparseLen());

    assert _ds == null;
    if (_ls != null && _ls.length > 0) {
      if (_id == null) { // check for sparseness
        int nzs = 0;
        for (int i = 0; i < _ls.length; ++i) if (_ls[i] != 0 || _xs[i] != 0) ++nzs;
        if ((nzs + 1) * _sparseRatio < _len) {
          set_sparse(nzs);
          assert sparseLen() == 0 || sparseLen() <= _ls.length
              : "_len = "
                  + sparseLen()
                  + ", _ls.length = "
                  + _ls.length
                  + ", nzs = "
                  + nzs
                  + ", len2 = "
                  + _len;
          assert _id.length == _ls.length;
          assert sparseLen() <= _len;
          return;
        }
      } else {
        // verify we're still sufficiently sparse
        if ((_sparseRatio * (sparseLen()) >> 1) > _len) cancel_sparse();
        else _id = MemoryManager.arrayCopyOf(_id, sparseLen() << 1);
      }
      _ls = MemoryManager.arrayCopyOf(_ls, sparseLen() << 1);
      _xs = MemoryManager.arrayCopyOf(_xs, sparseLen() << 1);
    } else {
      alloc_mantissa(4);
      alloc_exponent(4);
      if (_id != null) alloc_indices(4);
    }
    assert sparseLen() == 0 || sparseLen() < _ls.length
        : "_len = " + sparseLen() + ", _ls.length = " + _ls.length;
    assert _id == null || _id.length == _ls.length;
    assert sparseLen() <= _len;
  }