Fix persist of empty indexes in index generator job

When the number of rows ends exactly on row flush boundaries, persisting an empty index causes null pointer exceptions.