<commit_before>package com.yahoo.io;

import com.yahoo.text.Utf8;

import java.io.IOException;
import java.nio.ByteBuffer;

public class Utf8ByteWriter extends AbstractByteWriter {
    private ByteBuffer myBuf;
    public Utf8ByteWriter(int initialBuffer) {
        super(Utf8.getNewEncoder());
        myBuf = ByteBuffer.allocate(initialBuffer);
    }
    @Override
    public void send(ByteBuffer src) throws IOException {
        if (myBuf.remaining() < src.remaining()) {
            ByteBuffer newBuf = ByteBuffer.allocate(1 << Integer.highestOneBit(myBuf.position()+src.remaining()));
            myBuf.flip();
            newBuf.put(myBuf);
            myBuf = newBuf;
        }
        myBuf.put(src);
    }

    @Override<commit_msg>properly round up to closest power of 2 above required size.<commit_after>package com.yahoo.io;

import com.yahoo.text.Utf8;

import java.io.IOException;
import java.nio.ByteBuffer;

public class Utf8ByteWriter extends AbstractByteWriter {
    private ByteBuffer myBuf;
    public Utf8ByteWriter(int initialBuffer) {
        super(Utf8.getNewEncoder());
        myBuf = ByteBuffer.allocate(initialBuffer);
    }
    @Override
    public void send(ByteBuffer src) throws IOException {
        if (myBuf.remaining() < src.remaining()) {
            ByteBuffer newBuf = ByteBuffer.allocate(Integer.highestOneBit(myBuf.position()+src.remaining()) << 1);
            myBuf.flip();
            newBuf.put(myBuf);
            myBuf = newBuf;
        }
        myBuf.put(src);
    }

    @Override
{'fraction_non_alphanumeric': 0.10646636185499674, 'fraction_numerical': 0.007184846505551927, 'mean_word_length': 2.849246231155779, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3136367', 'n_tokens_mistral': 470, 'n_tokens_neox': 450, 'n_words': 93}