<commit_before>package org.kaaproject.data_migration;


import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.kaaproject.data_migration.utils.Options;

import java.sql.Connection;

import static com.mongodb.client.model.Filters.eq;

public class EndpointProfileMigration {
    private String host;
    private String dbName;
    private String nosql;


    public EndpointProfileMigration(String host, String db, String nosql) {
        dbName = db;
        this.host = host;
        this.nosql = nosql;
    }

    /**
     * Add field use_raw_configuration_schema to endpointProfile that used to support devices using SDK version 0.9.0
     * */
    public void transform() {
        Cluster cluster = Cluster.builder().addContactPoint(host).build();
        MongoClient client = new MongoClient(host);

        //mongo
        MongoDatabase database = client.getDatabase(dbName);
        MongoCollection<Document> endpointProfile = database.getCollection("endpoint_profile");
        endpointProfile.updateMany(new Document(), eq("$set", eq("use_raw_schema", false)));

        //cassandra
//        Session session = cluster.connect(dbName);
//        session.execute("");
//        session.close();
//        cluster.close();

    }
}<commit_msg>Add field use raw configuration schema toep_profile in Cassandra<commit_after>package org.kaaproject.data_migration;


import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.kaaproject.data_migration.utils.Options;

import java.sql.Connection;

import static com.mongodb.client.model.Filters.eq;

public class EndpointProfileMigration {
    private String host;
    private String dbName;
    private String nosql;


    public EndpointProfileMigration(String host, String db, String nosql) {
        dbName = db;
        this.host = host;
        this.nosql = nosql;
    }

    /**
     * Add field use_raw_configuration_schema to endpointProfile that used to support devices using SDK version 0.9.0
     * */
    public void transform() {
        //mongo
        MongoClient client = new MongoClient(host);
        MongoDatabase database = client.getDatabase(dbName);
        MongoCollection<Document> endpointProfile = database.getCollection("endpoint_profile");
        endpointProfile.updateMany(new Document(), eq("$set", eq("use_raw_schema", false)));

        //cassandra
        Cluster cluster = Cluster.builder().addContactPoint(host).build();
        Session session = cluster.connect(dbName);
        session.execute("ALTER TABLE ep_profile ADD use_raw_schema boolean");
        session.close();
        cluster.close();

    }
}
{'fraction_non_alphanumeric': 0.1015916017609211, 'fraction_numerical': 0.002031832035218422, 'mean_word_length': 3.442105263157895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3962954', 'n_tokens_mistral': 852, 'n_tokens_neox': 826, 'n_words': 191}