<commit_before>package com.sibilantsolutions.grison.net.netty.codec;

import java.util.function.Function;

import com.sibilantsolutions.grison.driver.foscam.dto.VideoDataTextDto;
import com.sibilantsolutions.grison.driver.foscam.type.FosInt32;
import com.sibilantsolutions.grison.driver.foscam.type.FosInt8;
import com.sibilantsolutions.grison.net.netty.codec.parse.NettyFosTypeReader;
import io.netty.buffer.ByteBuf;

public class VideoDataTextDtoParser implements Function<ByteBuf, VideoDataTextDto> {
    @Override
    public VideoDataTextDto apply(ByteBuf buf) {
        final FosInt32 timestamp = NettyFosTypeReader.fosInt32(buf);
        final FosInt32 framePerSec = NettyFosTypeReader.fosInt32(buf);
        final FosInt8 reserve = NettyFosTypeReader.fosInt8(buf);
        final FosInt32 videoLength = NettyFosTypeReader.fosInt32(buf);
        byte[] videoData = new byte[videoLength.value()];
        buf.readBytes(videoData);

        return VideoDataTextDto.builder()
                .timestamp(timestamp)
                .framePerSec(framePerSec)
                .reserve(reserve)
                .videoLength(videoLength)
                .videoData(videoData)
                .build();
    }
}<commit_msg>Use the readBytes helper to create the byte[] array for video data.<commit_after>package com.sibilantsolutions.grison.net.netty.codec;

import java.util.function.Function;

import com.sibilantsolutions.grison.driver.foscam.dto.VideoDataTextDto;
import com.sibilantsolutions.grison.driver.foscam.type.FosInt32;
import com.sibilantsolutions.grison.driver.foscam.type.FosInt8;
import com.sibilantsolutions.grison.net.netty.codec.parse.NettyByteBufHelper;
import com.sibilantsolutions.grison.net.netty.codec.parse.NettyFosTypeReader;
import io.netty.buffer.ByteBuf;

public class VideoDataTextDtoParser implements Function<ByteBuf, VideoDataTextDto> {
    @Override
    public VideoDataTextDto apply(ByteBuf buf) {
        final FosInt32 timestamp = NettyFosTypeReader.fosInt32(buf);
        final FosInt32 framePerSec = NettyFosTypeReader.fosInt32(buf);
        final FosInt8 reserve = NettyFosTypeReader.fosInt8(buf);
        final FosInt32 videoLength = NettyFosTypeReader.fosInt32(buf);
        //Copy the video data out of the buffer into a new array.  Two reasons: we don't want downstream to depend
        //on Netty, and we can't count on downstream to release a buffer.
        byte[] videoData = NettyByteBufHelper.readBytes(videoLength.value(), buf);

        return VideoDataTextDto.builder()
                .timestamp(timestamp)
                .framePerSec(framePerSec)
                .reserve(reserve)
                .videoLength(videoLength)
                .videoData(videoData)
                .build();
    }
}
{'fraction_non_alphanumeric': 0.08776402039329935, 'fraction_numerical': 0.012381646030589949, 'mean_word_length': 3.3881789137380194, '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': '6082270', 'n_tokens_mistral': 874, 'n_tokens_neox': 850, 'n_words': 152}