<commit_before>/*
 *  Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
package org.wso2.carbon.analytics.datasource.commons;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This class represents a schema for the analytics tables.
 */
public class AnalyticsSchema implements Serializable {
    
    private static final long serialVersionUID = -4696693702436657326L;

    private Map<String, ColumnDefinition> columns;
    
    /** primary keys are set separately rather than having in {@link ColumnDefinition} 
     * to optimize the lookup of just the primary keys when required */
    private List<String> primaryKeys;
    
    public AnalyticsSchema() { }
    
    public AnalyticsSchema(List<ColumnDefinition> columns, List<String> primaryKeys) {
        this.columns = new LinkedHashMap<>(columns.size());
        for (ColumnDefinition column : columns) {
            this.columns.put(column.getName(), column);
        }
        this.primaryKeys = primaryKeys;
    }
    
    public Map<String, ColumnDefinition> getColumns() {
        return columns;
    }
    
    public List<String> getPrimaryKeys() {
        return primaryKeys;
    }

    public static enum ColumnType {
        STRING,
        INTEGER,
        LONG,
        FLOAT,
        DOUBLE,
        BOOLEAN,
        BINARY,
        FACET
    }
    
    @Override
    public int hashCode() {
        int hash1 = 0, hash2 = 0;
        if (this.columns != null) {
            hash1 = this.columns.hashCode();
        }
        if (this.primaryKeys != null) {
            hash2 = this.primaryKeys.hashCode();
        }
        return hash1 * hash2;
    }
    
    @Override
    public boolean equals(Object rhs) {
        if (!(rhs instanceof AnalyticsSchema)) {
            return false;
        }
        AnalyticsSchema other = (AnalyticsSchema) rhs;
        if (this.getColumns() != null && !this.getColumns().equals(other.getColumns())) {
            return false;
        }
        if (this.getPrimaryKeys() != null && !this.getPrimaryKeys().equals(other.getPrimaryKeys())) {
            return false;
        }
        return true;
    }
}
<commit_msg>AnalyticsSchema constructor parameter check<commit_after>/*
 *  Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */
package org.wso2.carbon.analytics.datasource.commons;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * This class represents a schema for the analytics tables.
 */
public class AnalyticsSchema implements Serializable {
    
    private static final long serialVersionUID = -4696693702436657326L;

    private Map<String, ColumnDefinition> columns;
    
    /** primary keys are set separately rather than having in {@link ColumnDefinition} 
     * to optimize the lookup of just the primary keys when required */
    private List<String> primaryKeys;
    
    public AnalyticsSchema() { }
    
    public AnalyticsSchema(List<ColumnDefinition> columns, List<String> primaryKeys) {
        if (columns != null) {
            this.columns = new LinkedHashMap<>(columns.size());
            for (ColumnDefinition column : columns) {
                this.columns.put(column.getName(), column);
            }
        }
        this.primaryKeys = primaryKeys;
    }
    
    public Map<String, ColumnDefinition> getColumns() {
        return columns;
    }
    
    public List<String> getPrimaryKeys() {
        return primaryKeys;
    }

    public static enum ColumnType {
        STRING,
        INTEGER,
        LONG,
        FLOAT,
        DOUBLE,
        BOOLEAN,
        BINARY,
        FACET
    }
    
    @Override
    public int hashCode() {
        int hash1 = 0, hash2 = 0;
        if (this.columns != null) {
            hash1 = this.columns.hashCode();
        }
        if (this.primaryKeys != null) {
            hash2 = this.primaryKeys.hashCode();
        }
        return hash1 * hash2;
    }
    
    @Override
    public boolean equals(Object rhs) {
        if (!(rhs instanceof AnalyticsSchema)) {
            return false;
        }
        AnalyticsSchema other = (AnalyticsSchema) rhs;
        if (this.getColumns() != null && !this.getColumns().equals(other.getColumns())) {
            return false;
        }
        if (this.getPrimaryKeys() != null && !this.getPrimaryKeys().equals(other.getPrimaryKeys())) {
            return false;
        }
        return true;
    }
}

{'fraction_non_alphanumeric': 0.09492235212004886, 'fraction_numerical': 0.013610190193683477, 'mean_word_length': 2.38370720188902, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5666317', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1553, 'n_words': 496}