io.airlift.slice.Slice.getUnsignedByte()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(163)

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

Slice.getUnsignedByte介绍

[英]Gets an unsigned byte at the specified absolute index in this buffer.
[中]获取此缓冲区中指定绝对索引处的无符号字节。

代码示例

代码示例来源:origin: airlift/slice

  1. k2 ^= ((long) data.getUnsignedByte(current + 14)) << 48;
  2. case 14:
  3. k2 ^= ((long) data.getUnsignedByte(current + 13)) << 40;
  4. case 13:
  5. k2 ^= ((long) data.getUnsignedByte(current + 12)) << 32;
  6. case 12:
  7. k2 ^= ((long) data.getUnsignedByte(current + 11)) << 24;
  8. case 11:
  9. k2 ^= ((long) data.getUnsignedByte(current + 10)) << 16;
  10. case 10:
  11. k2 ^= ((long) data.getUnsignedByte(current + 9)) << 8;
  12. case 9:
  13. k2 ^= ((long) data.getUnsignedByte(current + 8)) << 0;
  14. k1 ^= ((long) data.getUnsignedByte(current + 7)) << 56;
  15. case 7:
  16. k1 ^= ((long) data.getUnsignedByte(current + 6)) << 48;
  17. case 6:
  18. k1 ^= ((long) data.getUnsignedByte(current + 5)) << 40;
  19. case 5:
  20. k1 ^= ((long) data.getUnsignedByte(current + 4)) << 32;
  21. case 4:
  22. k1 ^= ((long) data.getUnsignedByte(current + 3)) << 24;
  23. case 3:
  24. k1 ^= ((long) data.getUnsignedByte(current + 2)) << 16;
  25. case 2:
  26. k1 ^= ((long) data.getUnsignedByte(current + 1)) << 8;
  27. case 1:
  28. k1 ^= ((long) data.getUnsignedByte(current + 0)) << 0;

代码示例来源:origin: airlift/slice

  1. @Test
  2. public void testUnsignedByte()
  3. {
  4. int expected = 0xA5;
  5. assertTrue(expected > 0);
  6. assertEquals(slice.getUnsignedByte(0), expected);
  7. }

代码示例来源:origin: io.airlift/slice

  1. @Test
  2. public void testUnsignedByte()
  3. {
  4. int expected = 0xA5;
  5. assertTrue(expected > 0);
  6. assertEquals(slice.getUnsignedByte(0), expected);
  7. }

代码示例来源:origin: io.airlift/slice

  1. k2 ^= ((long) data.getUnsignedByte(current + 14)) << 48;
  2. case 14:
  3. k2 ^= ((long) data.getUnsignedByte(current + 13)) << 40;
  4. case 13:
  5. k2 ^= ((long) data.getUnsignedByte(current + 12)) << 32;
  6. case 12:
  7. k2 ^= ((long) data.getUnsignedByte(current + 11)) << 24;
  8. case 11:
  9. k2 ^= ((long) data.getUnsignedByte(current + 10)) << 16;
  10. case 10:
  11. k2 ^= ((long) data.getUnsignedByte(current + 9)) << 8;
  12. case 9:
  13. k2 ^= ((long) data.getUnsignedByte(current + 8)) << 0;
  14. k1 ^= ((long) data.getUnsignedByte(current + 7)) << 56;
  15. case 7:
  16. k1 ^= ((long) data.getUnsignedByte(current + 6)) << 48;
  17. case 6:
  18. k1 ^= ((long) data.getUnsignedByte(current + 5)) << 40;
  19. case 5:
  20. k1 ^= ((long) data.getUnsignedByte(current + 4)) << 32;
  21. case 4:
  22. k1 ^= ((long) data.getUnsignedByte(current + 3)) << 24;
  23. case 3:
  24. k1 ^= ((long) data.getUnsignedByte(current + 2)) << 16;
  25. case 2:
  26. k1 ^= ((long) data.getUnsignedByte(current + 1)) << 8;
  27. case 1:
  28. k1 ^= ((long) data.getUnsignedByte(current + 0)) << 0;

代码示例来源:origin: airlift/slice

  1. @SuppressFBWarnings({"SF_SWITCH_NO_DEFAULT", "SF_SWITCH_FALLTHROUGH"})
  2. public static int hash(int seed, Slice data, int offset, int length)
  3. {
  4. final int fastLimit = offset + length - SizeOf.SIZE_OF_INT + 1;
  5. int h1 = seed;
  6. int current = offset;
  7. while (current < fastLimit) {
  8. int k1 = mixK1(data.getInt(current));
  9. current += SizeOf.SIZE_OF_INT;
  10. h1 = mixH1(h1, k1);
  11. }
  12. int k1 = 0;
  13. switch (length & 3) {
  14. case 3:
  15. k1 ^= ((int) data.getUnsignedByte(current + 2)) << 16;
  16. case 2:
  17. k1 ^= ((int) data.getUnsignedByte(current + 1)) << 8;
  18. case 1:
  19. k1 ^= ((int) data.getUnsignedByte(current + 0)) << 0;
  20. }
  21. h1 ^= mixK1(k1);
  22. return fmix(h1, length);
  23. }

代码示例来源:origin: io.airlift/slice

  1. @SuppressFBWarnings({"SF_SWITCH_NO_DEFAULT", "SF_SWITCH_FALLTHROUGH"})
  2. public static int hash(int seed, Slice data, int offset, int length)
  3. {
  4. final int fastLimit = offset + length - SizeOf.SIZE_OF_INT + 1;
  5. int h1 = seed;
  6. int current = offset;
  7. while (current < fastLimit) {
  8. int k1 = mixK1(data.getInt(current));
  9. current += SizeOf.SIZE_OF_INT;
  10. h1 = mixH1(h1, k1);
  11. }
  12. int k1 = 0;
  13. switch (length & 3) {
  14. case 3:
  15. k1 ^= ((int) data.getUnsignedByte(current + 2)) << 16;
  16. case 2:
  17. k1 ^= ((int) data.getUnsignedByte(current + 1)) << 8;
  18. case 1:
  19. k1 ^= ((int) data.getUnsignedByte(current + 0)) << 0;
  20. }
  21. h1 ^= mixK1(k1);
  22. return fmix(h1, length);
  23. }

代码示例来源:origin: io.airlift/slice

  1. k2 ^= ((long) data.getUnsignedByte(current + 14)) << 48;
  2. case 14:
  3. k2 ^= ((long) data.getUnsignedByte(current + 13)) << 40;
  4. case 13:
  5. k2 ^= ((long) data.getUnsignedByte(current + 12)) << 32;
  6. case 12:
  7. k2 ^= ((long) data.getUnsignedByte(current + 11)) << 24;
  8. case 11:
  9. k2 ^= ((long) data.getUnsignedByte(current + 10)) << 16;
  10. case 10:
  11. k2 ^= ((long) data.getUnsignedByte(current + 9)) << 8;
  12. case 9:
  13. k2 ^= ((long) data.getUnsignedByte(current + 8)) << 0;
  14. k1 ^= ((long) data.getUnsignedByte(current + 7)) << 56;
  15. case 7:
  16. k1 ^= ((long) data.getUnsignedByte(current + 6)) << 48;
  17. case 6:
  18. k1 ^= ((long) data.getUnsignedByte(current + 5)) << 40;
  19. case 5:
  20. k1 ^= ((long) data.getUnsignedByte(current + 4)) << 32;
  21. case 4:
  22. k1 ^= ((long) data.getUnsignedByte(current + 3)) << 24;
  23. case 3:
  24. k1 ^= ((long) data.getUnsignedByte(current + 2)) << 16;
  25. case 2:
  26. k1 ^= ((long) data.getUnsignedByte(current + 1)) << 8;
  27. case 1:
  28. k1 ^= ((long) data.getUnsignedByte(current + 0)) << 0;

代码示例来源:origin: airlift/slice

  1. public static void assertSlicesEqual(Slice actual, Slice expected)
  2. {
  3. if (actual == null && expected == null) {
  4. return;
  5. }
  6. else if (actual == null) {
  7. throw new AssertionError("Actual is null");
  8. }
  9. else if (expected == null) {
  10. throw new AssertionError("Expected actual to be null");
  11. }
  12. if (actual.length() != expected.length()) {
  13. throw new AssertionError(String.format("Slices differ in size. Actual: %s, expected: %s", actual.length(), expected.length()));
  14. }
  15. for (int i = 0; i < actual.length(); i++) {
  16. if (actual.getByte(i) != expected.getByte(i)) {
  17. throw new AssertionError(String.format("Slices differ at index %s. Actual: 0x%02x, expected: 0x%02x", i, actual.getUnsignedByte(i), expected.getUnsignedByte(i)));
  18. }
  19. }
  20. }
  21. }

代码示例来源:origin: airlift/slice

  1. k2 ^= ((long) data.getUnsignedByte(current + 14)) << 48;
  2. case 14:
  3. k2 ^= ((long) data.getUnsignedByte(current + 13)) << 40;
  4. case 13:
  5. k2 ^= ((long) data.getUnsignedByte(current + 12)) << 32;
  6. case 12:
  7. k2 ^= ((long) data.getUnsignedByte(current + 11)) << 24;
  8. case 11:
  9. k2 ^= ((long) data.getUnsignedByte(current + 10)) << 16;
  10. case 10:
  11. k2 ^= ((long) data.getUnsignedByte(current + 9)) << 8;
  12. case 9:
  13. k2 ^= ((long) data.getUnsignedByte(current + 8)) << 0;
  14. k1 ^= ((long) data.getUnsignedByte(current + 7)) << 56;
  15. case 7:
  16. k1 ^= ((long) data.getUnsignedByte(current + 6)) << 48;
  17. case 6:
  18. k1 ^= ((long) data.getUnsignedByte(current + 5)) << 40;
  19. case 5:
  20. k1 ^= ((long) data.getUnsignedByte(current + 4)) << 32;
  21. case 4:
  22. k1 ^= ((long) data.getUnsignedByte(current + 3)) << 24;
  23. case 3:
  24. k1 ^= ((long) data.getUnsignedByte(current + 2)) << 16;
  25. case 2:
  26. k1 ^= ((long) data.getUnsignedByte(current + 1)) << 8;
  27. case 1:
  28. k1 ^= ((long) data.getUnsignedByte(current + 0)) << 0;

代码示例来源:origin: io.airlift/slice

  1. public static void assertSlicesEqual(Slice actual, Slice expected)
  2. {
  3. if (actual == null && expected == null) {
  4. return;
  5. }
  6. else if (actual == null) {
  7. throw new AssertionError("Actual is null");
  8. }
  9. else if (expected == null) {
  10. throw new AssertionError("Expected actual to be null");
  11. }
  12. if (actual.length() != expected.length()) {
  13. throw new AssertionError(String.format("Slices differ in size. Actual: %s, expected: %s", actual.length(), expected.length()));
  14. }
  15. for (int i = 0; i < actual.length(); i++) {
  16. if (actual.getByte(i) != expected.getByte(i)) {
  17. throw new AssertionError(String.format("Slices differ at index %s. Actual: 0x%02x, expected: 0x%02x", i, actual.getUnsignedByte(i), expected.getUnsignedByte(i)));
  18. }
  19. }
  20. }
  21. }

相关文章