本文整理汇总了Java中io.netty.buffer.DrillBuf.getByte方法的典型用法代码示例。如果您正苦于以下问题:Java DrillBuf.getByte方法的具体用法?Java DrillBuf.getByte怎么用?Java DrillBuf.getByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.DrillBuf
的用法示例。
在下文中一共展示了DrillBuf.getByte方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareDenseBytes
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static int compareDenseBytes(DrillBuf left, int leftStart, boolean leftSign, DrillBuf right, int rightStart, boolean rightSign, int width) {
int invert = 1;
/* If signs are different then simply look at the
* sign of the two inputs and determine which is greater
*/
if (leftSign != rightSign) {
return((leftSign == true) ? -1 : 1);
} else if(leftSign == true) {
/* Both inputs are negative, at the end we will
* have to invert the comparison
*/
invert = -1;
}
int cmp = 0;
for (int i = 0; i < width; i++) {
byte leftByte = left.getByte(leftStart + i);
byte rightByte = right.getByte(rightStart + i);
// Unsigned byte comparison
if ((leftByte & 0xFF) > (rightByte & 0xFF)) {
cmp = 1;
break;
} else if ((leftByte & 0xFF) < (rightByte & 0xFF)) {
cmp = -1;
break;
}
}
cmp *= invert; // invert the comparison if both were negative values
return cmp;
}
示例2: initCap
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static void initCap(int start, int end, DrillBuf inBuf, DrillBuf outBuf) {
boolean capNext = true;
int out = 0;
for (int id = start; id < end; id++, out++) {
byte currentByte = inBuf.getByte(id);
// 'A - Z' : 0x41 - 0x5A
// 'a - z' : 0x61 - 0x7A
// '0-9' : 0x30 - 0x39
if (capNext) { // curCh is whitespace or first character of word.
if (currentByte >= 0x30 && currentByte <= 0x39) { // 0-9
capNext = false;
} else if (currentByte >= 0x41 && currentByte <= 0x5A) { // A-Z
capNext = false;
} else if (currentByte >= 0x61 && currentByte <= 0x7A) { // a-z
capNext = false;
currentByte -= 0x20; // Uppercase this character
}
// else {} whitespace
} else { // Inside of a word or white space after end of word.
if (currentByte >= 0x30 && currentByte <= 0x39) { // 0-9
// noop
} else if (currentByte >= 0x41 && currentByte <= 0x5A) { // A-Z
currentByte -= 0x20; // Lowercase this character
} else if (currentByte >= 0x61 && currentByte <= 0x7A) { // a-z
// noop
} else { // whitespace
capNext = true;
}
}
outBuf.setByte(out, currentByte);
} // end of for_loop
}
示例3: readIntLittleEndian
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static int readIntLittleEndian(DrillBuf in, int offset) {
int ch4 = in.getByte(offset) & 0xff;
int ch3 = in.getByte(offset + 1) & 0xff;
int ch2 = in.getByte(offset + 2) & 0xff;
int ch1 = in.getByte(offset + 3) & 0xff;
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}
示例4: getBigDecimalFromDense
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static BigDecimal getBigDecimalFromDense(DrillBuf data, int startIndex, int nDecimalDigits, int scale, int maxPrecision, int width) {
/* This method converts the dense representation to
* an intermediate representation. The intermediate
* representation has one more integer than the dense
* representation.
*/
byte[] intermediateBytes = new byte[((nDecimalDigits + 1) * integerSize)];
// Start storing from the least significant byte of the first integer
int intermediateIndex = 3;
int[] mask = {0x03, 0x0F, 0x3F, 0xFF};
int[] reverseMask = {0xFC, 0xF0, 0xC0, 0x00};
int maskIndex;
int shiftOrder;
byte shiftBits;
// TODO: Some of the logic here is common with casting from Dense to Sparse types, factor out common code
if (maxPrecision == 38) {
maskIndex = 0;
shiftOrder = 6;
shiftBits = 0x00;
intermediateBytes[intermediateIndex++] = (byte) (data.getByte(startIndex) & 0x7F);
} else if (maxPrecision == 28) {
maskIndex = 1;
shiftOrder = 4;
shiftBits = (byte) ((data.getByte(startIndex) & 0x03) << shiftOrder);
intermediateBytes[intermediateIndex++] = (byte) (((data.getByte(startIndex) & 0x3C) & 0xFF) >>> 2);
} else {
throw new UnsupportedOperationException("Dense types with max precision 38 and 28 are only supported");
}
int inputIndex = 1;
boolean sign = false;
if ((data.getByte(startIndex) & 0x80) != 0) {
sign = true;
}
while (inputIndex < width) {
intermediateBytes[intermediateIndex] = (byte) ((shiftBits) | (((data.getByte(startIndex + inputIndex) & reverseMask[maskIndex]) & 0xFF) >>> (8 - shiftOrder)));
shiftBits = (byte) ((data.getByte(startIndex + inputIndex) & mask[maskIndex]) << shiftOrder);
inputIndex++;
intermediateIndex++;
if (((inputIndex - 1) % integerSize) == 0) {
shiftBits = (byte) ((shiftBits & 0xFF) >>> 2);
maskIndex++;
shiftOrder -= 2;
}
}
/* copy the last byte */
intermediateBytes[intermediateIndex] = shiftBits;
if (sign == true) {
intermediateBytes[0] = (byte) (intermediateBytes[0] | 0x80);
}
DrillBuf intermediate = data.getAllocator().buffer(intermediateBytes.length);
intermediate.setBytes(0, intermediateBytes);
BigDecimal ret = getBigDecimalFromIntermediate(intermediate, 0, nDecimalDigits + 1, scale);
intermediate.release();
return ret;
}
示例5: varCharToLong
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static long varCharToLong(final int start, final int end, DrillBuf buffer){
if ((end - start) ==0) {
//empty, not a valid number
return nfeL(start, end, buffer);
}
int readIndex = start;
boolean negative = buffer.getByte(readIndex) == '-';
if (negative && ++readIndex == end) {
//only one single '-'
return nfeL(start, end, buffer);
}
long result = 0;
int digit;
while (readIndex < end) {
digit = Character.digit(buffer.getByte(readIndex++),RADIX);
//not valid digit.
if (digit == -1) {
return nfeL(start, end, buffer);
}
//overflow
if (MAX_LONG > result) {
return nfeL(start, end, buffer);
}
long next = result * RADIX - digit;
//overflow
if (next > result) {
return nfeL(start, end, buffer);
}
result = next;
}
if (!negative) {
result = -result;
//overflow
if (result < 0) {
return nfeL(start, end, buffer);
}
}
return result;
}
示例6: varCharToInt
import io.netty.buffer.DrillBuf; //导入方法依赖的package包/类
public static int varCharToInt(final int start, final int end, DrillBuf buffer){
if ((end - start) ==0) {
//empty, not a valid number
return nfeI(start, end, buffer);
}
int readIndex = start;
boolean negative = buffer.getByte(readIndex) == '-';
if (negative && ++readIndex == end) {
//only one single '-'
return nfeI(start, end, buffer);
}
int result = 0;
int digit;
while (readIndex < end) {
digit = Character.digit(buffer.getByte(readIndex++), RADIX);
//not valid digit.
if (digit == -1) {
return nfeI(start, end, buffer);
}
//overflow
if (MAX_INT > result) {
return nfeI(start, end, buffer);
}
int next = result * RADIX - digit;
//overflow
if (next > result) {
return nfeI(start, end, buffer);
}
result = next;
}
if (!negative) {
result = -result;
//overflow
if (result < 0) {
return nfeI(start, end, buffer);
}
}
return result;
}