<commit_before>package buffer

import "io"

type Ring struct {
	Buffer
	L int64
	*WrapReader
	*WrapWriter
}

func NewRing(buffer Buffer) *Ring {
	return &Ring{
		Buffer:     buffer,
		WrapReader: NewWrapReader(buffer, 0, buffer.Cap()),
		WrapWriter: NewWrapWriter(buffer, 0, buffer.Cap()),
	}
}

func (buf *Ring) Len() int64 {
	return buf.L
}

func (buf *Ring) Read(p []byte) (n int, err error) {
	if Full(buf) {
		buf.WrapReader.Seek(buf.WrapWriter.Offset(), 0)
	}
	n, err = io.LimitReader(buf.WrapReader, buf.Len()).Read(p)
	buf.L -= int64(n)
	return n, err
}

func (buf *Ring) ReadAt(p []byte, off int64) (n int, err error) {
	if Full(buf) {
		buf.WrapReader.Seek(buf.WrapWriter.Offset(), 0)
	}
	return buf.WrapReader.ReadAt(p, buf.WrapReader.Offset()+off)
}

func (buf *Ring) Write(p []byte) (n int, err error) {
	n, err = buf.WrapWriter.Write(p)
	buf.L += int64(n)
	if buf.L > buf.Cap() {
		buf.L = buf.Cap()
	}
	return n, err
}

func (buf *Ring) WriteAt(p []byte, off int64) (n int, err error) {
	n, err = buf.WrapWriter.WriteAt(p, off)
	if off+int64(n) > buf.Len() {
		buf.L = off + int64(n)<commit_msg>Ring buffer also reports infinite capacity so writes are never rejected<commit_after>package buffer

import "io"

type Ring struct {
	Buffer
	L int64
	*WrapReader
	*WrapWriter
}

func NewRing(buffer Buffer) *Ring {
	return &Ring{
		Buffer:     buffer,
		WrapReader: NewWrapReader(buffer, 0, buffer.Cap()),
		WrapWriter: NewWrapWriter(buffer, 0, buffer.Cap()),
	}
}

func (buf *Ring) Len() int64 {
	return buf.L
}

func (buf *Ring) Cap() int64 {
	return MAXINT64
}

func (buf *Ring) Read(p []byte) (n int, err error) {
	if Full(buf) {
		buf.WrapReader.Seek(buf.WrapWriter.Offset(), 0)
	}
	n, err = io.LimitReader(buf.WrapReader, buf.Len()).Read(p)
	buf.L -= int64(n)
	return n, err
}

func (buf *Ring) ReadAt(p []byte, off int64) (n int, err error) {
	if Full(buf) {
		buf.WrapReader.Seek(buf.WrapWriter.Offset(), 0)
	}
	return buf.WrapReader.ReadAt(p, buf.WrapReader.Offset()+off)
}

func (buf *Ring) Write(p []byte) (n int, err error) {
	n, err = buf.WrapWriter.Write(p)
	buf.L += int64(n)
	if buf.L > buf.Cap() {
		buf.L = buf.Cap()
	}
	return n, err
}

func (buf *Ring) WriteAt(p []byte, off int64) (n int, err error) {
	n, err = buf.WrapWriter.WriteAt(p, off)
	if off+int64(n) > buf.Len() {
		buf.L = off + int64(n)
{'fraction_non_alphanumeric': 0.1687419493344783, 'fraction_numerical': 0.018892228424216402, 'mean_word_length': 3.8744769874476988, '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': '3641270', 'n_tokens_mistral': 1008, 'n_tokens_neox': 948, 'n_words': 252}