<commit_before>package se.olz.myfootprints;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;

import static java.lang.String.valueOf;

public class DBHelper extends SQLiteOpenHelper {
    // If you change the database schema, you must increment the database version.
    private static final int DATABASE_VERSION = 8;
    private static final String DATABASE_NAME = "Coordinates.db";
    private static final String TABLE_NAME = "positions";
    private static final String COLUMN_NAME_ID = "id";
    private static final String COLUMN_NAME_SESSION = "session";
    private static final String COLUMN_NAME_TIMESTAMP = "accessedTimestamp";
    private static final String COLUMN_NAME_LATITUDE = "latitude";
    private static final String COLUMN_NAME_LONGITUDE= "longitude";
    private static final String DOUBLE_TYPE = " DOUBLE";
    private static final String INT_TYPE = " INT";
    private static final String LONG_TYPE = " LONG";
    private static final String COMMA_SEP = ",";
    private static final String SQL_CREATE_ENTRIES =
            "CREATE TABLE " + TABLE_NAME + " (" +
                    COLUMN_NAME_ID + " INTEGER PRIMARY KEY," +
                    COLUMN_NAME_SESSION + LONG_TYPE + COMMA_SEP +
                    COLUMN_NAME_TIMESTAMP + LONG_TYPE + COMMA_SEP +
                    COLUMN_NAME_LATITUDE + DOUBLE_TYPE + COMMA_SEP +
                    COLUMN_NAME_LONGITUDE + DOUBLE_TYPE +" )";
    public static final String TAG = DBHelper.class.getSimpleName();

    public DBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_ENTRIES);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
    }

    public void clean() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_NAME, null, null);
    }

    /*private static double roundDown4(double d) {
        return (long) (d * 1e4) / 1e4;
    }*/

    /*private int findOccurance(double latitude, double longitude) {
        SQLiteDatabase db = this.getReadableDatabase();
        String[] args = {
                valueOf(latitude),
                valueOf(longitude)
        };
        Cursor res = db.query(TABLE_NAME, new String[] {COLUMN_NAME_ID}, COLUMN_NAME_LATITUDE+" = ? AND "+COLUMN_NAME_LONGITUDE+" = ?", args, null, null, null);
        int id = -1;
        if (res.getCount() > 0) {
            res.moveToLast();
            id = res.getInt(res.getColumnIndex(COLUMN_NAME_ID));
            res.close();
        }
        return id;
    }*/

    public boolean insertCoordinates(long session, long accessedTimestamp, double latitude, double longitude)
    {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues contentValues = new ContentValues();
        contentValues.put(COLUMN_NAME_SESSION, session);
        contentValues.put(COLUMN_NAME_TIMESTAMP, accessedTimestamp);
        contentValues.put(COLUMN_NAME_LATITUDE, latitude);
        contentValues.put(COLUMN_NAME_LONGITUDE, longitude);
        db.insert(TABLE_NAME, null, contentValues);

        return true;
    }

    public int numberOfRows(){
        SQLiteDatabase db = this.getReadableDatabase();
        return (int) DatabaseUtils.queryNumEntries(db, TABLE_NAME);
    }

    public ArrayList<RawPositions> getAllEntries() {
        ArrayList<RawPositions> CoordinateEntries = new ArrayList<>();
        SQLiteDatabase db = this.getReadableDatabase();<commit_msg>changed database schema<commit_after>package se.olz.myfootprints;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;

import static java.lang.String.valueOf;

public class DBHelper extends SQLiteOpenHelper {
    // If you change the database schema, you must increment the database version.
    private static final int DATABASE_VERSION = 12;
    private static final String DATABASE_NAME = "myfootprints.db";
    private static final String TABLE_NAME = "positions";
    private static final String COLUMN_NAME_ID = "id";
    private static final String COLUMN_NAME_SESSION = "session";
    private static final String COLUMN_NAME_TIMESTAMP = "accessedTimestamp";
    private static final String COLUMN_NAME_LATITUDE = "latitude";
    private static final String COLUMN_NAME_LONGITUDE= "longitude";
    private static final String DOUBLE_TYPE = " DOUBLE";
    private static final String INT_TYPE = " INTEGER";
    private static final String COMMA_SEP = ",";
    private static final String SQL_CREATE_ENTRIES =
            "CREATE TABLE " + TABLE_NAME + " (" +
                    COLUMN_NAME_ID + INT_TYPE + " PRIMARY KEY, " +
                    COLUMN_NAME_SESSION + INT_TYPE + COMMA_SEP +
                    COLUMN_NAME_TIMESTAMP + INT_TYPE + COMMA_SEP +
                    COLUMN_NAME_LATITUDE + DOUBLE_TYPE + COMMA_SEP +
                    COLUMN_NAME_LONGITUDE + DOUBLE_TYPE +" )";
    public static final String TAG = DBHelper.class.getSimpleName();

    public DBHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_ENTRIES);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
    }

    public void clean() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_NAME, null, null);
    }

    public boolean insertCoordinates(long session, long accessedTimestamp, double latitude, double longitude)
    {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues contentValues = new ContentValues();
        contentValues.put(COLUMN_NAME_SESSION, session);
        contentValues.put(COLUMN_NAME_TIMESTAMP, accessedTimestamp);
        contentValues.put(COLUMN_NAME_LATITUDE, latitude);
        contentValues.put(COLUMN_NAME_LONGITUDE, longitude);
        db.insert(TABLE_NAME, null, contentValues);

        return true;
    }

    public int numberOfRows(){
        SQLiteDatabase db = this.getReadableDatabase();
        return (int) DatabaseUtils.queryNumEntries(db, TABLE_NAME);
    }

    public ArrayList<RawPositions> getAllEntries() {

        final ArrayList<RawPositions> CoordinateEntries = new ArrayList<>();
        final SQLiteDatabase db = this.getReadableDatabase();

{'fraction_non_alphanumeric': 0.08445655291081158, 'fraction_numerical': 0.0014338973329509608, 'mean_word_length': 3.181654676258993, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '5628400', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1970, 'n_words': 491}