Skip to content

Commit

Permalink
TEIID-3443 fixing max block expression
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Apr 17, 2015
1 parent 18c4f42 commit 7445395
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -576,7 +576,7 @@ void initialize(boolean allocateMemory) throws TeiidComponentException {
}
memoryWritePermits = new Semaphore(blocks);
maxMemoryBlocks = Math.min(MAX_DOUBLE_INDIRECT, blocks);
maxMemoryBlocks = Math.min(maxMemoryBlocks, maxStorageObjectSize>>LOG_BLOCK_SIZE + ((maxStorageObjectSize&BufferFrontedFileStoreCache.BLOCK_MASK)>0?1:0));
maxMemoryBlocks = Math.min(maxMemoryBlocks, (maxStorageObjectSize>>LOG_BLOCK_SIZE) + ((maxStorageObjectSize&BufferFrontedFileStoreCache.BLOCK_MASK)>0?1:0));
//try to maintain enough freespace so that writers don't block in cleaning
cleaningThreshold = Math.min(maxMemoryBlocks<<4, blocks>>1);
criticalCleaningThreshold = Math.min(maxMemoryBlocks<<2, blocks>>2);
Expand Down
Expand Up @@ -419,4 +419,9 @@ public long getLength() {
createLayeredCache(1 << 20, 1 << 30, false, false);
}

@Test public void testNonAlignedMaxBlocks() throws TeiidComponentException {
BufferFrontedFileStoreCache bf = createLayeredCache(1 << 20, 8000000, false, false);
assertEquals(974, bf.getMaxMemoryBlocks());
}

}

0 comments on commit 7445395

Please sign in to comment.