Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/maps/MapFile.java
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | public class MapFile { | ||||
public byte[] readAtLine(long lineIndex) { | public byte[] readAtLine(long lineIndex) { | ||||
byte[] buffer = new byte[lineLength]; | byte[] buffer = new byte[lineLength]; | ||||
long position = lineIndex * (long) lineLength; | long position = lineIndex * (long) lineLength; | ||||
bufferMap.position(position); | bufferMap.position(position); | ||||
bufferMap.read(buffer, 0, lineLength); | bufferMap.read(buffer, 0, lineLength); | ||||
return buffer; | return buffer; | ||||
} | } | ||||
public long size() { | |||||
return bufferMap.length() / (long) lineLength; | |||||
} | |||||
/** | /** | ||||
* Closes the mmap()-ed file. | * Closes the mmap()-ed file. | ||||
*/ | */ | ||||
public void close() throws IOException { | public void close() throws IOException { | ||||
bufferMap.close(); | bufferMap.close(); | ||||
} | } | ||||
} | } |