<commit_before>﻿using System;
using System.IO;
using System.Linq;

namespace DocumentTable
{
    public class ReadSessionFactory : IReadSessionFactory, IDisposable
    {
        private readonly string _directory;
        private readonly FileStream _compoundFile;

        public ReadSessionFactory(string directory)
        {
            _directory = directory;

            var version = Directory.GetFiles(directory, "*.ix")
                .Select(f => long.Parse(Path.GetFileNameWithoutExtension(f)))
                .OrderBy(v => v).First();

            var compoundFileName = Path.Combine(_directory, version + ".rdb");

            _compoundFile = new FileStream(
                compoundFileName,
                FileMode.Open,
                FileAccess.Read,
                FileShare.ReadWrite,
                4096 * 1,
                FileOptions.RandomAccess);
        }

        public IReadSession OpenReadSession(long version)
        {
            var ix = BatchInfo.Load(Path.Combine(_directory, version + ".ix"));
           
            return new ReadSession(
                ix,
                new PostingsReader(_compoundFile, ix.PostingsOffset),
                new DocHashReader(_compoundFile, ix.DocHashOffset),
                new DocumentAddressReader(_compoundFile, ix.DocAddressesOffset),
                _compoundFile);
        }

        public void Dispose()
        {
            _compoundFile.Dispose();
        }
    }
}<commit_msg>don't set buffer size or caching options<commit_after>﻿using System;
using System.IO;
using System.Linq;

namespace DocumentTable
{
    public class ReadSessionFactory : IReadSessionFactory, IDisposable
    {
        private readonly string _directory;
        private readonly FileStream _compoundFile;

        public ReadSessionFactory(string directory)
        {
            _directory = directory;

            var version = Directory.GetFiles(directory, "*.ix")
                .Select(f => long.Parse(Path.GetFileNameWithoutExtension(f)))
                .OrderBy(v => v).First();

            var compoundFileName = Path.Combine(_directory, version + ".rdb");

            _compoundFile = new FileStream(
                compoundFileName,
                FileMode.Open,
                FileAccess.Read,
                FileShare.ReadWrite);
        }

        public IReadSession OpenReadSession(long version)
        {
            var ix = BatchInfo.Load(Path.Combine(_directory, version + ".ix"));
           
            return new ReadSession(
                ix,
                new PostingsReader(_compoundFile, ix.PostingsOffset),
                new DocHashReader(_compoundFile, ix.DocHashOffset),
                new DocumentAddressReader(_compoundFile, ix.DocAddressesOffset),
                _compoundFile);
        }

        public void Dispose()
        {
            _compoundFile.Dispose();
        }
    }
}
{'fraction_non_alphanumeric': 0.08158347676419965, 'fraction_numerical': 0.0017211703958691911, 'mean_word_length': 1.8268482490272373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '918163', 'n_tokens_mistral': 755, 'n_tokens_neox': 703, 'n_words': 155}