<commit_before>////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed 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.
//
////////////////////////////////////////////////////////////////////////////

import Realm

/**
This class represents the collection of model object schemas persisted to Realm.

When using Realm, `Schema` objects allow performing migrations and
introspecting the database's schema.

Schemas map to collections of tables in the core database.
*/
public final class Schema: Equatable {

    // MARK: Properties

    internal var rlmSchema: RLMSchema

    /// `ObjectSchema`s for all object types in this Realm. Meant
    /// to be used during migrations for dynamic introspection.
    public var objectSchema: [ObjectSchema] {
        return (rlmSchema.objectSchema as [RLMObjectSchema]).map { ObjectSchema($0) }
    }

    // MARK: Initializers

    internal init(_ rlmSchema: RLMSchema) {
        self.rlmSchema = rlmSchema
    }

    // MARK: ObjectSchema Retrieval

    /// Returns the object schema with the given class name, if it exists.
    public subscript(className: String) -> ObjectSchema? {
        if let rlmObjectSchema = rlmSchema.schemaForClassName(className) {
            return ObjectSchema(rlmObjectSchema)
        }
        return nil
    }
}

// MARK: Equatable

/// Returns whether the two schemas are equal.
public func ==(lhs: Schema, rhs: Schema) -> Bool {
    return lhs.rlmSchema.isEqualToSchema(rhs.rlmSchema)
}<commit_msg>[Schema] Declare Equatable conformance in an extension<commit_after>////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed 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.
//
////////////////////////////////////////////////////////////////////////////

import Realm

/**
This class represents the collection of model object schemas persisted to Realm.

When using Realm, `Schema` objects allow performing migrations and
introspecting the database's schema.

Schemas map to collections of tables in the core database.
*/
public final class Schema {

    // MARK: Properties

    internal var rlmSchema: RLMSchema

    /// `ObjectSchema`s for all object types in this Realm. Meant
    /// to be used during migrations for dynamic introspection.
    public var objectSchema: [ObjectSchema] {
        return (rlmSchema.objectSchema as [RLMObjectSchema]).map { ObjectSchema($0) }
    }

    // MARK: Initializers

    internal init(_ rlmSchema: RLMSchema) {
        self.rlmSchema = rlmSchema
    }

    // MARK: ObjectSchema Retrieval

    /// Returns the object schema with the given class name, if it exists.
    public subscript(className: String) -> ObjectSchema? {
        if let rlmObjectSchema = rlmSchema.schemaForClassName(className) {
            return ObjectSchema(rlmObjectSchema)
        }
        return nil
    }
}

// MARK: Equatable

extension Schema: Equatable {}

/// Returns whether the two schemas are equal.
public func ==(lhs: Schema, rhs: Schema) -> Bool {
    return lhs.rlmSchema.isEqualToSchema(rhs.rlmSchema)
}
{'fraction_non_alphanumeric': 0.15220552593310713, 'fraction_numerical': 0.004362578768783325, 'mean_word_length': 2.3689795918367347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4856328', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1014, 'n_words': 428}