asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: Fix ASTERIXDB-1255
Date Fri, 16 Dec 2016 23:00:03 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 2f9d4c3ab -> af7702128


Fix ASTERIXDB-1255

This changes enable dynamic hashtable size in SimilarityJaccardEvaluator

Change-Id: I08c550d35d864df08792369d38ff81012e3976af
Reviewed-on: https://asterix-gerrit.ics.uci.edu/586
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/af770212
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/af770212
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/af770212

Branch: refs/heads/master
Commit: af7702128621b57e91bffc96bca339960ca2193a
Parents: 2f9d4c3
Author: Michael Blow <mblow@apache.org>
Authored: Fri Dec 16 12:17:09 2016 -0800
Committer: Till Westmann <tillw@apache.org>
Committed: Fri Dec 16 14:59:27 2016 -0800

----------------------------------------------------------------------
 .../evaluators/common/SimilarityJaccardEvaluator.java | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/af770212/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
index e9928a1..ab817bd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
@@ -50,11 +50,11 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
 public class SimilarityJaccardEvaluator implements IScalarEvaluator {
 
     // Parameters for hash table.
-    protected final int TABLE_SIZE = 100;
-    protected final int TABLE_FRAME_SIZE = 32768;
+    protected static final int MIN_TABLE_SIZE = 100;
+    protected static final int TABLE_FRAME_SIZE = 32768;
 
     // Assuming type indicator in serde format.
-    protected final int TYPE_INDICATOR_SIZE = 1;
+    protected static final int TYPE_INDICATOR_SIZE = 1;
 
     protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
     protected final DataOutput out = resultStorage.getDataOutput();
@@ -89,6 +89,8 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
     // Ignore case for strings. Defaults to true.
     protected final boolean ignoreCase = true;
 
+    protected int hashTableSize = MIN_TABLE_SIZE;
+
     public SimilarityJaccardEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext
context)
             throws HyracksDataException {
         firstOrdListEval = args[0].createScalarEvaluator(context);
@@ -140,6 +142,10 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
         if (firstListIter.size() == 0 || secondListIter.size() == 0) {
             return false;
         }
+
+        // Set the size of the table dynamically
+        hashTableSize = Math.max(Math.max(firstListIter.size(), secondListIter.size()), MIN_TABLE_SIZE);
+
         // TODO: Check item types are compatible.
         return true;
     }
@@ -229,7 +235,7 @@ public class SimilarityJaccardEvaluator implements IScalarEvaluator {
                 .createBinaryHashFunction(probeItemTypeTag, ignoreCase);
         IBinaryComparator cmp = ListItemBinaryComparatorFactory.INSTANCE.createBinaryComparator(buildItemTypeTag,
                 probeItemTypeTag, ignoreCase);
-        hashMap = new BinaryHashMap(TABLE_SIZE, TABLE_FRAME_SIZE, putHashFunc, getHashFunc,
cmp);
+        hashMap = new BinaryHashMap(hashTableSize, TABLE_FRAME_SIZE, putHashFunc, getHashFunc,
cmp);
     }
 
     protected boolean checkArgTypes(ATypeTag typeTag1, ATypeTag typeTag2) throws HyracksDataException
{


Mime
View raw message