code: public int findElementInReadBuffer(ByteBuffer workingBuffer, byte[] key, int indexInChunk) {
          workingBuffer.position(indexInChunk);
          int minElement = indexInChunk / gp.getElementSize();
          int numberOfEntries = workingBuffer.limit() / gp.getElementSize();
  
          // binary search
          int maxElement = numberOfEntries - 1;
          int midElement;
          int comp;
          byte[] tempKey = new byte[gp.getKeySize()];
  
          while (minElement <= maxElement) {
              midElement = minElement + (maxElement - minElement) / 2;
              indexInChunk = midElement * gp.getElementSize();
  
              workingBuffer.position(indexInChunk);
              workingBuffer.get(tempKey);
  
              comp = KeyUtils.compareKey(key, tempKey, gp.getKeySize());
              if (comp == 0) {
                  return indexInChunk;
              } else if (comp < 0) {
                  maxElement = midElement - 1;
              } else {
                  minElement = midElement + 1;
              }
          }
          return -1;
      }
docs: Searches for the given key in workingBuffer, beginning at the given index. Remember: The records in the
  given workingBuffer have to be ordered ascending.
  
  @param workingBuffer
  the ByteBuffer to work on
  @param key
  the key to find
  @param indexInChunk
  the start position of reading the <code>workingBuffer</code>
  @return the byteOffset where the key was found.<br>
  -1 if the key wasn't found