<commit_before>package com.proofpoint.dbpool;

import com.google.inject.Inject;
import org.h2.jdbcx.JdbcDataSource;
import org.h2.util.ScriptReader;

import java.io.FileReader;
import java.io.File;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.FileNotFoundException;
import static java.lang.Math.ceil;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import static java.util.concurrent.TimeUnit.SECONDS;

public class H2EmbeddedDataSource extends ManagedDataSource
{
    @Inject
    public H2EmbeddedDataSource(H2EmbeddedDataSourceConfig config)
            throws Exception
    {
        super(createMySQLConnectionPoolDataSource(config),
                config.getMaxConnections(),
                config.getMaxConnectionWait());


        Connection connection = getConnection();
        try {
            setConfig(connection, "CACHE_SIZE", config.getCacheSize());
            setConfig(connection, "COMPRESS_LOB", config.getCompressLob());

            Reader fileReader;
            String fileName = config.getInitScript();
            if (new File(fileName).exists()) {
                fileReader = new FileReader(fileName);
            } else {
                InputStream stream = getClass().getClassLoader().getResourceAsStream(fileName);
                if (stream == null) {
                    throw new FileNotFoundException(fileName);<commit_msg>Do not close db when all connections are closed<commit_after>package com.proofpoint.dbpool;

import com.google.inject.Inject;
import org.h2.jdbcx.JdbcDataSource;
import org.h2.util.ScriptReader;

import java.io.FileReader;
import java.io.File;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.FileNotFoundException;
import static java.lang.Math.ceil;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import static java.util.concurrent.TimeUnit.SECONDS;

public class H2EmbeddedDataSource extends ManagedDataSource
{
    @Inject
    public H2EmbeddedDataSource(H2EmbeddedDataSourceConfig config)
            throws Exception
    {
        super(createMySQLConnectionPoolDataSource(config),
                config.getMaxConnections(),
                config.getMaxConnectionWait());


        Connection connection = getConnection();
        try {
            setConfig(connection, "CACHE_SIZE", config.getCacheSize());
            setConfig(connection, "COMPRESS_LOB", config.getCompressLob());
            setConfig(connection, "DB_CLOSE_DELAY ", "-1");

            Reader fileReader;
            String fileName = config.getInitScript();
            if (new File(fileName).exists()) {
                fileReader = new FileReader(fileName);
            } else {
                InputStream stream = getClass().getClassLoader().getResourceAsStream(fileName);
                if (stream == null) {
                    throw new FileNotFoundException(fileName);
{'fraction_non_alphanumeric': 0.0933955970647098, 'fraction_numerical': 0.003669112741827885, 'mean_word_length': 3.0417789757412397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1793211', 'n_tokens_mistral': 790, 'n_tokens_neox': 777, 'n_words': 164}