I’m developing a snake bot in c that is using zobrist hashing. However I’ve only got 16 Go of RAM which means that I can store around 10 ^ 9 different data. It’s not enough for my case. I want to store my data, which is a big array directly in my hard drive (nvme 4To). I can’t use fopen(), fclose(), … because if I store it in just one file, it will take forever to extract let’s say the 1001 element of the array. If I store each values of the array in different files (let’s say the the name of each file is the index of the array), it will take a lot of memory space and take a very very long time to find a file.
So I need a way to store the array directly on the hard drive without passing by the filesystem. Does anyone know one ? Btw, Im on linux and the disk is empty so it’s not a problem if I erase something that I shouldn’t. If there is a c library that does what I need, it could be a huge help, otherwise any low level solution could work for me. Also, I’m not an expert in file management so if there is a way to access the nth memory box of a file in constant time and change what it contains in constant time, that could work for me too.
I hope it’s clear enough.
Thank you all advance !
mat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.