Should this one be null? Or better, do

    if (!SharkEnv.memoryMetadataManager.getStats(_databaseName, _tableName).isDefined) {
      ...
    }

Right now it sounds as indexToStats is to be used in this function.