<commit_before>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
using Orleans;
using Orleans.Runtime;
using Orleans.SqlUtils;

namespace OrleansSQLUtils.Storage
{
    /// <summary>
    /// This class implements the expected contract between Orleans and the underlying relational storage.
    /// It makes sure all the stored queries are present and 
    /// </summary>
    internal class DbStoredQueries
    {
        private readonly Dictionary<string, string> queries;
        internal DbStoredQueries(Dictionary<string, string> queries)
        {
            var fields = typeof (DbStoredQueries).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
                .Select(p => p.Name);
            var missingQueryKeys = queries.Keys.Except(fields).ToArray();
            if (missingQueryKeys.Length > 0)
            {
                throw new ArgumentException(
                    $"Not all required queries found. Missing are: {string.Join(",", missingQueryKeys)}");
            }
            this.queries = queries;
        }

        /// <summary>
        /// The query that's used to get all the stored queries.
        /// this will probably be the same for all relational dbs.
        /// </summary>
        internal const string GetQueriesKey = "SELECT QueryKey, QueryText FROM OrleansQuery;";

        /// <summary>
        /// A query template to retrieve gateway URIs.
        /// </summary>        
        internal string GatewaysQueryKey => queries[nameof(GatewaysQueryKey)];

        /// <summary>
        /// A query template to retrieve a single row of membership data.
        /// </summary>        
        internal string MembershipReadRowKey => queries[nameof(MembershipReadRowKey)];

        /// <summary>
        /// A query template to retrieve all membership data.<commit_msg>allow for extraneous keys in OrleanQuery table<commit_after>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Reflection;
using Orleans;
using Orleans.Runtime;
using Orleans.SqlUtils;

namespace OrleansSQLUtils.Storage
{
    /// <summary>
    /// This class implements the expected contract between Orleans and the underlying relational storage.
    /// It makes sure all the stored queries are present and 
    /// </summary>
    internal class DbStoredQueries
    {
        private readonly Dictionary<string, string> queries;
        internal DbStoredQueries(Dictionary<string, string> queries)
        {
            var fields = typeof (DbStoredQueries).GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
                .Select(p => p.Name);
            var missingQueryKeys = fields.Except(queries.Keys).ToArray();
            if (missingQueryKeys.Length > 0)
            {
                throw new ArgumentException(
                    $"Not all required queries found. Missing are: {string.Join(",", missingQueryKeys)}");
            }
            this.queries = queries;
        }

        /// <summary>
        /// The query that's used to get all the stored queries.
        /// this will probably be the same for all relational dbs.
        /// </summary>
        internal const string GetQueriesKey = "SELECT QueryKey, QueryText FROM OrleansQuery;";

        /// <summary>
        /// A query template to retrieve gateway URIs.
        /// </summary>        
        internal string GatewaysQueryKey => queries[nameof(GatewaysQueryKey)];

        /// <summary>
        /// A query template to retrieve a single row of membership data.
        /// </summary>        
        internal string MembershipReadRowKey => queries[nameof(MembershipReadRowKey)];

        /// <summary>
        /// A query template to retrieve all membership data.
{'fraction_non_alphanumeric': 0.09558631496474275, 'fraction_numerical': 0.0005223295899712719, 'mean_word_length': 2.254035683942226, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 33, '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': '5208745', 'n_tokens_mistral': 950, 'n_tokens_neox': 912, 'n_words': 313}