You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2016/02/19 05:12:24 UTC
lens git commit: LENS-963 : Fix table weight look up in FactPartition
Repository: lens
Updated Branches:
refs/heads/master c4fa10723 -> 57f547a21
LENS-963 : Fix table weight look up in FactPartition
Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/57f547a2
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/57f547a2
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/57f547a2
Branch: refs/heads/master
Commit: 57f547a215f8f34b22147cf2177f527cffc3b709
Parents: c4fa107
Author: Amareshwari Sriramadasu <am...@apache.org>
Authored: Fri Feb 19 09:42:05 2016 +0530
Committer: Amareshwari Sriramadasu <am...@apache.org>
Committed: Fri Feb 19 09:42:05 2016 +0530
----------------------------------------------------------------------
.../java/org/apache/lens/cube/metadata/FactPartition.java | 8 ++++++--
.../org/apache/lens/cube/metadata/TestFactPartition.java | 4 ++++
2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lens/blob/57f547a2/lens-cube/src/main/java/org/apache/lens/cube/metadata/FactPartition.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/main/java/org/apache/lens/cube/metadata/FactPartition.java b/lens-cube/src/main/java/org/apache/lens/cube/metadata/FactPartition.java
index 1e5ef93..355a1f0 100644
--- a/lens-cube/src/main/java/org/apache/lens/cube/metadata/FactPartition.java
+++ b/lens-cube/src/main/java/org/apache/lens/cube/metadata/FactPartition.java
@@ -179,9 +179,13 @@ public class FactPartition implements Comparable<FactPartition> {
}
public double getAllTableWeights(ImmutableMap<String, Double> tableWeights) {
- float weight = 0;
+ double weight = 0;
+ Map<String, Double> tblWithoutDBWeghts = new HashMap<>();
+ for (Map.Entry<String, Double> entry : tableWeights.entrySet()) {
+ tblWithoutDBWeghts.put(entry.getKey().substring(entry.getKey().indexOf('.') + 1), entry.getValue());
+ }
for (String tblName : getStorageTables()) {
- Double tblWeight = tableWeights.get(tblName);
+ Double tblWeight = tblWithoutDBWeghts.get(tblName);
if (tblWeight != null) {
weight += tblWeight;
}
http://git-wip-us.apache.org/repos/asf/lens/blob/57f547a2/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestFactPartition.java
----------------------------------------------------------------------
diff --git a/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestFactPartition.java b/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestFactPartition.java
index e802c3c..dbcf20b 100644
--- a/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestFactPartition.java
+++ b/lens-cube/src/test/java/org/apache/lens/cube/metadata/TestFactPartition.java
@@ -53,5 +53,9 @@ public class TestFactPartition {
weights.put("st1", 0.2);
weights.put("st2", 0.3);
assertEquals(fp1.getAllTableWeights(ImmutableMap.copyOf(weights)), 0.5);
+ weights.clear();
+ weights.put("db1.st1", 0.4);
+ weights.put("db2.st2", 0.5);
+ assertEquals(fp1.getAllTableWeights(ImmutableMap.copyOf(weights)), 0.9);
}
}