Performance fix for BufferCache.
The dpid of a page of file is calculated by fileid<<32 + pageid.
But BufferCache.hash(long dpid) returns the hash value dpid%pageMap.length.
In many cases,  the asterix configuration results in power-of-2 pageMap.length (buffer-cache-size/page-size), which makes fileid useless.
That used to result in serious consequences: different partitions contend for the same cache bucket (which contains a link list of size #partitions)
for most of the time and therefore the CPU couldn't be saturated.

Change-Id: I4afc406d612e569e23f65afdedc469459235ce7d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/341
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Young-Seok Kim <kisskys@gmail.com>
Reviewed-by: Pouria Pirzadeh <pouria.pirzadeh@gmail.com>
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 94ad801..0ceab64 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
@@ -67,7 +67,7 @@
         this.pageSize = pageReplacementStrategy.getPageSize();
         this.maxOpenFiles = maxOpenFiles;
         pageReplacementStrategy.setBufferCache(this);
-        pageMap = new CacheBucket[pageReplacementStrategy.getMaxAllowedNumPages() * MAP_FACTOR];
+        pageMap = new CacheBucket[pageReplacementStrategy.getMaxAllowedNumPages() * MAP_FACTOR + 1];
         for (int i = 0; i < pageMap.length; ++i) {
             pageMap[i] = new CacheBucket();
         }
@@ -441,7 +441,8 @@
     }
 
     private int hash(long dpid) {
-        return (int) (dpid % pageMap.length);
+        int hashValue = (int) (dpid ^ (dpid >>> 32));
+        return hashValue % pageMap.length;
     }
 
     private static class CacheBucket {