<commit_before>///
///  MetaLogEntry.swift
///
///  Copyright 2015 <NAME>
///
///  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.
///
///  Created by <NAME> on 12/10/15.
///
import Foundation
import CoreData

internal typealias TransactionID = String

@objc
internal enum MetaLogEntryType: Int32 {
    case beginMarker = 1
    case endMarker   = 2
    case insert      = 3
    case update      = 4
    case delete      = 5
}

@objc(MetaLogEntry)
internal class MetaLogEntry: NSManagedObject {

    typealias ValueContainerType = [AnyHashable: Any]

    internal class ChangeData : NSObject, NSCoding  {
        required convenience init?(coder aDecoder: NSCoder) {
            self.init()
        }
        func encode(with aCoder: NSCoder) {
        }
    }
    /**
        NOTE: the attributes in this class are all public because
        it is considered a structure.  We had to make this a class
        to suite the CoreData requirements.
    */
    internal class InsertData : ChangeData {
        var attributesAndValues: ValueContainerType?

        required convenience init?(coder aDecoder: NSCoder) {
            self.init()
            
            attributesAndValues = aDecoder.decodeObject() as? ValueContainerType
        }
        override func encode(with aCoder: NSCoder) {
            aCoder.encode(attributesAndValues)
        }

    }

    internal class UpdateData : ChangeData  {
        var attributesAndValues: ValueContainerType?
        var updatedAttributes:   [String]?

        required convenience init?(coder aDecoder: NSCoder) {
            self.init()
            
            attributesAndValues = aDecoder.decodeObject() as? ValueContainerType
            updatedAttributes   = aDecoder.decodeObject() as? [String]
        }
        
        override func encode(with aCoder: NSCoder) {
            aCoder.encode(attributesAndValues)
            aCoder.encode(updatedAttributes)
        }

    }

    internal class DeleteData : ChangeData   {
        required convenience init?(coder aDecoder: NSCoder) {
            self.init()
        }
        override func encode(with aCoder: NSCoder) {}
    }
}<commit_msg>Adding a default constructor and changing the NSCoding methods to the super class.<commit_after>///
///  MetaLogEntry.swift
///
///  Copyright 2015 <NAME>
///
///  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.
///
///  Created by <NAME> on 12/10/15.
///
import Foundation
import CoreData

internal typealias TransactionID = String

@objc
internal enum MetaLogEntryType: Int32 {
    case beginMarker = 1
    case endMarker   = 2
    case insert      = 3
    case update      = 4
    case delete      = 5
}

@objc(MetaLogEntry)
internal class MetaLogEntry: NSManagedObject {

    typealias ValueContainerType = [AnyHashable: Any]

    internal class ChangeData : NSObject, NSCoding  {
        required override init() {}
        required init?(coder aDecoder: NSCoder) {}
        func encode(with aCoder: NSCoder) {}
    }
    /**
        NOTE: the attributes in this class are all public because
        it is considered a structure.  We had to make this a class
        to suite the CoreData requirements.
    */
    internal class InsertData : ChangeData {
        var attributesAndValues: ValueContainerType?

        required override init() {
            super.init()
        }

        required init?(coder aDecoder: NSCoder) {
            super.init(coder: aDecoder)
            
            attributesAndValues = aDecoder.decodeObject() as? ValueContainerType
        }
        override func encode(with aCoder: NSCoder) {
            aCoder.encode(attributesAndValues)
            super.encode(with: aCoder)
        }
    }

    internal class UpdateData : ChangeData  {
        var attributesAndValues: ValueContainerType?
        var updatedAttributes:   [String]?

        required override init() {
            super.init()
        }

        required init?(coder aDecoder: NSCoder) {
            super.init(coder: aDecoder)
            
            attributesAndValues = aDecoder.decodeObject() as? ValueContainerType
            updatedAttributes   = aDecoder.decodeObject() as? [String]
        }
        
        override func encode(with aCoder: NSCoder) {
            aCoder.encode(attributesAndValues)
            aCoder.encode(updatedAttributes)
            super.encode(with: aCoder)
        }
    }

    internal class DeleteData : ChangeData   {

        required override init() {
            super.init()
        }

        required  init?(coder aDecoder: NSCoder) {
            super.init(coder: aDecoder)
        }
        override func encode(with aCoder: NSCoder) {
            super.encode(with: aCoder)
        }
    }
}
{'fraction_non_alphanumeric': 0.0843205574912892, 'fraction_numerical': 0.007317073170731708, 'mean_word_length': 2.2018962632459567, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5447958', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1510, 'n_words': 503}