本文整理汇总了Java中water.util.UnsafeUtils.set4方法的典型用法代码示例。如果您正苦于以下问题:Java UnsafeUtils.set4方法的具体用法?Java UnsafeUtils.set4怎么用?Java UnsafeUtils.set4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类water.util.UnsafeUtils
的用法示例。
在下文中一共展示了UnsafeUtils.set4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CStrChunk
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public CStrChunk(int sslen, byte[] ss, int sparseLen, int idxLen, int[] strIdx, boolean isAllASCII) {
_start = -1;
_valstart = _OFF + (idxLen<<2);
_isAllASCII = isAllASCII;
set_len(idxLen);
_mem = MemoryManager.malloc1(CStrChunk._OFF + idxLen*4 + sslen, false);
UnsafeUtils.set4(_mem, 0, CStrChunk._OFF + idxLen * 4); // location of start of strings
if (_isAllASCII) UnsafeUtils.set1(_mem, 4, (byte)1); // use byte to store _isAllASCII
else UnsafeUtils.set1(_mem, 4, (byte)0);
for( int i = 0; i < sparseLen; ++i )
UnsafeUtils.set4(_mem, CStrChunk._OFF + 4*i, strIdx[i]);
for( int i = sparseLen; i < idxLen; ++i ) // set NAs
UnsafeUtils.set4(_mem, CStrChunk._OFF + 4*i, -1);
for( int i = 0; i < sslen; ++i )
_mem[CStrChunk._OFF + idxLen*4 + i] = ss[i];
}
示例2: CUDChunk
import water.util.UnsafeUtils; //导入方法依赖的package包/类
CUDChunk(byte[] bs, HashMap<Long,Byte> hs, int len) {
_start = -1;
numUniques = hs.size();
set_len(len);
_mem = MemoryManager.malloc1(computeByteSize(numUniques, _len), false);
UnsafeUtils.set4(_mem, 0, _len);
UnsafeUtils.set4(_mem, 4, numUniques);
int j=0;
//create the mapping and also store the unique values (as longs)
for (Map.Entry<Long,Byte> e : hs.entrySet()) {
e.setValue(new Byte((byte)(j-128))); //j is in 0...256 -> byte value needs to be in -128...127 for storage
UnsafeUtils.set8(_mem, 8 + (j << 3), e.getKey());
j++;
}
// store the mapping
for (int i=0; i<len; ++i)
UnsafeUtils.set1(_mem, 8 + (numUniques << 3) + i, hs.get(Double.doubleToLongBits(UnsafeUtils.get8d(bs, i << 3))));
}
示例3: init
import water.util.UnsafeUtils; //导入方法依赖的package包/类
private void init (int sslen, byte[] ss, int sparseLen, int idxLen, int[] id, int[] is) {
_start = -1;
_valstart = idx(idxLen);
_len = idxLen;
_mem = MemoryManager.malloc1(_valstart + sslen, false);
UnsafeUtils.set4(_mem, 0, _valstart); // location of start of strings
Arrays.fill(_mem,_OFF,_valstart,(byte)-1); // Indicate All Is NA's
for( int i = 0; i < sparseLen; ++i ) // Copy the sparse indices
UnsafeUtils.set4(_mem, idx(id==null ? i : id[i]), is==null ? 0 : is[i]); //Need to check if id and is are null since both are not always needed for mem allocation
UnsafeUtils.copyMemory(ss,0,_mem,_valstart,sslen);
_isAllASCII = true;
for(int i = _valstart; i < _mem.length; ++i) {
byte c = _mem[i];
if ((c & 0x80) == 128) { //value beyond std ASCII
_isAllASCII = false;
break;
}
}
UnsafeUtils.set1(_mem, 4, (byte) (_isAllASCII ? 1 : 0)); // isAllASCII flag
}
示例4: bufS
import water.util.UnsafeUtils; //导入方法依赖的package包/类
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;
}
示例5: bufD
import water.util.UnsafeUtils; //导入方法依赖的package包/类
private byte[] bufD(final int valsz, boolean na_sparse){
int elem_size = valsz+4;
byte [] res = MemoryManager.malloc1(CXIChunk._OFF + _sparseLen*elem_size);
UnsafeUtils.set4(res,0,_len);
res[4] = (byte)4;
res[5] = (byte)valsz;
res[6] = na_sparse?(byte)1:0;
if(na_sparse)res[6] = (byte)1;
for(int i = 0; i < _sparseLen; ++i){
UnsafeUtils.set4(res,CXIChunk._OFF+i*elem_size+0,_id[i]);
if(valsz == 4){
UnsafeUtils.set4f(res,CXIChunk._OFF+i*elem_size+4,(float)_ds[i]);
} else if(valsz == 8) {
UnsafeUtils.set8d(res,CXIChunk._OFF+i*elem_size+4,_ds[i]);
} else throw H2O.unimpl();
}
return res;
}
示例6: set_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override boolean set_impl(int idx, long l) {
long res = (long)(l/_scale)-_bias; // Compressed value
double d = (res+_bias)*_scale; // Reverse it
if( (long)d != l ) return false; // Does not reverse cleanly?
if( !(Integer.MIN_VALUE < res && res <= Integer.MAX_VALUE) ) return false; // Out-o-range for a int array
UnsafeUtils.set4(_mem,(idx<<2)+_OFF,(int)res);
return true;
}
示例7: C0DChunk
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public C0DChunk(double con, int len) {
_start = -1;
set_len(len);
_mem=new byte[_OFF];
_con = con;
UnsafeUtils.set8d(_mem, 0, con);
UnsafeUtils.set4(_mem,8,len);
}
示例8: intern
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public static H2ONode intern( byte[] bs, int off ) {
byte[] b = new byte[4];
UnsafeUtils.set4(b, 0, UnsafeUtils.get4(bs, off));
int port = UnsafeUtils.get2(bs,off+4)&0xFFFF;
try { return intern(InetAddress.getByAddress(b),port); }
catch( UnknownHostException e ) { throw Log.throwErr(e); }
}
示例9: CSChunk
import water.util.UnsafeUtils; //导入方法依赖的package包/类
CSChunk( byte[] bs, long bias, int scale, int szLog) {
_mem = bs;
_start = -1;
set_len((_mem.length - _OFF) >> szLog);
_bias = bias;
UnsafeUtils.set8(_mem, 0, bias);
UnsafeUtils.set4(_mem, 8, scale);
_scale = PrettyPrint.pow10(1,scale);
UnsafeUtils.set4(_mem,12,szLog);
}
示例10: intern
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public static H2ONode intern( byte[] bs, int off ) {
byte[] b = new byte[H2Okey.SIZE_OF_IP]; // the size depends on version of selected IP stack
int port;
// The static constant should be optimized
if (!H2O.IS_IPV6) { // IPv4
UnsafeUtils.set4(b, 0, UnsafeUtils.get4(bs, off));
} else { // IPv6
UnsafeUtils.set8(b, 0, UnsafeUtils.get8(bs, off));
UnsafeUtils.set8(b, 8, UnsafeUtils.get8(bs, off + 8));
}
port = UnsafeUtils.get2(bs,off + H2Okey.SIZE_OF_IP) & 0xFFFF;
try { return intern(InetAddress.getByAddress(b),port); }
catch( UnknownHostException e ) { throw Log.throwErr(e); }
}
示例11: intern
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public static H2ONode intern( byte[] bs, int off ) {
byte[] b = new byte[4];
UnsafeUtils.set4(b, 0, UnsafeUtils.get4(bs, off));
int port = UnsafeUtils.get2(bs,off+4)&0xFFFF;
try { return intern(InetAddress.getByAddress(b),port); }
catch( UnknownHostException e ) { throw Log.errRTExcept(e); }
}
示例12: set_impl
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override boolean set_impl(int idx, long l) {
if( !(Integer.MIN_VALUE < l && l <= Integer.MAX_VALUE) ) return false;
UnsafeUtils.set4(_mem,idx<<2,(int)l);
return true;
}
示例13: C0LChunk
import water.util.UnsafeUtils; //导入方法依赖的package包/类
public C0LChunk(long con, int len) { _mem=new byte[_OFF]; _start = -1; set_len(len);
_con = con;
UnsafeUtils.set8(_mem, 0, con);
UnsafeUtils.set4(_mem,8,len);
}
示例14: setDecimal
import water.util.UnsafeUtils; //导入方法依赖的package包/类
protected void setDecimal(){
_isDecimal = true;
_scale = PrettyPrint.pow10(1,-UnsafeUtils.get4(_mem,8));
UnsafeUtils.set4(_mem,12,-UnsafeUtils.get4(_mem,12)-1);
}
示例15: asBytes
import water.util.UnsafeUtils; //导入方法依赖的package包/类
@Override public byte [] asBytes() {
byte [] res = MemoryManager.malloc1(_len*4);
for(int i = 0; i < _len; ++i)
UnsafeUtils.set4(res,4*i,_is[i]);
return res;
}