<commit_before>package org.ethereum.db;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.ethereum.datasource.mapdb.MapDBFactory;
import org.ethereum.util.FastByteComparisons;
import org.mapdb.DB;
import org.mapdb.Serializer;

import java.util.*;

import static org.ethereum.config.SystemProperties.CONFIG;

/**
 * @author <NAME>
 * @since 07.07.2015
 */
public class HashStoreImpl implements HashStore {

    private final static String STORE_NAME = "hashstore";
    private MapDBFactory mapDBFactory;

    private DB db;
    private Map<Long, byte[]> hashes;
    private List<Long> index;

    @Override
    public void open() {
        db = mapDBFactory.createTransactionalDB(dbName());
        hashes = db.hashMapCreate(STORE_NAME)
                .keySerializer(Serializer.LONG)
                .valueSerializer(Serializer.BYTE_ARRAY)
                .makeOrGet();
        index = new ArrayList<>(hashes.keySet());
        sortIndex();
    }
<commit_msg>Clean up HashStore on open()<commit_after>package org.ethereum.db;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
import org.ethereum.datasource.mapdb.MapDBFactory;
import org.ethereum.util.FastByteComparisons;
import org.mapdb.DB;
import org.mapdb.Serializer;

import java.util.*;

import static org.ethereum.config.SystemProperties.CONFIG;

/**
 * @author <NAME>
 * @since 07.07.2015
 */
public class HashStoreImpl implements HashStore {

    private final static String STORE_NAME = "hashstore";
    private MapDBFactory mapDBFactory;

    private DB db;
    private Map<Long, byte[]> hashes;
    private List<Long> index;

    @Override
    public void open() {
        db = mapDBFactory.createTransactionalDB(dbName());
        hashes = db.hashMapCreate(STORE_NAME)
                .keySerializer(Serializer.LONG)
                .valueSerializer(Serializer.BYTE_ARRAY)
                .makeOrGet();
        hashes.clear();
        db.commit();
        index = new ArrayList<>();
    }

{'fraction_non_alphanumeric': 0.1068334937439846, 'fraction_numerical': 0.009624639076034648, 'mean_word_length': 3.3043478260869565, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5830808', 'n_tokens_mistral': 639, 'n_tokens_neox': 611, 'n_words': 129}