<commit_before>﻿using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Net;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace MaxMind.Db
{
    /// <summary>
    /// An enumeration specifying the API to use to read the database
    /// </summary>
    public enum FileAccessMode
    {
        /// <summary>
        /// Open the file in memory mapped mode. Does not load into real memory.
        /// </summary>
        MemoryMapped,
        /// <summary>
        /// Load the file into memory.
        /// </summary>
        Memory
    }

    /// <summary>
    /// Given a MaxMind DB file, this class will retrieve information about an IP address
    /// </summary>
    public class Reader : IDisposable
    {
        /// <summary>
        /// Gets the metadata.
        /// </summary>
        /// <value>
        /// The metadata.
        /// </value>
        internal Metadata Metadata { get; private set; }

        private const int DataSectionSeparatorSize = 16;

        private readonly byte[] _metadataStartMarker = { 0xAB, 0xCD, 0xEF, 77, 97, 120, 77, 105, 110, 100, 46, 99, 111, 109 };

        private readonly string _fileName;

        private int _fileSize;

        private readonly MemoryMappedFile _memoryMappedFile;

        private int _ipV4Start;
        private int IPV4Start
        {
            get
            {
                if (_ipV4Start == 0 || Metadata.IpVersion == 4)
                {
                    int node = 0;
                    for (int i = 0; i < 96 && node < Metadata.NodeCount; i++)
                    {
                        node = ReadNode(node, 0);
                    }
                    _ipV4Start = node;
                }
                return _ipV4Start;
            }
        }

        private static Object _mmapLocker = new Object();

        private readonly ThreadLocal<Stream> _stream;

        private Decoder Decoder { get; set; }


        /// <summary><commit_msg>Made _mmapLocker readonly<commit_after>﻿using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Net;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace MaxMind.Db
{
    /// <summary>
    /// An enumeration specifying the API to use to read the database
    /// </summary>
    public enum FileAccessMode
    {
        /// <summary>
        /// Open the file in memory mapped mode. Does not load into real memory.
        /// </summary>
        MemoryMapped,
        /// <summary>
        /// Load the file into memory.
        /// </summary>
        Memory
    }

    /// <summary>
    /// Given a MaxMind DB file, this class will retrieve information about an IP address
    /// </summary>
    public class Reader : IDisposable
    {
        /// <summary>
        /// Gets the metadata.
        /// </summary>
        /// <value>
        /// The metadata.
        /// </value>
        internal Metadata Metadata { get; private set; }

        private const int DataSectionSeparatorSize = 16;

        private readonly byte[] _metadataStartMarker = { 0xAB, 0xCD, 0xEF, 77, 97, 120, 77, 105, 110, 100, 46, 99, 111, 109 };

        private readonly string _fileName;

        private int _fileSize;

        private readonly MemoryMappedFile _memoryMappedFile;

        private int _ipV4Start;
        private int IPV4Start
        {
            get
            {
                if (_ipV4Start == 0 || Metadata.IpVersion == 4)
                {
                    int node = 0;
                    for (int i = 0; i < 96 && node < Metadata.NodeCount; i++)
                    {
                        node = ReadNode(node, 0);
                    }
                    _ipV4Start = node;
                }
                return _ipV4Start;
            }
        }

        private static readonly Object _mmapLocker = new Object();

        private readonly ThreadLocal<Stream> _stream;

        private Decoder Decoder { get; set; }


        /// <summary>
{'fraction_non_alphanumeric': 0.09977772289454186, 'fraction_numerical': 0.02222771054581378, 'mean_word_length': 1.4969173859432798, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 31, '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': '3351901', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1060, 'n_words': 350}