<commit_before>// Copyright (c) <NAME>, 2015. All rights reserved. PROVIDED "AS IS"
// WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. See LICENSE file for details.

package rec

import (
	"log"
	"time"

	"github.com/google/gopacket"

	"my/ev/packet"
	"my/ev/sim"
)

type Stream struct {
	message *sim.SimMessage
	seconds map[gopacket.Flow]int
	seqNum  map[gopacket.Flow]uint64
}

func NewStream() *Stream {
	l := &Stream{
		seconds: make(map[gopacket.Flow]int),
		seqNum:  make(map[gopacket.Flow]uint64),
	}
	return l
}
func (l *Stream) MessageArrived(idm *sim.SimMessage) {
	l.message = idm

	flow := l.message.Pam.Flow()
	seq := l.message.Pam.SequenceNumber()
	if seq != 0 {
		if prevSeq, ok := l.seqNum[flow]; ok && prevSeq+1 != seq {
			log.Printf("seqNum gap; expected %d actual %d\n", prevSeq+1, seq)
		}
		l.seqNum[flow] = seq
	}

	if m, ok := l.message.Pam.Layer().(packet.SecondsMessage); ok {
		l.seconds[flow] = m.Seconds()
	}
}
func (l *Stream) getSeqNum() uint64 {
	flow := l.message.Pam.Flow()
	return l.seqNum[flow]
}
func (l *Stream) getTimestamp() uint64 {
	flow := l.message.Pam.Flow()
	return uint64(l.seconds[flow])*1e9 + uint64(l.message.Pam.Layer().(packet.ExchangeMessage).Nanoseconds())
}
func (l *Stream) getExchangeMessage() packet.ExchangeMessage {
	return l.message.Pam.Layer().(packet.ExchangeMessage)
}
func (l *Stream) getPacketTimestamp() time.Time {
	return l.message.Pam.Timestamp()
}<commit_msg>rec:Stream: refactor to use sim.Session<commit_after>// Copyright (c) <NAME>, 2015. All rights reserved. PROVIDED "AS IS"
// WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. See LICENSE file for details.

package rec

import (
	"log"
	"time"

	"my/ev/packet"
	"my/ev/sim"
)

type Stream struct {
	message *sim.SimMessage
	seconds map[int]int
	seqNum  map[int]uint64
}

func NewStream() *Stream {
	l := &Stream{
		seconds: make(map[int]int),
		seqNum:  make(map[int]uint64),
	}
	return l
}
func (l *Stream) MessageArrived(idm *sim.SimMessage) {
	l.message = idm

	idx := l.message.Session.Index()
	seq := l.message.Pam.SequenceNumber()
	if seq != 0 {
		if prevSeq, ok := l.seqNum[idx]; ok && prevSeq+1 != seq {
			log.Printf("seqNum gap; expected %d actual %d\n", prevSeq+1, seq)
		}
		l.seqNum[idx] = seq
	}

	if m, ok := l.message.Pam.Layer().(packet.SecondsMessage); ok {
		l.seconds[idx] = m.Seconds()
	}
}
func (l *Stream) getSeqNum() uint64 {
	idx := l.message.Session.Index()
	return l.seqNum[idx]
}
func (l *Stream) getTimestamp() uint64 {
	idx := l.message.Session.Index()
	return uint64(l.seconds[idx])*1e9 + uint64(l.message.Pam.Layer().(packet.ExchangeMessage).Nanoseconds())
}
func (l *Stream) getExchangeMessage() packet.ExchangeMessage {
	return l.message.Pam.Layer().(packet.ExchangeMessage)
}
func (l *Stream) getPacketTimestamp() time.Time {
	return l.message.Pam.Timestamp()
}
{'fraction_non_alphanumeric': 0.16500711237553342, 'fraction_numerical': 0.014935988620199146, 'mean_word_length': 4.248134328358209, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1170137', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1057, 'n_words': 245}