本文整理了Java中org.apache.kylin.common.util.Bytes.binaryIncrementNeg()
方法的一些代码示例,展示了Bytes.binaryIncrementNeg()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.binaryIncrementNeg()
方法的具体详情如下:
包路径:org.apache.kylin.common.util.Bytes
类名称:Bytes
方法名:binaryIncrementNeg
暂无
代码示例来源:origin: apache/kylin
/**
* Bytewise binary increment/deincrement of long contained in byte array
* on given amount.
*
* @param value - array of bytes containing long (length <= SIZEOF_LONG)
* @param amount value will be incremented on (deincremented if negative)
* @return array of bytes containing incremented long (length == SIZEOF_LONG)
*/
public static byte[] incrementBytes(byte[] value, long amount) {
byte[] val = value;
if (val.length < SIZEOF_LONG) {
// Hopefully this doesn't happen too often.
byte[] newvalue;
if (val[0] < 0) {
newvalue = new byte[] { -1, -1, -1, -1, -1, -1, -1, -1 };
} else {
newvalue = new byte[SIZEOF_LONG];
}
System.arraycopy(val, 0, newvalue, newvalue.length - val.length, val.length);
val = newvalue;
} else if (val.length > SIZEOF_LONG) {
throw new IllegalArgumentException("Increment Bytes - value too big: " + val.length);
}
if (amount == 0)
return val;
if (val[0] < 0) {
return binaryIncrementNeg(val, amount);
}
return binaryIncrementPos(val, amount);
}
代码示例来源:origin: org.apache.kylin/kylin-common
/**
* Bytewise binary increment/deincrement of long contained in byte array
* on given amount.
*
* @param value - array of bytes containing long (length <= SIZEOF_LONG)
* @param amount value will be incremented on (deincremented if negative)
* @return array of bytes containing incremented long (length == SIZEOF_LONG)
*/
public static byte[] incrementBytes(byte[] value, long amount) {
byte[] val = value;
if (val.length < SIZEOF_LONG) {
// Hopefully this doesn't happen too often.
byte[] newvalue;
if (val[0] < 0) {
newvalue = new byte[] { -1, -1, -1, -1, -1, -1, -1, -1 };
} else {
newvalue = new byte[SIZEOF_LONG];
}
System.arraycopy(val, 0, newvalue, newvalue.length - val.length, val.length);
val = newvalue;
} else if (val.length > SIZEOF_LONG) {
throw new IllegalArgumentException("Increment Bytes - value too big: " + val.length);
}
if (amount == 0)
return val;
if (val[0] < 0) {
return binaryIncrementNeg(val, amount);
}
return binaryIncrementPos(val, amount);
}
代码示例来源:origin: org.apache.kylin/kylin-core-common
/**
* Bytewise binary increment/deincrement of long contained in byte array
* on given amount.
*
* @param value - array of bytes containing long (length <= SIZEOF_LONG)
* @param amount value will be incremented on (deincremented if negative)
* @return array of bytes containing incremented long (length == SIZEOF_LONG)
*/
public static byte[] incrementBytes(byte[] value, long amount) {
byte[] val = value;
if (val.length < SIZEOF_LONG) {
// Hopefully this doesn't happen too often.
byte[] newvalue;
if (val[0] < 0) {
newvalue = new byte[] { -1, -1, -1, -1, -1, -1, -1, -1 };
} else {
newvalue = new byte[SIZEOF_LONG];
}
System.arraycopy(val, 0, newvalue, newvalue.length - val.length, val.length);
val = newvalue;
} else if (val.length > SIZEOF_LONG) {
throw new IllegalArgumentException("Increment Bytes - value too big: " + val.length);
}
if (amount == 0)
return val;
if (val[0] < 0) {
return binaryIncrementNeg(val, amount);
}
return binaryIncrementPos(val, amount);
}
内容来源于网络,如有侵权,请联系作者删除!