This change includes:
1. avoid calling ByteBuffer.get() and ByteBuffer.put() for bloom filter set/get operations. ByteBuffer will check boundaries of the index for get/put.
It's a very frequent operation.
2. let the hash table size in BufferCache be 3X of the buffer cache page count.  This will even reduce conflicts.

Change-Id: Ifd47c410338ce557a494ab3605660bad1899e786
Reviewed-on: https://asterix-gerrit.ics.uci.edu/345
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Young-Seok Kim <kisskys@gmail.com>
Reviewed-by: Ian Maxon <imaxon@apache.org>
diff --git a/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java b/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
index 957659b..768841a 100644
--- a/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
+++ b/hyracks/hyracks-storage-am-bloomfilter/src/main/java/edu/uci/ics/hyracks/storage/am/bloomfilter/impls/BloomFilter.java
@@ -3,9 +3,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may obtain a copy of the License from
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -87,7 +87,7 @@
         }
         MurmurHash128Bit.hash3_x64_128(tuple, keyFields, SEED, hashes);
         for (int i = 0; i < numHashes; ++i) {
-            long hash = Math.abs((hashes[0] + (long) i * hashes[1]) % numBits);
+            long hash = Math.abs((hashes[0] + i * hashes[1]) % numBits);
 
             // we increment the page id by one, since the metadata page id of the filter is 0.
             ICachedPage page = bufferCache.pin(
@@ -272,7 +272,7 @@
             }
             MurmurHash128Bit.hash3_x64_128(tuple, keyFields, SEED, hashes);
             for (int i = 0; i < numHashes; ++i) {
-                long hash = Math.abs((hashes[0] + (long) i * hashes[1]) % numBits);
+                long hash = Math.abs((hashes[0] + i * hashes[1]) % numBits);
 
                 // we increment the page id by one, since the metadata page id of the filter is 0.
                 ICachedPage page = bufferCache.pin(
@@ -281,16 +281,14 @@
                 try {
                     ByteBuffer buffer = page.getBuffer();
                     int byteIndex = (int) (hash % numBitsPerPage) >> 3; // divide by 8
-                    byte b = buffer.get(byteIndex);
+                    byte b = buffer.array()[byteIndex];
                     int bitIndex = (int) (hash % numBitsPerPage) & 0x07; // mod 8
                     b = (byte) (b | (1 << bitIndex));
-
-                    buffer.put(byteIndex, b);
+                    buffer.array()[byteIndex] = b;
                 } finally {
                     page.releaseWriteLatch(true);
                     bufferCache.unpin(page);
                 }
-
             }
         }
 
diff --git a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
index d973947..2228f8c 100644
--- a/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
+++ b/hyracks/hyracks-storage-common/src/main/java/edu/uci/ics/hyracks/storage/common/buffercache/BufferCache.java
@@ -41,7 +41,7 @@
 
 public class BufferCache implements IBufferCacheInternal, ILifeCycleComponent {
     private static final Logger LOGGER = Logger.getLogger(BufferCache.class.getName());
-    private static final int MAP_FACTOR = 2;
+    private static final int MAP_FACTOR = 3;
 
     private static final int MIN_CLEANED_COUNT_DIFF = 3;
     private static final int PIN_MAX_WAIT_TIME = 50;