mmap() vs. reading blocks

I’m working on a program that will be processing files that could potentially be 100GB or more in size. The files contain sets of variable length records. I’ve got a first implementation up and running and am now looking towards improving performance, particularly at doing I/O more efficiently since the input file gets scanned many … Read more

getResourceAsStream returns null

I’m loading a text file from within a package in a compiled JAR of my Java project. The relevant directory structure is as follows: /src/initialization/Lifepaths.txt My code loads a file by calling Class::getResourceAsStream to return a InputStream. public class Lifepaths { public static void execute() { System.out.println(Lifepaths.class.getClass(). getResourceAsStream(“/initialization/Lifepaths.txt”)); } private Lifepaths() {} //This is temporary; … Read more

C read file line by line

I wrote this function to read a line from a file: const char *readLine(FILE *file) { if (file == NULL) { printf(“Error: file pointer is null.”); exit(1); } int maximumLineLength = 128; char *lineBuffer = (char *)malloc(sizeof(char) * maximumLineLength); if (lineBuffer == NULL) { printf(“Error allocating memory for line buffer.”); exit(1); } char ch = … Read more