本文整理汇总了Java中water.util.UnsafeUtils.get4方法的典型用法代码示例。如果您正苦于以下问题:Java UnsafeUtils.get4方法的具体用法?Java UnsafeUtils.get4怎么用?Java UnsafeUtils.get4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类water.util.UnsafeUtils
的用法示例。
在下文中一共展示了UnsafeUtils.get4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asciiTrim
import water.util.UnsafeUtils; //导入方法依赖的package包/类
/**
* Optimized trim() method to operate across the entire CStrChunk buffer in one pass.
* This mimics Java String.trim() by only considering characters of value
* <code>'\u0020'</code> or less as whitespace to be trimmed. This means that like
* Java's String.trim() it ignores 16 of the 17 characters regarded as a space in UTF.
*
* NewChunk is the same size as the original, despite trimming.
*
* @param nc NewChunk to be filled with trimmed version of strings in this chunk
* @return Filled NewChunk
*/
public NewChunk asciiTrim(NewChunk nc) {
// copy existing data
nc = this.inflate_impl(nc);
//update offsets and byte array
for(int i=0; i < _len; i++) {
int j = 0;
int off = UnsafeUtils.get4(_mem,(i<<2)+_OFF);
if (off != NA) {
//UTF chars will appear as negative values. In Java spec, space is any char 0x20 and lower
while( _mem[_valstart+off+j] > 0 && _mem[_valstart+off+j] < 0x21) j++;
if (j > 0) nc._is[i] = off + j;
while( _mem[_valstart+off+j] != 0 ) j++; //Find end
j--;
while( _mem[_valstart+off+j] > 0 && _mem[_valstart+off+j] < 0x21) { //March back to find first non-space
nc._ss[off+j] = 0; //Set new end
j--;
}
}
}
return nc;
}
示例2: asciiLength
import water.util.UnsafeUtils; //导入方法依赖的package包/类
/**
* Optimized length() method for a buffer of only ASCII characters.
* This is a straight byte count for each word in the chunk. The presence
* of UTF-8 multi-byte characters would give incorrect results.
*
* @param nc NewChunk to be filled with lengths of strings in this chunk
* @return Filled NewChunk
*/
public NewChunk asciiLength(NewChunk nc) {
//pre-allocate since size is known
nc._ls = MemoryManager.malloc8(_len);
nc._xs = MemoryManager.malloc4(_len); // sadly, a waste
// fill in lengths
for(int i=0; i < _len; i++) {
int off = UnsafeUtils.get4(_mem,(i<<2)+_OFF);
int len = 0;
if (off != NA) {
while (_mem[_valstart + off + len] != 0) len++;
nc.addNum(len, 0);
} else nc.addNA();
}
return nc;
}
示例3: asciiTrim
import water.util.UnsafeUtils; //导入方法依赖的package包/类
/**
* Optimized trim() method to operate across the entire CStrChunk buffer in one pass.
* This mimics Java String.trim() by only considering characters of value
* <code>'\u0020'</code> or less as whitespace to be trimmed. This means that like
* Java's String.trim() it ignores 16 of the 17 characters regarded as a space in UTF.
*
* NewChunk is the same size as the original, despite trimming.
*
* @param nc NewChunk to be filled with trimmed version of strings in this chunk
* @return Filled NewChunk
*/
public NewChunk asciiTrim(NewChunk nc) {
// copy existing data
nc = this.extractRows(nc, 0,_len);
//update offsets and byte array
for(int i=0; i < _len; i++) {
int j = 0;
int off = UnsafeUtils.get4(_mem,idx(i));
if (off != NA) {
//UTF chars will appear as negative values. In Java spec, space is any char 0x20 and lower
while( _mem[_valstart+off+j] > 0 && _mem[_valstart+off+j] < 0x21) j++;
if (j > 0) nc.set_is(i,off + j);
while( _mem[_valstart+off+j] != 0 ) j++; //Find end
j--;
while( _mem[_valstart+off+j] > 0 && _mem[_valstart+off+j] < 0x21) { //March back to find first non-space
nc._ss[off+j] = 0; //Set new end
j--;
}
}
}
return nc;
}
示例4: asciiSubstring
import water.util.UnsafeUtils; //导入方法依赖的package包/类
/**
* Optimized substring() method for a buffer of only ASCII characters.
* The presence of UTF-8 multi-byte characters would give incorrect results
* for the string length, which is required here.
*
* @param nc NewChunk to be filled with substrings in this chunk
* @param startIndex The beginning index of the substring, inclusive
* @param endIndex The ending index of the substring, exclusive
* @return Filled NewChunk
*/
public NewChunk asciiSubstring(NewChunk nc, int startIndex, int endIndex) {
// copy existing data
nc = this.extractRows(nc, 0,_len);
//update offsets and byte array
for (int i = 0; i < _len; i++) {
int off = UnsafeUtils.get4(_mem, idx(i));
if (off != NA) {
int len = 0;
while (_mem[_valstart + off + len] != 0) len++; //Find length
nc.set_is(i,startIndex < len ? off + startIndex : off + len);
for (; len > endIndex - 1; len--) {
nc._ss[off + len] = 0; //Set new end
}
}
}
return nc;
}
示例5: asciiLength
import water.util.UnsafeUtils; //导入方法依赖的package包/类
/**
* Optimized length() method for a buffer of only ASCII characters.
* This is a straight byte count for each word in the chunk. The presence
* of UTF-8 multi-byte characters would give incorrect results.
*
* @param nc NewChunk to be filled with lengths of strings in this chunk
* @return Filled NewChunk
*/
public NewChunk asciiLength(NewChunk nc) {
//pre-allocate since size is known
nc.alloc_mantissa(_len);
nc.alloc_exponent(_len); // sadly, a waste
// fill in lengths
for(int i=0; i < _len; i++) {
int off = UnsafeUtils.get4(_mem,idx(i));
int len = 0;
if (off != NA) {
while (_mem[_valstart + off + len] != 0) len++;
nc.addNum(len, 0);
} else nc.addNA();
}
return nc;
}
示例6: inflate_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public NewChunk inflate_impl(NewChunk nc) {
nc.set_sparseLen(0);
nc.set_len(0);
final int len = _len;
for( int i=0; i<len; i++ ) {
int res = UnsafeUtils.get4(_mem,(i<<2));
if( res == _NA ) nc.addNA();
else nc.addNum(res,0);
}
return nc;
}
示例7: atStr_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public BufferedString atStr_impl(BufferedString bStr, int idx) {
int off = UnsafeUtils.get4(_mem,(idx<<2)+_OFF);
if( off == NA ) return null;
int len = 0;
while( _mem[_valstart+off+len] != 0 ) len++;
return bStr.set(_mem,_valstart+off,len);
}
示例8: read_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public CStrChunk read_impl(AutoBuffer bb) {
_mem = bb.bufClose();
_start = -1; _cidx = -1;
_valstart = UnsafeUtils.get4(_mem,0);
byte b = UnsafeUtils.get1(_mem,4);
if (b == 0) _isAllASCII = false; else _isAllASCII = true;
set_len((_valstart-_OFF)>>2);
return this;
}
示例9: inflate_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public NewChunk inflate_impl(NewChunk nc) {
nc.set_len(_len);
nc.set_sparseLen(sparseLen());
nc._isAllASCII = _isAllASCII;
nc._is = MemoryManager.malloc4(_len);
for( int i = 0; i < _len; i++ )
nc._is[i] = UnsafeUtils.get4(_mem,(i<<2)+_OFF);
nc._sslen = _mem.length - _valstart;
nc._ss = MemoryManager.malloc1(nc._sslen);
System.arraycopy(_mem,_valstart,nc._ss,0,nc._sslen);
return nc;
}
示例10: read_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public CUDChunk read_impl(AutoBuffer bb) {
_mem = bb.bufClose();
_start = -1; _cidx = -1;
_len = UnsafeUtils.get4(_mem, 0);
numUniques = UnsafeUtils.get4(_mem, 4);
set_len(_len);
return this;
}
示例11: getIValue
import water.util.UnsafeUtils; //导入方法依赖的package包/类
protected final long getIValue(int off){
switch(_valsz){
case 1: return _mem[off+ _ridsz]&0xFF;
case 2: return UnsafeUtils.get2(_mem, off + _ridsz);
case 4: return UnsafeUtils.get4(_mem, off + _ridsz);
case 8: return UnsafeUtils.get8(_mem, off + _ridsz);
default: throw H2O.fail();
}
}
示例12: guessCompressionMethod
import water.util.UnsafeUtils; //导入方法依赖的package包/类
static Compression guessCompressionMethod(byte [] bits) {
// Look for ZIP magic
if( bits.length > ZipFile.LOCHDR && UnsafeUtils.get4(bits, 0) == ZipFile.LOCSIG )
return Compression.ZIP;
if( bits.length > 2 && (UnsafeUtils.get2(bits,0)&0xffff) == GZIPInputStream.GZIP_MAGIC )
return Compression.GZIP;
return Compression.NONE;
}
示例13: initFromBytes
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override
protected final void initFromBytes() {
_start = -1; _cidx = -1;
_len = UnsafeUtils.get4(_mem,0);
int id_sz = _mem[4]&0xFF;
_val_sz = _mem[5]&0xFF;
_elem_sz = _val_sz + id_sz;
_isNA = (0xFF&_mem[6]) == 1;
_previousOffset = _OFF;
}
示例14: getDoubles
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public double [] getDoubles(double [] vals, int from, int to, double NA){
for(int i = from; i < to; i++) {
int x = UnsafeUtils.get4(_mem, 4*i);
vals[i-from] = (x == _NA)?NA:x;
}
return vals;
}
示例15: initFromBytes
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public final void initFromBytes () {
_start = -1; _cidx = -1;
set_len((_mem.length-_OFF) >> getSzLog());
_bias = UnsafeUtils.get8 (_mem,0);
int x = UnsafeUtils.get4(_mem,8);
int szLog = UnsafeUtils.get4(_mem,12);
_isDecimal = szLog < 0;
_scale = PrettyPrint.pow10(1,_isDecimal?-x:x);
}