code: @VisibleForTesting
      public int findPositionOf(ByteBuffer context, CounterId id)
      {
          int headerLength = headerLength(context);
          int offset = context.position() + headerLength;
  
          int left = 0;
          int right = (context.remaining() - headerLength) / STEP_LENGTH - 1;
  
          while (right >= left)
          {
              int middle = (left + right) / 2;
              int cmp = compareId(context, offset + middle * STEP_LENGTH, id.bytes(), id.bytes().position());
  
              if (cmp == -1)
                  left = middle + 1;
              else if (cmp == 0)
                  return offset + middle * STEP_LENGTH;
              else
                  right = middle - 1;
          }
  
          return -1; // position not found
      }
docs: Finds the position of a shard with the given id within the context (via binary search).