@Test
  public void testDeleteElement() {
    int blockSize = 100;
    int keySize = 4;
    int numIndexPairs = 300;
    AbstractBlockBasedIndex<?> index = createIndex(tempFolder, keySize, blockSize);

    IndexPair[] indexPairs = new IndexPair[numIndexPairs];
    for (int i = 0; i < numIndexPairs; i++) {
      byte signatureByte0 = (byte) (i % 100);
      byte signatureByte1 = (byte) ((i / 100) % 100);
      long[] key = new long[] { 0, 0, signatureByte1, signatureByte0 };
      IndexPair pair = createIndexPair(key, i);
      indexPairs[i] = pair;
    }
    Arrays.sort(indexPairs, IndexPair.COMPARATOR);
    index.bulkLoad(indexPairs);

    int indexToRemove = 4;
    IndexPair pairToRemove = indexPairs[indexToRemove];
    index.deleteElement(pairToRemove.getBitSignature());
    for (int i = 0; i < numIndexPairs; i++) {
      if (i == indexToRemove)
        continue;
      Assert.assertEquals(indexPairs[i].getElementId(),
          index.getElement(indexPairs[i].getBitSignature()));
    }

    try {
      index.getElement(pairToRemove.getBitSignature());
      Assert.fail("Element should not be included any more.");
    } catch (IllegalArgumentException e) {
      // happy path
    }
  }