Beispiel #1
0
 public NewChunk convertEnum2Str(ValueString[] emap) {
   NewChunk strChunk = new NewChunk(_vec, _cidx);
   int j = 0, l = _len;
   for (int i = 0; i < l; ++i) {
     if (_id != null && _id.length > 0 && (j < _id.length && _id[j] == i)) // Sparse storage
       // adjust for enum ids using 1-based indexing
       strChunk.addStr(emap[(int) _ls[j++] - 1]);
     else if (_xs[i] != Integer.MIN_VALUE) // Categorical value isn't NA
     strChunk.addStr(emap[(int) _ls[i] - 1]);
     else strChunk.addNA();
   }
   if (_id != null) assert j == sparseLen() : "j = " + j + ", sparseLen = " + sparseLen();
   return strChunk;
 }
Beispiel #2
0
 public void addStr(Chunk c, int row) {
   if (c.isNA(row)) addNA();
   else {
     addStr(c.atStr(new BufferedString(), row));
     _isAllASCII &= ((CStrChunk) c)._isAllASCII;
   }
 }
Beispiel #3
0
 public void add2Chunk(NewChunk c) {
   if (_ds == null && _ss == null) {
     c.addNum(_ls[_lId], _xs[_lId]);
   } else {
     if (_ls != null) {
       c.addUUID(_ls[_lId], Double.doubleToRawLongBits(_ds[_lId]));
     } else if (_ss != null) {
       int sidx = _is[_lId];
       int nextNotNAIdx = _lId + 1;
       // Find next not-NA value (_is[idx] != -1)
       while (nextNotNAIdx < _is.length && _is[nextNotNAIdx] == -1) nextNotNAIdx++;
       int slen = nextNotNAIdx < _is.length ? _is[nextNotNAIdx] - sidx : _sslen - sidx;
       // null-BufferedString represents NA value
       BufferedString bStr = sidx == -1 ? null : new BufferedString().set(_ss, sidx, slen);
       c.addStr(bStr);
     } else c.addNum(_ds[_lId]);
   }
 }
Beispiel #4
0
 // Append a String, stored in _ss & _is
 public void addStr(ValueString str) {
   if (_id == null || str != null) {
     if (_is == null || sparseLen() >= _is.length) {
       append2slowstr();
       addStr(str);
       assert sparseLen() <= _len;
       return;
     }
     if (str != null) {
       if (_id != null) _id[sparseLen()] = _len;
       _is[sparseLen()] = _sslen;
       set_sparseLen(sparseLen() + 1);
       append_ss(str);
     } else if (_id == null) {
       _is[sparseLen()] = CStrChunk.NA;
       set_sparseLen(sparseLen() + 1);
     }
   }
   set_len(_len + 1);
   assert sparseLen() <= _len;
 }
Beispiel #5
0
 // Append a string, store in _ss & _is
 public void addStr(Object str) {
   if (_id == null || str != null) {
     if (_is == null || sparseLen() >= _is.length) {
       append2slowstr();
       addStr(str);
       assert sparseLen() <= _len;
       return;
     }
     if (str != null) {
       if (_id != null) _id[sparseLen()] = _len;
       _is[sparseLen()] = _sslen;
       set_sparseLen(sparseLen() + 1);
       if (str instanceof BufferedString) append_ss((BufferedString) str);
       else // this spares some callers from an unneeded conversion to BufferedString first
       append_ss((String) str);
     } else if (_id == null) {
       _is[sparseLen()] = CStrChunk.NA;
       set_sparseLen(sparseLen() + 1);
     }
   }
   set_len(_len + 1);
   assert sparseLen() <= _len;
 }
Beispiel #6
0
 public void addNA() {
   if (isUUID()) addUUID(C16Chunk._LO_NA, C16Chunk._HI_NA);
   else if (isString()) addStr(null);
   else if (_ds != null) addNum(Double.NaN);
   else append2(Long.MAX_VALUE, Integer.MIN_VALUE);
 }
Beispiel #7
0
 public void addStr(Chunk c, int row) {
   if (c.isNA(row)) addNA();
   else addStr(c.atStr(new ValueString(), row));
 }
Beispiel #8
0
 public void addStr(Chunk c, long row) {
   if (c.isNA_abs(row)) addNA();
   else addStr(c.atStr_abs(new ValueString(), row));
 }