'Initialize a ResultDatabase object.
Args:
db_filename: The name of the SQLite database to use.
signature: A string identifying the important invocation options,
used to make sure we are not using an old database.
commit_periodicity: How many operations to perform between commits.
exporter: Exporter instance; if exporter.calculate_sort_key_from_entity
is true then exporter.sort_key_from_entity(entity) will be called.'

def __init__(self, db_filename, signature, commit_periodicity=1, exporter=None):

    self.complete = False
    create_table = 'create    table    result    (\nid    BLOB    primary    key,\nvalue    BLOB    not    null,\nsort_key    BLOB)'
    _Database.__init__(self, db_filename, create_table, signature, commit_periodicity=commit_periodicity)
    if self.existing_table:
        cursor = self.primary_conn.cursor()
        cursor.execute('select    count(*)    from    result')
        self.existing_count = int(cursor.fetchone()[0])
    else:
        self.existing_count = 0
    self.count = self.existing_count
    if (exporter and getattr(exporter, 'calculate_sort_key_from_entity', False)):
        self.sort_key_from_entity = exporter.sort_key_from_entity
    else:
        self.sort_key_from_entity = None
