* Opens the underlying file to the database.
*/
private RandomAccessWrapper openRowFileImpl()
throws IOException
{
RandomAccessStream file = null;
RandomAccessWrapper wrapper = null;
// SoftReference<RandomAccessWrapper> ref = _cachedRowFile.allocate();
wrapper = _cachedRowFile.allocate();
/*
if (ref != null) {
wrapper = ref.get();
}
*/
if (wrapper != null) {
file = wrapper.getFile();
if (_mmapFile.get() != null && file.getLength() != _fileSize)
file = null;
}
if (file == null) {
Path path = _path;
if (path != null) {
RandomAccessStream mmapFile = _mmapFile.get();
if (mmapFile != null && mmapFile.getLength() == _fileSize) {
return new RandomAccessWrapper(mmapFile);
}
if (_isEnableMmap) {
long fileSize = _fileSize;
if (fileSize == 0)
fileSize = FILE_SIZE_INCREMENT;
file = path.openMemoryMappedFile(fileSize);
if (file != null)
_fileSize = fileSize;
}
if (file != null) {
_isMmap = true;
RandomAccessStream oldMmap = _mmapFile.getAndSet(file);
if (oldMmap != null)
oldMmap.close();
}
else {
_isEnableMmap = false;
file = path.openRandomAccess();
}