// Path: src/main/java/net/kimleo/rec/common/Pair.java
// public class Pair<K, V> {
//     public final K first;
//     public final V second;
// 
// 
//     public Pair(K first, V second) {
//         this.first = first;
//         this.second = second;
//     }
// 
//     public K getFirst() {
//         return first;
//     }
// 
//     public V getSecond() {
//         return second;
//     }
// 
// }
// 
// Path: src/main/java/net/kimleo/rec/common/concept/Mapped.java
// public interface Mapped<T> {
//     T get(String field);
// 
//     List<String> keys();
// }
// 
// Path: src/main/java/net/kimleo/rec/common/exception/ResourceAccessException.java
// public class ResourceAccessException extends RuntimeException {
//     public ResourceAccessException(String message, Throwable ex) {
//         super(message, ex);
//     }
// }


import net.kimleo.rec.common.Pair;
import net.kimleo.rec.common.concept.Mapped;
import net.kimleo.rec.common.exception.ResourceAccessException;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
        if (size != expectedSize) return null;
        ArrayList<String> items = new ArrayList<>(size);

        for (int i = 0; i < size; i++) {
            int length = buffer.getInt();
            byte[] bytes = new byte[length];
            buffer.get(bytes, 0, length);
            items.add(new String(bytes));

        }

        return new Pair<>(items, buffer.position() - readPos);
    }

    public static void dump(File file, int expectSize) {
        try {
            long length = file.length();
            MappedByteBuffer byteBuffer = FileChannel.open(file.toPath(), StandardOpenOption.READ)
                    .map(FileChannel.MapMode.READ_ONLY, 0, (int) length);

            int readPos = 0;

            while (readPos < byteBuffer.limit()) {
                Pair<List<String>, Integer> result = decode(byteBuffer, readPos, expectSize);
                if (result == null) break;
                readPos += result.second;

                System.out.println(result.first.stream().collect(Collectors.joining(", ")));
            }
        } catch (IOException e) {
// Path: src/main/java/net/kimleo/rec/common/Pair.java
// public class Pair<K, V> {
//     public final K first;
//     public final V second;
// 
// 
//     public Pair(K first, V second) {
//         this.first = first;
//         this.second = second;
//     }
// 
//     public K getFirst() {
//         return first;
//     }
// 
//     public V getSecond() {
//         return second;
//     }
// 
// }
// 
// Path: src/main/java/net/kimleo/rec/common/concept/Mapped.java
// public interface Mapped<T> {
//     T get(String field);
// 
//     List<String> keys();
// }
// 
// Path: src/main/java/net/kimleo/rec/common/exception/ResourceAccessException.java
// public class ResourceAccessException extends RuntimeException {
//     public ResourceAccessException(String message, Throwable ex) {
//         super(message, ex);
//     }
// }


// Path: src/main/java/net/kimleo/rec/v2/utils/Records.java
import net.kimleo.rec.common.Pair;
import net.kimleo.rec.common.concept.Mapped;
import net.kimleo.rec.common.exception.ResourceAccessException;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

        if (size != expectedSize) return null;
        ArrayList<String> items = new ArrayList<>(size);

        for (int i = 0; i < size; i++) {
            int length = buffer.getInt();
            byte[] bytes = new byte[length];
            buffer.get(bytes, 0, length);
            items.add(new String(bytes));

        }

        return new Pair<>(items, buffer.position() - readPos);
    }

    public static void dump(File file, int expectSize) {
        try {
            long length = file.length();
            MappedByteBuffer byteBuffer = FileChannel.open(file.toPath(), StandardOpenOption.READ)
                    .map(FileChannel.MapMode.READ_ONLY, 0, (int) length);

            int readPos = 0;

            while (readPos < byteBuffer.limit()) {
                Pair<List<String>, Integer> result = decode(byteBuffer, readPos, expectSize);
                if (result == null) break;
                readPos += result.second;

                System.out.println(result.first.stream().collect(Collectors.joining(", ")));
            }
        } catch (IOException e) {
            throw new ResourceAccessException("Unable to dump file: [" + file.getName() + "]", e);