com.google.protobuf.ByteString.ByteIterator Java Examples

The following examples show how to use com.google.protobuf.ByteString.ByteIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BigtableBackendTest.java    From heroic with Apache License 2.0 6 votes vote down vote up
int compare(ByteString a, ByteString b) {
    ByteIterator itA = a.iterator();
    ByteIterator itB = b.iterator();

    while (itA.hasNext()) {
        if (!itB.hasNext()) {
            return -1;
        }

        int bA = itA.nextByte() & 0xff;
        int bB = itB.nextByte() & 0xff;

        int c = Integer.compare(bA, bB);

        if (c != 0) {
            return c;
        }
    }

    if (itB.hasNext()) {
        return 1;
    }

    return 0;
}
 
Example #2
Source File: ProtoSpanDeserializer.java    From jaeger-analytics-java with Apache License 2.0 5 votes vote down vote up
private String asHexString(ByteString id) {
  ByteIterator iterator = id.iterator();
  StringBuilder out = new StringBuilder();
  while (iterator.hasNext()) {
    byte b = iterator.nextByte();
    out.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
  }
  return out.toString();
}
 
Example #3
Source File: ProtoUnmarshaler.java    From Mastering-Distributed-Tracing with MIT License 5 votes vote down vote up
private String asHexString(ByteString id) {
    ByteIterator iterator = id.iterator();
    StringBuilder out = new StringBuilder();
    while (iterator.hasNext()) {
        byte b = iterator.nextByte();
        out.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
    }
    return out.toString();
}