<commit_before>﻿/*
   Copyright 2014-2019 Zumero, LLC

   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.
*/

// Copyright © Microsoft Open Technologies, Inc.
// All Rights Reserved
// 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
// 
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
// 
// See the Apache 2 License for the specific language governing permissions and limitations under the License.

namespace SQLitePCL
{
    using System;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Collections.Generic;

    internal static class hooks
    {
	    internal class info
	    {
		    // TODO note that sqlite function names can be case-insensitive.  but we're using
		    // a dictionary with a string key to keep track of them.  this has the potential
		    // to cause problems.  fixing it with a case-insensitive string comparer is not
		    // correct here, since the .NET notion of case-insensitivity is different (more
		    // complete) than SQLite's notion.

			public Dictionary<string, collation_hook_handle> collation = new Dictionary<string, collation_hook_handle>();
			public Dictionary<string, scalar_function_hook_handle> scalar = new Dictionary<string, scalar_function_hook_handle>();
			public Dictionary<string, agg_function_hook_handle> agg = new Dictionary<string, agg_function_hook_handle>();
			public update_hook_handle update;
			public rollback_hook_handle rollback;
			public commit_hook_handle commit;
			public trace_hook_handle trace;
			public progress_handler_hook_handle progress;
			public profile_hook_handle profile;
            public authorizer_hook_handle authorizer;

		    public void Dispose()
		    {
			foreach (var h in collation.Values) h.Dispose();
			foreach (var h in scalar.Values) h.Dispose();
			foreach (var h in agg.Values) h.Dispose();
			if (update!=null) update.Dispose();
			if (rollback!=null) rollback.Dispose();
			if (commit!=null) commit.Dispose();
			if (trace!=null) trace.Dispose();
			if (progress!=null) progress.Dispose();
			if (profile!=null) profile.Dispose();
			if (authorizer!=null) authorizer.Dispose();
		    }
	    }

        internal static log_hook_handle log;

        private static System.Collections.Concurrent.ConcurrentDictionary<IntPtr,info> _hooks_by_db = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr,info>();

	internal static info getOrCreateFor(IntPtr db)
	{<commit_msg>in hooks.info, instead of keeping the actual type of every hook, just keep them as IDisposable, since Dispose is all we need.<commit_after>﻿/*
   Copyright 2014-2019 Zumero, LLC

   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.
*/

// Copyright © Microsoft Open Technologies, Inc.
// All Rights Reserved
// 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
// 
// THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
// 
// See the Apache 2 License for the specific language governing permissions and limitations under the License.

namespace SQLitePCL
{
    using System;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Collections.Generic;

    internal static class hooks
    {
	    internal class info
	    {
		    // TODO note that sqlite function names can be case-insensitive.  but we're using
		    // a dictionary with a string key to keep track of them.  this has the potential
		    // to cause problems.  fixing it with a case-insensitive string comparer is not
		    // correct here, since the .NET notion of case-insensitivity is different (more
		    // complete) than SQLite's notion.

			public Dictionary<string, IDisposable> collation = new Dictionary<string, IDisposable>();
			public Dictionary<string, IDisposable> scalar = new Dictionary<string, IDisposable>();
			public Dictionary<string, IDisposable> agg = new Dictionary<string, IDisposable>();
			public IDisposable update;
			public IDisposable rollback;
			public IDisposable commit;
			public IDisposable trace;
			public IDisposable progress;
			public IDisposable profile;
            public IDisposable authorizer;

		    public void Dispose()
		    {
			foreach (var h in collation.Values) h.Dispose();
			foreach (var h in scalar.Values) h.Dispose();
			foreach (var h in agg.Values) h.Dispose();
			if (update!=null) update.Dispose();
			if (rollback!=null) rollback.Dispose();
			if (commit!=null) commit.Dispose();
			if (trace!=null) trace.Dispose();
			if (progress!=null) progress.Dispose();
			if (profile!=null) profile.Dispose();
			if (authorizer!=null) authorizer.Dispose();
		    }
	    }

		// TODO why is this static?
        internal static IDisposable log;

        private static System.Collections.Concurrent.ConcurrentDictionary<IntPtr,info> _hooks_by_db = new System.Collections.Concurrent.ConcurrentDictionary<IntPtr,info>();

	internal static info getOrCreateFor(IntPtr db)
	{
{'fraction_non_alphanumeric': 0.07824109173616375, 'fraction_numerical': 0.005155420773313116, 'mean_word_length': 3.7114285714285713, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4711580', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1716, 'n_words': 720}