/* * Assume that the window is properly positioned. Try to fill the read * buffer with data from this file handle, starting at the location * indicated by the starting offset field. If this file contains more * data, return true. If this file doesn't contain more data, return * false. * * In all cases, leave the the read buffer pointing at the target * offset and in a state that's ready to support reads, even if there * is nothing in the buffer. Note that the target offset, which may not * be the same as starting offset. * @return true if more data was read, false if not. */ protected boolean fillFromFile(FileHandle fileHandle, long targetOffset) throws DatabaseException { boolean foundData = false; readBuffer.clear(); if (fileManager.readFromFile( fileHandle.getFile(), readBuffer, startOffset, fileHandle.getFileNum(), false /* dataKnownToBeInFile */)) { foundData = true; nReadOperations += 1; /* * Ensure that fileNum and logVersion are in sync. setFileNum * handles changes in the file number. But we must also update * the logVersion here to handle the first read after we * initialize fileNum and logVersion is unknown. */ logVersion = fileHandle.getLogVersion(); } /* * In all cases, setup read buffer for valid reading. If the buffer * has no data, it will be positioned at the beginning, and will be * able to correctly return the fact that there is no data present. */ endOffset = startOffset + threadSafeBufferPosition(readBuffer); threadSafeBufferFlip(readBuffer); threadSafeBufferPosition(readBuffer, (int) (targetOffset - startOffset)); return foundData; }