<commit_before>﻿Imports System.IO
Imports Microsoft.VisualBasic.Data.IO
Imports Microsoft.VisualBasic.Text

Namespace mzData.mzWebCache

    Public Class BinaryStreamReader : Implements IMagicBlock
        Implements IDisposable

        Dim disposedValue As Boolean
        Dim file As BinaryDataReader
        Dim index As New Dictionary(Of String, Long)

        Public ReadOnly Property rtmin As Double
        Public ReadOnly Property rtmax As Double
        Public ReadOnly Property mzmin As Double
        Public ReadOnly Property mzmax As Double

        Public ReadOnly Property magic As String Implements IMagicBlock.magic
            Get
                Return BinaryStreamWriter.Magic
            End Get
        End Property

        Public ReadOnly Property EnumerateIndex As IEnumerable(Of String)
            Get
                Return index.Keys
            End Get
        End Property

        Sub New(file As String)
            Me.file = New BinaryDataReader(
                input:=file.Open(IO.FileMode.OpenOrCreate, doClear:=False, [readOnly]:=True),
                encoding:=Encodings.ASCII
            )
            Me.file.ByteOrder = ByteOrder.LittleEndian

            If Not Me.VerifyMagicSignature(Me.file) Then
                Throw New InvalidProgramException("invalid magic header!")
            Else
                Call loadIndex()
            End If
        End Sub

        Private Sub loadIndex()<commit_msg>Update BinaryStreamReader.vb<commit_after>﻿Imports System.IO
Imports Microsoft.VisualBasic.Data.IO
Imports Microsoft.VisualBasic.Text

Namespace mzData.mzWebCache

    Public Class BinaryStreamReader : Implements IMagicBlock
        Implements IDisposable

        Dim disposedValue As Boolean
        Dim file As BinaryDataReader
        Dim index As New Dictionary(Of String, Long)

        Public ReadOnly Property rtmin As Double
        Public ReadOnly Property rtmax As Double
        Public ReadOnly Property mzmin As Double
        Public ReadOnly Property mzmax As Double

        Public ReadOnly Property magic As String Implements IMagicBlock.magic
            Get
                Return BinaryStreamWriter.Magic
            End Get
        End Property

        Public ReadOnly Property EnumerateIndex As IEnumerable(Of String)
            Get
                Return index.Keys
            End Get
        End Property

        Public ReadOnly Property filepath As String

        Sub New(file As String)
            Me.file = New BinaryDataReader(
                input:=file.Open(IO.FileMode.OpenOrCreate, doClear:=False, [readOnly]:=True),
                encoding:=Encodings.ASCII
            )
            Me.file.ByteOrder = ByteOrder.LittleEndian
            Me.filepath = file

            If Not Me.VerifyMagicSignature(Me.file) Then
                Throw New InvalidProgramException("invalid magic header!")
            Else
                Call loadIndex()
            End If
        End Sub

        Private Sub loadIndex()
{'fraction_non_alphanumeric': 0.04240400667779633, 'fraction_numerical': 0.0, 'mean_word_length': 1.9722222222222223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3869048', 'n_tokens_mistral': 750, 'n_tokens_neox': 689, 'n_words': 238}