core/src/main/java/com/orientechnologies/common/util/OByteBufferUtils.java
public static int mergeIntFromBuffers(final ByteBuffer buffer, final ByteBuffer buffer1) {
    int result = 0;
    final int remaining = buffer.remaining();
    for (int i = 0; i < remaining; ++i) {
      result = result | (buffer.get() & MASK);
      result = result << SIZE_OF_BYTE_IN_BITS;
    }
    for (int i = 0; i < SIZE_OF_INT - remaining - 1; ++i) {
      result = result | (buffer1.get() & MASK);
      result = result << SIZE_OF_BYTE_IN_BITS;
    }
    result = result | (buffer1.get() & MASK);
    return result;
  }
public static int mergeIntFromBuffers(final ByteBuffer buffer, final ByteBuffer buffer1) {
    int result = 0;
    final int remaining = buffer.remaining();
    for (int i = 0; i < remaining; ++i) {
      result = result | (buffer.get() & MASK);
      result = result << SIZE_OF_BYTE_IN_BITS;
    }
    for (int i = 0; i < SIZE_OF_INT - remaining - 1; ++i) {
      result = result | (buffer1.get() & MASK);
      result = result << SIZE_OF_BYTE_IN_BITS;
    }
    result = result | (buffer1.get() & MASK);
    return result;
  }
public static int mergeIntFromBuffers ( final ByteBuffer buffer , final ByteBuffer buffer1 ) { int result = 0 ; final int remaining = buffer . remaining ( ) ; for ( int i = 0 ; i < remaining ; ++ i ) { result = result | ( buffer . get ( ) & MASK ) ; result = result << SIZE_OF_BYTE_IN_BITS ; } for ( int i = 0 ; i < SIZE_OF_INT - remaining - 1 ; ++ i ) { result = result | ( buffer1 . get ( ) & MASK ) ; result = result << SIZE_OF_BYTE_IN_BITS ; } result = result | ( buffer1 . get ( ) & MASK ) ; return result ; }
Merge int value from two byte buffer. First bytes of int will be extracted from first byte buffer and second from second one.
How many bytes will be read from first buffer determines based on <code>buffer.remaining()</code> value

@param buffer
to read first part of value
@param buffer1
to read second part of value
@return merged value
Merge int value from two byte buffer . First bytes of int will be extracted from first byte buffer and second from second one . How many bytes will be read from first buffer determines based on <code > buffer . remaining () < / code > value