Skip to content

Commit

Permalink
Issue #5343 full scan issues were fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
laa committed Jan 6, 2016
1 parent d9f8cac commit 046c3bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Expand Up @@ -627,17 +627,18 @@ public OCachePointer[] load(long fileId, long startPageIndex, int pageCount, boo
return pagePointers;

for (int n = 0; n < pagePointers.length; n++) {
pagePointers[n].incrementReadersReferrer();

if (n > 0) {
pageGroup = writeCachePages.get(pageKeys[n]);

assert pageKeys[n].pageIndex == pagePointers[n].getPageIndex();

if (pageGroup != null) {
pagePointers[n].decrementReadersReferrer();
pagePointers[n] = pageGroup.page;
}
}

pagePointers[n].incrementReadersReferrer();
}

return pagePointers;
Expand Down Expand Up @@ -1271,16 +1272,24 @@ private OCachePointer[] cacheFileContent(final long fileId, final int intId, fin
final ByteBuffer[] buffers = new ByteBuffer[realPageCount];
for (int i = 0; i < buffers.length; i++) {
buffers[i] = bufferPool.acquireDirect(false);
assert buffers[i].position() == 0;
}

fileClassic.read(firstPageStartPosition, buffers);
final long bytesRead = fileClassic.read(firstPageStartPosition, buffers);
assert bytesRead % pageSize == 0;

final OCachePointer[] dataPointers = new OCachePointer[realPageCount];
for (int n = 0; n < dataPointers.length; n++) {
final int buffersRead = (int) (bytesRead / pageSize);

final OCachePointer[] dataPointers = new OCachePointer[buffersRead];
for (int n = 0; n < buffersRead; n++) {
buffers[n].position(0);
dataPointers[n] = new OCachePointer(buffers[n], bufferPool, lastLsn, fileId, startPageIndex + n);
}

for (int n = buffersRead; n < buffers.length; n++) {
bufferPool.release(buffers[n]);
}

pagesRead = dataPointers.length;
return dataPointers;
} finally {
Expand Down
Expand Up @@ -121,7 +121,7 @@ public interface OFile {

void read(long offset, ByteBuffer buffer) throws IOException;

void read(long offset, ByteBuffer[] buffers) throws IOException;
long read(long offset, ByteBuffer[] buffers) throws IOException;

void write(long offset, ByteBuffer buffer) throws IOException;
}
Expand Up @@ -172,7 +172,9 @@ public void read(long offset, ByteBuffer buffer) throws IOException {
}

@Override
public void read(long offset, ByteBuffer[] buffers) throws IOException {
public long read(long offset, ByteBuffer[] buffers) throws IOException {
int bytesRead = 0;

int attempts = 0;

while (true) {
Expand All @@ -182,7 +184,7 @@ public void read(long offset, ByteBuffer[] buffers) throws IOException {
offset += HEADER_SIZE;

channel.position(offset);
channel.read(buffers);
bytesRead = (int) channel.read(buffers);

break;

Expand All @@ -195,6 +197,8 @@ public void read(long offset, ByteBuffer[] buffers) throws IOException {
reopenFile(attempts, e);
}
}

return bytesRead;
}

@Override
Expand Down

0 comments on commit 046c3bf

Please sign in to comment.