本文整理了Java中java.lang.Byte.toUnsignedInt()
方法的一些代码示例,展示了Byte.toUnsignedInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Byte.toUnsignedInt()
方法的具体详情如下:
包路径:java.lang.Byte
类名称:Byte
方法名:toUnsignedInt
暂无
代码示例来源:origin: neo4j/neo4j
static GeometryHeader fromArrayHeaderBytes( byte[] header )
{
int geometryType = Byte.toUnsignedInt( header[1] );
int dimension = Byte.toUnsignedInt( header[2] );
int crsTableId = Byte.toUnsignedInt( header[3] );
int crsCode = (Byte.toUnsignedInt( header[4] ) << 8) + Byte.toUnsignedInt( header[5] );
return new GeometryHeader( geometryType, dimension, crsTableId, crsCode );
}
代码示例来源:origin: debezium/debezium
private int[] getUnsignedBinary() {
if (unsignedBinary != null || binary == null) {
return unsignedBinary;
}
unsignedBinary = new int[binary.length];
for (int i = 0; i < binary.length; i++) {
unsignedBinary[i] = Byte.toUnsignedInt(binary[i]);
}
return unsignedBinary;
}
代码示例来源:origin: neo4j/neo4j
public static GeometryHeader fromArrayHeaderByteBuffer( ByteBuffer buffer )
{
int geometryType = Byte.toUnsignedInt( buffer.get() );
int dimension = Byte.toUnsignedInt( buffer.get() );
int crsTableId = Byte.toUnsignedInt( buffer.get() );
int crsCode = (Byte.toUnsignedInt( buffer.get() ) << 8) + Byte.toUnsignedInt( buffer.get() );
return new GeometryHeader( geometryType, dimension, crsTableId, crsCode );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
@SuppressWarnings({ "unchecked" })
public int compare(byte[] o1, byte[] o2) {
final int lengthToCheck = Math.min( o1.length, o2.length );
for ( int i = 0 ; i < lengthToCheck ; i++ ) {
// must do an unsigned int comparison
final int comparison = ComparableComparator.INSTANCE.compare(
Byte.toUnsignedInt( o1[i] ),
Byte.toUnsignedInt( o2[i] )
);
if ( comparison != 0 ) {
return comparison;
}
}
return o1.length - o2.length;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
private static int runLen(IntFunction<BytesRef> packedValues, int start, int end, int byteOffset) {
BytesRef first = packedValues.apply(start);
byte b = first.bytes[first.offset + byteOffset];
for (int i = start + 1; i < end; ++i) {
BytesRef ref = packedValues.apply(i);
byte b2 = ref.bytes[ref.offset + byteOffset];
assert Byte.toUnsignedInt(b2) >= Byte.toUnsignedInt(b);
if (b != b2) {
return i - start;
}
}
return end - start;
}
代码示例来源:origin: neo4j/neo4j
public static TemporalHeader fromArrayHeaderByteBuffer( ByteBuffer buffer )
{
int temporalType = Byte.toUnsignedInt( buffer.get() );
return new TemporalHeader( temporalType );
}
}
代码示例来源:origin: neo4j/neo4j
static TemporalHeader fromArrayHeaderBytes( byte[] header )
{
int temporalType = Byte.toUnsignedInt( header[1] );
return new TemporalHeader( temporalType );
}
代码示例来源:origin: apache/incubator-pinot
/**
* Compares two byte[] values. The comparison performed is on unsigned value for each byte.
* Returns:
* <ul>
* <li> 0 if both values are identical. </li>
* <li> -ve integer if first value is smaller than the second. </li>
* <li> +ve integer if first value is larger than the second. </li>
* </ul>
*
* @param bytes1 First byte[] to compare.
* @param bytes2 Second byte[] to compare.
* @return Result of comparison as stated above.
*/
public static int compare(byte[] bytes1, byte[] bytes2) {
int len1 = bytes1.length;
int len2 = bytes2.length;
int lim = Math.min(len1, len2);
for (int k = 0; k < lim; k++) {
// Java byte is always signed, but we need to perform unsigned comparison.
int ai = Byte.toUnsignedInt(bytes1[k]);
int bi = Byte.toUnsignedInt(bytes2[k]);
if (ai != bi) {
return ai - bi;
}
}
return len1 - len2;
}
}
代码示例来源:origin: apache/ignite
/**
* @param pageAddr Page address.
* @return Number of levels in this tree.
*/
public int getLevelsCount(long pageAddr) {
return Byte.toUnsignedInt(PageUtils.getByte(pageAddr, LVLS_OFF));
}
代码示例来源:origin: apache/nifi
public UnsignedByteTypeNode(BinaryReader binaryReader, ChunkHeader chunkHeader, BxmlNode parent, int length) throws IOException {
super(binaryReader, chunkHeader, parent, length);
value = Byte.toUnsignedInt((byte) binaryReader.read());
}
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Decode values that have been encoded with {@link #intToByte4(int)}.
*/
public static int byte4ToInt(byte b) {
int i = Byte.toUnsignedInt(b);
if (i < NUM_FREE_VALUES) {
return i;
} else {
long decoded = NUM_FREE_VALUES + int4ToLong(i - NUM_FREE_VALUES);
return Math.toIntExact(decoded);
}
}
}
代码示例来源:origin: Alluxio/alluxio
@Override
public int read() throws IOException {
if (!mReader.hasRemaining()) {
return -1;
}
// readByte returns a signed byte cast as an int, but InputStream expects bytes to be
// represented as ints in the range 0 to 255.
return Byte.toUnsignedInt((byte) mReader.readByte());
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected int byteAt(int i, int k) {
if (k < packedBytesLength) {
return Byte.toUnsignedInt(reader.getByteAt(i, k));
} else {
final int shift = bitsPerDocId - ((k - packedBytesLength + 1) << 3);
return (reader.getDocID(i) >>> Math.max(0, shift)) & 0xff;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
protected int byteAt(int i, int k) {
if (k < cmpBytes) {
return Byte.toUnsignedInt(reader.getByteAt(i, offset + k));
} else {
final int shift = bitsPerDocId - ((k - cmpBytes + 1) << 3);
return (reader.getDocID(i) >>> Math.max(0, shift)) & 0xff;
}
}
}.select(from, to, mid);
代码示例来源:origin: org.apache.lucene/lucene-core
float getLengthValue(int doc) throws IOException {
if (norms == null) {
return 1F;
}
if (norms.advanceExact(doc)) {
return normCache[Byte.toUnsignedInt((byte) norms.longValue())];
} else {
return 0;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Sliced reference to points in an OfflineSorter.ByteSequencesWriter file. */
private static final class PathSlice {
final PointWriter writer;
final long start;
final long count;
public PathSlice(PointWriter writer, long start, long count) {
this.writer = writer;
this.start = start;
this.count = count;
}
@Override
public String toString() {
return "PathSlice(start=" + start + " count=" + count + " writer=" + writer + ")";
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
private void visitCompressedDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, int[] docIDs, int count, IntersectVisitor visitor, int compressedDim) throws IOException {
// the byte at `compressedByteOffset` is compressed using run-length compression,
// other suffix bytes are stored verbatim
final int compressedByteOffset = compressedDim * bytesPerDim + commonPrefixLengths[compressedDim];
commonPrefixLengths[compressedDim]++;
int i;
for (i = 0; i < count; ) {
scratchPackedValue[compressedByteOffset] = in.readByte();
final int runLen = Byte.toUnsignedInt(in.readByte());
for (int j = 0; j < runLen; ++j) {
for(int dim=0;dim<numDataDims;dim++) {
int prefix = commonPrefixLengths[dim];
in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix);
}
visitor.visit(docIDs[i+j], scratchPackedValue);
}
i += runLen;
}
if (i != count) {
throw new CorruptIndexException("Sub blocks do not add up to the expected count: " + count + " != " + i, in);
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
private static void readInts24(IndexInput in, int count, int[] docIDs) throws IOException {
int i;
for (i = 0; i < count - 7; i += 8) {
long l1 = in.readLong();
long l2 = in.readLong();
long l3 = in.readLong();
docIDs[i] = (int) (l1 >>> 40);
docIDs[i+1] = (int) (l1 >>> 16) & 0xffffff;
docIDs[i+2] = (int) (((l1 & 0xffff) << 8) | (l2 >>> 56));
docIDs[i+3] = (int) (l2 >>> 32) & 0xffffff;
docIDs[i+4] = (int) (l2 >>> 8) & 0xffffff;
docIDs[i+5] = (int) (((l2 & 0xff) << 16) | (l3 >>> 48));
docIDs[i+6] = (int) (l3 >>> 24) & 0xffffff;
docIDs[i+7] = (int) l3 & 0xffffff;
}
for (; i < count; ++i) {
docIDs[i] = (Short.toUnsignedInt(in.readShort()) << 8) | Byte.toUnsignedInt(in.readByte());
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public BytesRef next() throws IOException {
if (++ord >= entry.termsDictSize) {
return null;
}
if ((ord & blockMask) == 0L) {
term.length = bytes.readVInt();
bytes.readBytes(term.bytes, 0, term.length);
} else {
final int token = Byte.toUnsignedInt(bytes.readByte());
int prefixLength = token & 0x0F;
int suffixLength = 1 + (token >>> 4);
if (prefixLength == 15) {
prefixLength += bytes.readVInt();
}
if (suffixLength == 16) {
suffixLength += bytes.readVInt();
}
term.length = prefixLength + suffixLength;
bytes.readBytes(term.bytes, prefixLength, suffixLength);
}
return term;
}
代码示例来源:origin: org.apache.lucene/lucene-core
private static void readInts24(IndexInput in, int count, IntersectVisitor visitor) throws IOException {
int i;
for (i = 0; i < count - 7; i += 8) {
long l1 = in.readLong();
long l2 = in.readLong();
long l3 = in.readLong();
visitor.visit((int) (l1 >>> 40));
visitor.visit((int) (l1 >>> 16) & 0xffffff);
visitor.visit((int) (((l1 & 0xffff) << 8) | (l2 >>> 56)));
visitor.visit((int) (l2 >>> 32) & 0xffffff);
visitor.visit((int) (l2 >>> 8) & 0xffffff);
visitor.visit((int) (((l2 & 0xff) << 16) | (l3 >>> 48)));
visitor.visit((int) (l3 >>> 24) & 0xffffff);
visitor.visit((int) l3 & 0xffffff);
}
for (; i < count; ++i) {
visitor.visit((Short.toUnsignedInt(in.readShort()) << 8) | Byte.toUnsignedInt(in.readByte()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!