Example #1
0
 /**
  * @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);
 }
Example #2
0
 /**
  * @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);
 }
Example #3
0
 public final long requiredMemory(long numRecords) {
   return myLogic.getNumBytes(numRecords);
 }
Example #4
0
 /**
  * @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);
 }
Example #5
0
 public long readNextRecord(DatabaseHandle dh) throws IOException {
   readFullBytes(dh, dh.currentRecord, 0, myLogic.recordBytes);
   return myLogic.getRecord(dh.currentRecord, 0);
 }
Example #6
0
 public void writeNextRecord(DatabaseHandle dh, long record) throws IOException {
   myLogic.fillBytes(record, dh.currentRecord, 0);
   writeFullBytes(dh, dh.currentRecord, 0, myLogic.recordBytes);
 }
Example #7
0
 public void prepareWriteRecordRange(DatabaseHandle dh, long recordIndex, long numRecords)
     throws IOException {
   prepareWriteRange(dh, myLogic.getByteIndex(recordIndex), myLogic.getNumBytes(numRecords));
 }
Example #8
0
 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);
 }
Example #9
0
 public void writeRecord(DatabaseHandle dh, long recordIndex, long record) throws IOException {
   writeRecordFromByteIndex(dh, myLogic.getByteIndex(recordIndex), record);
 }
Example #10
0
 /**
  * @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);
 }
Example #11
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));
 }