<commit_before>package com.github.gfx.android.orma;

import com.github.gfx.android.orma.adapter.TypeAdapter;
import com.github.gfx.android.orma.adapter.TypeAdapterRegistry;
import com.github.gfx.android.orma.exception.TransactionAbortException;
import com.github.gfx.android.orma.migration.MigrationEngine;
import com.github.gfx.android.orma.migration.NamedDdl;
import com.github.gfx.android.orma.migration.SchemaDiffMigration;

import android.annotation.TargetApi;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.database.sqlite.SQLiteStatement;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class OrmaConnection extends SQLiteOpenHelper {

    static final String TAG = OrmaConnection.class.getSimpleName();

    static final String[] countSelections = {"COUNT(*)"};

    final List<Schema<?>> schemas;

    final MigrationEngine migration;

    final boolean trace;

    final TypeAdapterRegistry typeAdapters = new TypeAdapterRegistry();

    public OrmaConnection(@NonNull Context context, @Nullable String filename, List<Schema<?>> schemas) {
        this(context, filename, schemas, new SchemaDiffMigration(context));
    }

    public OrmaConnection(@NonNull Context context, @Nullable String filename, List<Schema<?>> schemas,
            @NonNull MigrationEngine migration) {
        super(context, filename, null, migration.getVersion());
        this.schemas = schemas;
        this.migration = migration;
        this.trace = extractDebug(context);
        enableWal();
    }

    static boolean extractDebug(Context context) {
        return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE;
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    private void enableWal() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setWriteAheadLoggingEnabled(true);
        }
    }

    public SQLiteDatabase getDatabase() {
        return getWritableDatabase();
    }

    public TypeAdapterRegistry getTypeAdapters() {
        return typeAdapters;
    }

    public void addTypeAdapters(TypeAdapter<?> ...adapters) {<commit_msg>pass application context to SQLiteOpenHelper's constructor<commit_after>package com.github.gfx.android.orma;

import com.github.gfx.android.orma.adapter.TypeAdapter;
import com.github.gfx.android.orma.adapter.TypeAdapterRegistry;
import com.github.gfx.android.orma.exception.TransactionAbortException;
import com.github.gfx.android.orma.migration.MigrationEngine;
import com.github.gfx.android.orma.migration.NamedDdl;
import com.github.gfx.android.orma.migration.SchemaDiffMigration;

import android.annotation.TargetApi;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.database.sqlite.SQLiteStatement;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import java.util.ArrayList;
import java.util.List;

public class OrmaConnection extends SQLiteOpenHelper {

    static final String TAG = OrmaConnection.class.getSimpleName();

    static final String[] countSelections = {"COUNT(*)"};

    final List<Schema<?>> schemas;

    final MigrationEngine migration;

    final boolean trace;

    final TypeAdapterRegistry typeAdapters = new TypeAdapterRegistry();

    public OrmaConnection(@NonNull Context context, @Nullable String filename, List<Schema<?>> schemas) {
        this(context, filename, schemas, new SchemaDiffMigration(context));
    }

    public OrmaConnection(@NonNull Context context, @Nullable String filename, List<Schema<?>> schemas,
            @NonNull MigrationEngine migration) {
        super(context.getApplicationContext(), filename, null, migration.getVersion());
        this.schemas = schemas;
        this.migration = migration;
        this.trace = extractDebug(context);
        enableWal();
    }

    static boolean extractDebug(Context context) {
        return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE;
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    private void enableWal() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setWriteAheadLoggingEnabled(true);
        }
    }

    public SQLiteDatabase getDatabase() {
        return getWritableDatabase();
    }

    public TypeAdapterRegistry getTypeAdapters() {
        return typeAdapters;
    }

    public void addTypeAdapters(TypeAdapter<?> ...adapters) {
{'fraction_non_alphanumeric': 0.09788308409399883, 'fraction_numerical': 0.0, 'mean_word_length': 4.449735449735449, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '2497988', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1413, 'n_words': 285}