Compares the content of the specified buffer to the content of this
buffer.  This comparison is performed byte by byte using an unsigned
comparison.
1403
@SuppressWarnings("ObjectEquality")
    @Override
    public int compareTo(Slice that)
    {
        if (this == that) {
            return 0;
        }
        return compareTo(0, size, that, 0, that.size);
    }
44555
@Override
	public int compare(int i, int j) {
		final int bufferNumI = i / this.recordsPerSegment;
		final int segmentOffsetI = (i % this.recordsPerSegment) * this.recordSize;
		
		final int bufferNumJ = j / this.recordsPerSegment;
		final int segmentOffsetJ = (j % this.recordsPerSegment) * this.recordSize;
		
		final MemorySegment segI = this.sortBuffer.get(bufferNumI);
		final MemorySegment segJ = this.sortBuffer.get(bufferNumJ);
		
		int val = MemorySegment.compare(segI, segJ, segmentOffsetI, segmentOffsetJ, this.numKeyBytes);
		return this.useNormKeyUninverted ? val : -val;
	}
518976
public int compareTo(ByteSequence obs) {
        if (isBackedByArray() && obs.isBackedByArray()) {
            return WritableComparator.compareBytes(getBackingArray(), offset(), length(), obs.getBackingArray(), obs.offset(), obs.length());
        }

        return compareBytes(this, obs);
    }
1047705
private byte readByte()
            throws IOException
    {
        if (buffer.size() > position) {
            byte b = buffer.getByte(position);
            position++;
            return b;
        }
        else {
            nextBuffer();
            if (buffer.size() > 0) {
                byte b = buffer.getByte(0);
                position = 1;
                return b;
            }
            return readByte();
        }
    }
622217
@Override
    public int compareTo(PrefixedChecksummedBytes o) {
        int result = this.params.getId().compareTo(o.params.getId());
        return result != 0 ? result : UnsignedBytes.lexicographicalComparator().compare(this.bytes, o.bytes);
    }
691901
@Override
    public int compareTo(Object obj) {
        if (!this.trusted)
            checkValidity();
        final ByteBuffer other = ((WsByteBuffer) obj).getWrappedByteBufferNonSafe();
        return this.oByteBuffer.compareTo(other);
    }
1122877
private static boolean hasSameContent(final InputStream stream1, final InputStream stream2) throws IOException {
    int byte1 = -1;
    int byte2 = -1;
    do {
      byte1 = stream1.read();
      byte2 = stream2.read();

    } while (byte1 == byte2 && byte1 != -1);
    return byte1 == byte2;
  }
1243021
public int compareTo(BinaryComparable other) {
        if (this == other)
            return 0;
        return WritableComparator.compareBytes(getBytes(), 0, getLength(), other.getBytes(), 0, other.getLength());
    }
1249007
private boolean matchString(final ByteBuffer bbuf) throws IOException {
		if (this.isBetween) {
			final String buffer = new String(bbuf.array());
			if (buffer.contains(getContent())) {
				return true;
			}
			return false;
		}
		final int read = getContent().length();
		for (int j = 0; j < read; j++) {
			if ((bbuf.get(j) & 0xFF) != getContent().charAt(j)) {
				return false;
			}
		}
		return true;
	}
188019
@Override
    public int read(final ByteBuffer destination) throws IOException {

        // Precondition checks
        this.checkClosed();
        if (destination == null) {
            throw new IllegalArgumentException("Destination buffer must be supplied");
        }

        // Init
        final int spaceInBuffer = destination.remaining();
        final int numBytesRemainingInContent, numBytesToRead;

        // Sync up before getting at shared mutable state
        synchronized (this) {
            numBytesRemainingInContent = this.contents.length - this.position;

            // Set position was greater than the size? Just return.
            if (numBytesRemainingInContent <= 0) {
                return -1;
            }

            // We'll read in either the number of bytes remaining in content or the amount of space in the buffer,
            // whichever is smaller
            numBytesToRead = numBytesRemainingInContent >= spaceInBuffer ? spaceInBuffer : numBytesRemainingInContent;
            // Copy a sub-array of the bytes we'll put into the buffer
            destination.put(this.contents, this.position, numBytesToRead);

            // Set the new position
            this.position += numBytesToRead;
        }

        // Return the number of bytes read
        return numBytesToRead;
    }
789623
public void writeByteBufferPart(byte[] buffer, int offset, int length)
        throws IOException
    {
        while (length > 0) {
            flushIfFull();

            int sublen = _buffer.length - _offset;

            if (length < sublen)
                sublen = length;

            _buffer[_offset++] = BC_BINARY_CHUNK;
            _buffer[_offset++] = (byte) (sublen >> 8);
            _buffer[_offset++] = (byte) sublen;

            System.arraycopy(buffer, offset, _buffer, _offset, sublen);

            _offset += sublen;
            length -= sublen;
            offset += sublen;
        }
    }
933726
protected void bufferize(byte b) {
        if (index == buffer.length) {
            byte[] newBuffer = new byte[buffer.length * 2];
            System.arraycopy(buffer, 0, newBuffer, 0, index);
            buffer = newBuffer;
        }
        buffer[index++] = b;
    }
1069774
public static boolean equal(File file1, File file2) throws IOException {
    checkNotNull(file1);
    checkNotNull(file2);
    if (file1 == file2 || file1.equals(file2)) {
      return true;
    }

    /*
     * Some operating systems may return zero as the length for files denoting system-dependent
     * entities such as devices or pipes, in which case we must fall back on comparing the bytes
     * directly.
     */
    long len1 = file1.length();
    long len2 = file2.length();
    if (len1 != 0 && len2 != 0 && len1 != len2) {
      return false;
    }
    return asByteSource(file1).contentEquals(asByteSource(file2));
  }
501273
private boolean contentEqualsUnchecked(byte[] bytes, int offset, int len) {
    if (length != len) {
      return false;
    }

    return compareToUnchecked(bytes, offset, len) == 0;
  }
731577
public static boolean isNext(final Buffer buffer, final byte b) throws IOException {
        if (buffer.hasReadableBytes()) {
            final byte actual = buffer.peekByte();
            return actual == b;
        }

        return false;
    }
262682
private static boolean directByteBufferEquals(ByteBuffer buffa, ByteBuffer buffb)
    {
        if ( buffa == buffb )
        {
            return true;
        }
        
        if ( buffa ==null || buffb == null )
        {
            return false;
        }
        
        buffa.rewind();
        buffb.rewind();
        
        int length = buffa.remaining();
        
        if ( buffb.remaining() != length )
        {
            return false;
        }
        
        for ( int i = 0; i < length; i++ )
        {
            if ( buffa.get() != buffb.get() )
            {
                return false;
            }
        }

        return true;
    }
1089118
private static boolean arrayCompare(byte[] a, int offset1, byte[] a2, int offset2, int length) {
        for (int i = 0; i < length; i++) {
            if (a[offset1++] != a2[offset2++]) return false;
        }
        return true;
    }