@Test
  public void testInsertMultipleElements() throws IOException {
    // Test adding a large number of elements, so that block splitting will
    // need to take place.
    int blockSize = 100;
    int keySize = 4;
    int numIndexPairs = 300;
    AbstractBlockBasedIndex<?> index = createIndex(tempFolder, keySize, blockSize);

    IndexPair[] indexPairs = new IndexPair[numIndexPairs];
    
    int idCounter = 0;
    for (int i = 0; i < numIndexPairs; i++) {
      long[] key = new long[] { 0, (byte) (0xFF & (i >> 8)),
          (byte) (0xFF & i), 1 };
      IndexPair pair = createIndexPair(key, idCounter++);
      indexPairs[i] = pair;
    }
    Arrays.sort(indexPairs, IndexPair.COMPARATOR);
    index.bulkLoad(indexPairs);

    // Add the new elements.
    IndexPair[] newIndexPairs = new IndexPair[numIndexPairs];
    for (int i = 0; i < numIndexPairs; i++) {
      long[] key = new long[] { 0, (byte) (0xFF & (i >> 8)),
          (byte) (0xFF & i), 0 };
      IndexPair pair = createIndexPair(key, idCounter++);
      newIndexPairs[i] = pair;
      index.insertElement(pair);
    }

    // Check all the values.
    for (IndexPair indexPair : indexPairs) {
      int retrievedElement = index
          .getElement(indexPair.getBitSignature());
      Assert.assertEquals(indexPair.getElementId(), retrievedElement);
    }
    for (IndexPair indexPair : newIndexPairs) {
      int retrievedElement = index
          .getElement(indexPair.getBitSignature());
      Assert.assertEquals(indexPair.getElementId(), retrievedElement);
    }
  }