/** * @return The index of the first byte contained in this database as a function of the index of * the first record */ protected final long firstByteIndex() { return myLogic.getByteIndex(firstRecordIndex); }
/** * @return The number of bytes contained in this database as a function of the number of records */ protected final long numBytes() { return myLogic.getNumBytes(numRecords); }
public final long requiredMemory(long numRecords) { return myLogic.getNumBytes(numRecords); }
/** * @param numBytes The number of bytes available * @return The number of records which can be stored in numBytes bytes */ public final long recordsForBytes(long numBytes) { return myLogic.getNumRecords(numBytes); }
public long readNextRecord(DatabaseHandle dh) throws IOException { readFullBytes(dh, dh.currentRecord, 0, myLogic.recordBytes); return myLogic.getRecord(dh.currentRecord, 0); }
public void writeNextRecord(DatabaseHandle dh, long record) throws IOException { myLogic.fillBytes(record, dh.currentRecord, 0); writeFullBytes(dh, dh.currentRecord, 0, myLogic.recordBytes); }
public void prepareWriteRecordRange(DatabaseHandle dh, long recordIndex, long numRecords) throws IOException { prepareWriteRange(dh, myLogic.getByteIndex(recordIndex), myLogic.getNumBytes(numRecords)); }
protected void writeRecordFromByteIndex(DatabaseHandle dh, long byteIndex, long record) throws IOException { myLogic.fillBytes(record, dh.currentRecord, 0); writeFullBytes(dh, byteIndex, dh.currentRecord, 0, myLogic.recordBytes); }
public void writeRecord(DatabaseHandle dh, long recordIndex, long record) throws IOException { writeRecordFromByteIndex(dh, myLogic.getByteIndex(recordIndex), record); }
/** * @param dh The handle to use for reading * @param byteIndex The byte-index into the file to begin reading at * @return The hash of the record read at that position * @throws IOException If an IOException occurs while reading */ protected long readRecordFromByteIndex(DatabaseHandle dh, long byteIndex) throws IOException { readFullBytes(dh, byteIndex, dh.currentRecord, 0, myLogic.recordBytes); return myLogic.getRecord(dh.currentRecord, 0); }
/** * Reads a record at the given hash * * @param dh The handle to use for reading * @param recordIndex The hash of the game state where the record should be read * @return The hash of the record read at that position * @throws IOException If an IOException occurs while reading */ public long readRecord(DatabaseHandle dh, long recordIndex) throws IOException { return readRecordFromByteIndex(dh, myLogic.getByteIndex(recordIndex)); }