java.lang.Integer.toUnsignedLong()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(659)

本文整理了Java中java.lang.Integer.toUnsignedLong()方法的一些代码示例,展示了Integer.toUnsignedLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.toUnsignedLong()方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:toUnsignedLong

Integer.toUnsignedLong介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

  1. static int computePosition(long hashcode, int hashTableSize)
  2. {
  3. return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
  4. }
  5. }

代码示例来源:origin: prestodb/presto

  1. static int computePosition(long hashcode, int hashTableSize)
  2. {
  3. return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
  4. }
  5. }

代码示例来源:origin: apache/flink

  1. public void setValue(long value) {
  2. if (value >= 0L) {
  3. bigInteger = BigInteger.valueOf(value);
  4. } else {
  5. int upper = (int) (value >>> 32);
  6. int lower = (int) value;
  7. bigInteger = BigInteger
  8. .valueOf(Integer.toUnsignedLong(upper))
  9. .shiftLeft(32)
  10. .add(BigInteger.valueOf(Integer.toUnsignedLong(lower)));
  11. }
  12. }

代码示例来源:origin: debezium/debezium

  1. @Override
  2. public long getTransactionId() {
  3. return Integer.toUnsignedLong(rawMessage.getTransactionId());
  4. }

代码示例来源:origin: prestodb/presto

  1. @Benchmark
  2. public long computePositionWithBitShifting()
  3. {
  4. return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) >> 32);
  5. }

代码示例来源:origin: prestodb/presto

  1. @Benchmark
  2. public long computePositionWithDivision()
  3. {
  4. return (int) ((Integer.toUnsignedLong(Long.hashCode(hashcode)) * hashTableSize) / (1 << 32));
  5. }

代码示例来源:origin: eclipse-vertx/vert.x

  1. private void testSetUnsignedInt(Buffer buff) throws Exception {
  2. for (int i = 0; i < numSets; i++) {
  3. long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
  4. buff.setUnsignedInt(i * 4, val);
  5. }
  6. for (int i = 0; i < numSets; i++) {
  7. long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
  8. assertEquals(val, buff.getUnsignedInt(i * 4));
  9. }
  10. }

代码示例来源:origin: debezium/debezium

  1. @Override
  2. public void processMessage(final ByteBuffer buffer, ReplicationMessageProcessor processor, TypeRegistry typeRegistry) throws SQLException, InterruptedException {
  3. try {
  4. if (!buffer.hasArray()) {
  5. throw new IllegalStateException(
  6. "Invalid buffer received from PG server during streaming replication");
  7. }
  8. final byte[] source = buffer.array();
  9. final byte[] content = Arrays.copyOfRange(source, buffer.arrayOffset(), source.length);
  10. final RowMessage message = PgProto.RowMessage.parseFrom(content);
  11. if (!message.getNewTypeinfoList().isEmpty() && message.getNewTupleCount() != message.getNewTypeinfoCount()) {
  12. throw new ConnectException(String.format("Message from transaction {} has {} data columns but only {} of type info",
  13. Integer.toUnsignedLong(message.getTransactionId()),
  14. message.getNewTupleCount(),
  15. message.getNewTypeinfoCount()));
  16. }
  17. processor.process(new PgProtoReplicationMessage(message, typeRegistry));
  18. } catch (InvalidProtocolBufferException e) {
  19. throw new ConnectException(e);
  20. }
  21. }

代码示例来源:origin: eclipse-vertx/vert.x

  1. private void testGetSetUnsignedInt(boolean isLE) throws Exception {
  2. int numInts = 100;
  3. Buffer b = Buffer.buffer(numInts * 4);
  4. for (int i = 0; i < numInts; i++) {
  5. if (isLE) {
  6. b.setUnsignedIntLE(i * 4, (int) (Integer.MAX_VALUE + (long) i));
  7. } else {
  8. b.setUnsignedInt(i * 4, (int) (Integer.MAX_VALUE + (long) i));
  9. }
  10. }
  11. for (int i = 0; i < numInts; i++) {
  12. if (isLE) {
  13. assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedIntLE(i * 4));
  14. } else {
  15. assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedInt(i * 4));
  16. }
  17. }
  18. }

代码示例来源:origin: eclipse-vertx/vert.x

  1. private void testGetSetUnsignedMedium(boolean isLE) throws Exception {
  2. int numInts = 100;
  3. int MEDIUM_MAX_VALUE = BufferTest.MEDIUM_MAX_VALUE - numInts;
  4. Buffer b = Buffer.buffer(numInts * 3);
  5. for (int i = 0; i < numInts; i++) {
  6. if (isLE) {
  7. b.setMediumLE(i * 3, (MEDIUM_MAX_VALUE + i));
  8. } else {
  9. b.setMedium(i * 3, (MEDIUM_MAX_VALUE + i));
  10. }
  11. }
  12. for (int i = 0; i < numInts; i++) {
  13. if (isLE) {
  14. assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMediumLE(i * 3));
  15. } else {
  16. assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMedium(i * 3));
  17. }
  18. }
  19. }

代码示例来源:origin: eclipse-vertx/vert.x

  1. private void testGetSetUnsignedShort(boolean isLE) throws Exception {
  2. int numShorts = 100;
  3. Buffer b = Buffer.buffer(numShorts * 2);
  4. for (short i = 0; i < numShorts; i++) {
  5. if (isLE) {
  6. b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
  7. } else {
  8. b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
  9. }
  10. }
  11. for (short i = 0; i < numShorts; i++) {
  12. if (isLE) {
  13. assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
  14. } else {
  15. assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
  16. }
  17. }
  18. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. /** Check whether the given point is within the considered polygon.
  2. * NOTE: this operates directly on the encoded representation of points. */
  3. public boolean test(int lat, int lon) {
  4. final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
  5. if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
  6. return false;
  7. }
  8. int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
  9. if (lon2 < lonBase) { // wrap
  10. lon2 += 1 << (32 - lonShift);
  11. }
  12. assert Integer.toUnsignedLong(lon2) >= lonBase;
  13. assert lon2 - lonBase >= 0;
  14. if (lon2 - lonBase >= maxLonDelta) {
  15. return false;
  16. }
  17. final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
  18. if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
  19. return tree.contains(decodeLatitude(lat), decodeLongitude(lon));
  20. } else {
  21. return relation == Relation.CELL_INSIDE_QUERY.ordinal();
  22. }
  23. }
  24. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. /** Check whether the given point is within a distance of another point.
  2. * NOTE: this operates directly on the encoded representation of points. */
  3. public boolean test(int lat, int lon) {
  4. final int lat2 = ((lat - Integer.MIN_VALUE) >>> latShift);
  5. if (lat2 < latBase || lat2 >= latBase + maxLatDelta) {
  6. return false;
  7. }
  8. int lon2 = ((lon - Integer.MIN_VALUE) >>> lonShift);
  9. if (lon2 < lonBase) { // wrap
  10. lon2 += 1 << (32 - lonShift);
  11. }
  12. assert Integer.toUnsignedLong(lon2) >= lonBase;
  13. assert lon2 - lonBase >= 0;
  14. if (lon2 - lonBase >= maxLonDelta) {
  15. return false;
  16. }
  17. final int relation = relations[(lat2 - latBase) * maxLonDelta + (lon2 - lonBase)];
  18. if (relation == Relation.CELL_CROSSES_QUERY.ordinal()) {
  19. return SloppyMath.haversinSortKey(
  20. decodeLatitude(lat), decodeLongitude(lon),
  21. this.lat, this.lon) <= distanceKey;
  22. } else {
  23. return relation == Relation.CELL_INSIDE_QUERY.ordinal();
  24. }
  25. }
  26. }

代码示例来源:origin: org.apache.lucene/lucene-core

  1. long max = 0;
  2. for (int i = 0; i < count; ++i) {
  3. max |= Integer.toUnsignedLong(docIds[start + i]);

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. public static long encodeLatLon(double lat, double lon) {
  2. return (Integer.toUnsignedLong(GeoEncodingUtils.encodeLatitude(lat)) << 32) | Integer.toUnsignedLong(GeoEncodingUtils.encodeLongitude(lon));
  3. }

代码示例来源:origin: stackoverflow.com

  1. long l = Integer.toUnsignedLong(uint);
  2. System.out.println(l); // will print 4294967295
  3. int x = Integer.parseUnsignedInt("4294967295");
  4. int y = 5;
  5. int cmp1 = Integer.compareUnsigned(x,y); // interprets x as 4294967295 (x>y)
  6. int cmp2 = Integer.compare(x,y); // interprets x as -1 (x<y)

代码示例来源:origin: org.elasticsearch/elasticsearch

  1. static void verifyChecksum(BufferedChecksumStreamInput in) throws IOException {
  2. // This absolutely must come first, or else reading the checksum becomes part of the checksum
  3. long expectedChecksum = in.getChecksum();
  4. long readChecksum = Integer.toUnsignedLong(in.readInt());
  5. if (readChecksum != expectedChecksum) {
  6. throw new TranslogCorruptedException(in.getSource(), "checksum verification failed - expected: 0x" +
  7. Long.toHexString(expectedChecksum) + ", got: 0x" + Long.toHexString(readChecksum));
  8. }
  9. }

代码示例来源:origin: io.vertx/vertx-core

  1. private void testSetUnsignedInt(Buffer buff) throws Exception {
  2. for (int i = 0; i < numSets; i++) {
  3. long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
  4. buff.setUnsignedInt(i * 4, val);
  5. }
  6. for (int i = 0; i < numSets; i++) {
  7. long val = Integer.toUnsignedLong(Integer.MAX_VALUE + i);
  8. assertEquals(val, buff.getUnsignedInt(i * 4));
  9. }
  10. }

代码示例来源:origin: io.vertx/vertx-core

  1. private void testGetSetUnsignedShort(boolean isLE) throws Exception {
  2. int numShorts = 100;
  3. Buffer b = Buffer.buffer(numShorts * 2);
  4. for (short i = 0; i < numShorts; i++) {
  5. if (isLE) {
  6. b.setUnsignedShortLE(i * 2, (short) (Short.MAX_VALUE + (int) i));
  7. } else {
  8. b.setUnsignedShort(i * 2, (short) (Short.MAX_VALUE + (int) i));
  9. }
  10. }
  11. for (short i = 0; i < numShorts; i++) {
  12. if (isLE) {
  13. assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShortLE(i * 2));
  14. } else {
  15. assertEquals(Integer.toUnsignedLong(Short.MAX_VALUE + i), b.getUnsignedShort(i * 2));
  16. }
  17. }
  18. }

代码示例来源:origin: io.vertx/vertx-core

  1. private void testGetSetUnsignedInt(boolean isLE) throws Exception {
  2. int numInts = 100;
  3. Buffer b = Buffer.buffer(numInts * 4);
  4. for (int i = 0; i < numInts; i++) {
  5. if (isLE) {
  6. b.setUnsignedIntLE(i * 4, (int) (Integer.MAX_VALUE + (long) i));
  7. } else {
  8. b.setUnsignedInt(i * 4, (int) (Integer.MAX_VALUE + (long) i));
  9. }
  10. }
  11. for (int i = 0; i < numInts; i++) {
  12. if (isLE) {
  13. assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedIntLE(i * 4));
  14. } else {
  15. assertEquals(Integer.toUnsignedLong(Integer.MAX_VALUE + i), b.getUnsignedInt(i * 4));
  16. }
  17. }
  18. }

相关文章