本文整理了Java中java.lang.Integer.toUnsignedLong()
方法的一些代码示例,展示了Integer.toUnsignedLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.toUnsignedLong()
方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:toUnsignedLong
暂无
代码示例来源:origin: prestodb/presto
static int computePosition(long hashcode, int hashTableSize)
{
return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
}
}
代码示例来源:origin: prestodb/presto
static int computePosition(long hashcode, int hashTableSize)
{
return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
}
}
代码示例来源:origin: apache/flink
public void setValue(long value) {
if (value >= 0L) {
bigInteger = BigInteger.valueOf(value);
} else {
int upper = (int) (value >>> 32);
int lower = (int) value;
bigInteger = BigInteger
.valueOf(Integer.toUnsignedLong(upper))
.shiftLeft(32)
.add(BigInteger.valueOf(Integer.toUnsignedLong(lower)));
}
}
代码示例来源:origin: debezium/debezium
@Override
public long getTransactionId() {
return Integer.toUnsignedLong(rawMessage.getTransactionId());
}
代码示例来源:origin: prestodb/presto
@Benchmark
public long computePositionWithBitShifting()
{
return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
}
代码示例来源:origin: prestodb/presto
@Benchmark
public long computePositionWithDivision()
{
return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) / (1 << 32));
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testSetUnsignedInt(Buffer buff) throws Exception {
for (int i = 0; i < numSets; i++) {
long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
buff.setUnsignedInt(i * 4, val);
}
for (int i = 0; i < numSets; i++) {
long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
assertEquals(val, buff.getUnsignedInt(i * 4));
}
}
代码示例来源:origin: debezium/debezium
@Override
public void processMessage(final ByteBuffer buffer, ReplicationMessageProcessor processor, TypeRegistry typeRegistry) throws SQLException, InterruptedException {
try {
if (!buffer.hasArray()) {
throw new IllegalStateException(
"Invalid buffer received from PG server during streaming replication");
}
final byte[] source = buffer.array();
final byte[] content = Arrays.copyOfRange(source, buffer.arrayOffset(), source.length);
final RowMessage message = PgProto.RowMessage.parseFrom(content);
if (!message.getNewTypeinfoList().isEmpty() && message.getNewTupleCount() != message.getNewTypeinfoCount()) {
throw new ConnectException(String.format("Message from transaction {} has {} data columns but only {} of type info",
Integer.toUnsignedLong(message.getTransactionId()),
message.getNewTupleCount(),
message.getNewTypeinfoCount()));
}
processor.process(new PgProtoReplicationMessage(message, typeRegistry));
} catch (InvalidProtocolBufferException e) {
throw new ConnectException(e);
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testGetSetUnsignedInt(boolean isLE) throws Exception {
int numInts = 100;
Buffer b = Buffer.buffer(numInts * 4);
for (int i = 0; i < numInts; i++) {
if (isLE) {
b.setUnsignedIntLE(i * 4, (int) (Integer.MAX_VALUE + (long) i));
} else {
b.setUnsignedInt(i * 4, (int) (Integer.MAX_VALUE + (long) i));
}
}
for (int i = 0; i < numInts; i++) {
if (isLE) {
assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedIntLE(i * 4));
} else {
assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedInt(i * 4));
}
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testGetSetUnsignedMedium(boolean isLE) throws Exception {
int numInts = 100;
int MEDIUM_MAX_VALUE = BufferTest.MEDIUM_MAX_VALUE - numInts;
Buffer b = Buffer.buffer(numInts * 3);
for (int i = 0; i < numInts; i++) {
if (isLE) {
b.setMediumLE(i * 3, (MEDIUM_MAX_VALUE + i));
} else {
b.setMedium(i * 3, (MEDIUM_MAX_VALUE + i));
}
}
for (int i = 0; i < numInts; i++) {
if (isLE) {
assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMediumLE(i * 3));
} else {
assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMedium(i * 3));
}
}
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testGetSetUnsignedShort(boolean isLE) throws Exception {
int numShorts = 100;
Buffer b = Buffer.buffer(numShorts * 2);
for (short i = 0; i < numShorts; i++) {
if (isLE) {
b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
} else {
b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
}
}
for (short i = 0; i < numShorts; i++) {
if (isLE) {
assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
} else {
assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
}
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Check whether the given point is within the considered polygon.
* NOTE: this operates directly on the encoded representation of points. */
public boolean test(int lat, int lon) {
final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
return false;
}
int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
if (lon2 < lonBase) { // wrap
lon2 += 1 << (32 - lonShift);
}
assert Integer.toUnsignedLong(lon2) >= lonBase;
assert lon2 - lonBase >= 0;
if (lon2 - lonBase >= maxLonDelta) {
return false;
}
final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
return tree.contains(decodeLatitude(lat), decodeLongitude(lon));
} else {
return relation == Relation.CELL_INSIDE_QUERY.ordinal();
}
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
/** Check whether the given point is within a distance of another point.
* NOTE: this operates directly on the encoded representation of points. */
public boolean test(int lat, int lon) {
final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
return false;
}
int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
if (lon2 < lonBase) { // wrap
lon2 += 1 << (32 - lonShift);
}
assert Integer.toUnsignedLong(lon2) >= lonBase;
assert lon2 - lonBase >= 0;
if (lon2 - lonBase >= maxLonDelta) {
return false;
}
final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
return SloppyMath.haversinSortKey(
decodeLatitude(lat), decodeLongitude(lon),
this.lat, this.lon) <= distanceKey;
} else {
return relation == Relation.CELL_INSIDE_QUERY.ordinal();
}
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
long max = 0;
for (int i = 0; i < count; ++i) {
max |= Integer.toUnsignedLong(docIds[start + i]);
代码示例来源:origin: org.elasticsearch/elasticsearch
public static long encodeLatLon(double lat, double lon) {
return (Integer.toUnsignedLong(GeoEncodingUtils.encodeLatitude(lat)) << 32) | Integer.toUnsignedLong(GeoEncodingUtils.encodeLongitude(lon));
}
代码示例来源:origin: stackoverflow.com
long l = Integer.toUnsignedLong(uint);
System.out.println(l); // will print 4294967295
int x = Integer.parseUnsignedInt("4294967295");
int y = 5;
int cmp1 = Integer.compareUnsigned(x,y); // interprets x as 4294967295 (x>y)
int cmp2 = Integer.compare(x,y); // interprets x as -1 (x<y)
代码示例来源:origin: org.elasticsearch/elasticsearch
static void verifyChecksum(BufferedChecksumStreamInput in) throws IOException {
// This absolutely must come first, or else reading the checksum becomes part of the checksum
long expectedChecksum = in.getChecksum();
long readChecksum = Integer.toUnsignedLong(in.readInt());
if (readChecksum != expectedChecksum) {
throw new TranslogCorruptedException(in.getSource(), "checksum verification failed - expected: 0x" +
Long.toHexString(expectedChecksum) + ", got: 0x" + Long.toHexString(readChecksum));
}
}
代码示例来源:origin: io.vertx/vertx-core
private void testSetUnsignedInt(Buffer buff) throws Exception {
for (int i = 0; i < numSets; i++) {
long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
buff.setUnsignedInt(i * 4, val);
}
for (int i = 0; i < numSets; i++) {
long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
assertEquals(val, buff.getUnsignedInt(i * 4));
}
}
代码示例来源:origin: io.vertx/vertx-core
private void testGetSetUnsignedShort(boolean isLE) throws Exception {
int numShorts = 100;
Buffer b = Buffer.buffer(numShorts * 2);
for (short i = 0; i < numShorts; i++) {
if (isLE) {
b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
} else {
b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
}
}
for (short i = 0; i < numShorts; i++) {
if (isLE) {
assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
} else {
assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
}
}
}
代码示例来源:origin: io.vertx/vertx-core
private void testGetSetUnsignedInt(boolean isLE) throws Exception {
int numInts = 100;
Buffer b = Buffer.buffer(numInts * 4);
for (int i = 0; i < numInts; i++) {
if (isLE) {
b.setUnsignedIntLE(i * 4, (int) (Integer.MAX_VALUE + (long) i));
} else {
b.setUnsignedInt(i * 4, (int) (Integer.MAX_VALUE + (long) i));
}
}
for (int i = 0; i < numInts; i++) {
if (isLE) {
assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedIntLE(i * 4));
} else {
assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedInt(i * 4));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!