private static int rehashWithoutTombstones(final @NotNull AtomicReferenceArray<PageImpl> sourcePages,
                                             final @NotNull AtomicReferenceArray<PageImpl> targetPages) throws NoFreeSpaceException {
    final IntRef insertionIndexRef = new IntRef();
    int pagesCopied = 0;
    for (int i = 0; i < sourcePages.length(); i++) {
      final PageImpl page = sourcePages.get(i);
      if (page == null) {
        continue;
      }
      else if (page.isTombstone()) {
        continue;
      }
      final int pageIndex = page.pageIndex();
      final PageImpl pageMustNotBeFound = findPageOrInsertionIndex(targetPages, pageIndex, insertionIndexRef);
      final int insertionIndex = insertionIndexRef.get();

      if (pageMustNotBeFound != null) {
        throw new AssertionError("Page[#" + pageIndex + "] is copying now -- can't be already in .newPages! " +
                                 "\nsource: " + sourcePages +
                                 "\ntarget: " + targetPages);
      }
      if (insertionIndex < 0) {
        if (pagesCopied == targetPages.length()) {
          //either targetPages is too small to fit, or code bug in hashing logic
          throw new NoFreeSpaceException("Not enough space in targetPages(length: " + targetPages.length() + "): " +
                                         "sourcePages(length: " + sourcePages.length() + ") contains > " + pagesCopied +
                                         " !tombstone pages. \nsource: " + sourcePages + "\ntarget: " + targetPages);
        }
        else {
          throw new AssertionError("Bug: insertion index must be found for Page[#" + pageIndex + "] during rehash. " +
                                   " source.length: " + sourcePages.length() + " target.length: " + targetPages.length() +
                                   "\nsource: " + sourcePages +
                                   "\ntarget: " + targetPages);
        }
      }

      targetPages.set(insertionIndex, page);
      pagesCopied++;
    }
    return pagesCopied;
  }
private static int rehashWithoutTombstones(final @NotNull AtomicReferenceArray<PageImpl> sourcePages,
                                             final @NotNull AtomicReferenceArray<PageImpl> targetPages)