Commit e1aafb33 by Tomas Dvorak

fixed total counts and percents when limit or query applied

parent d86c32c2
...@@ -32,7 +32,6 @@ public class LimitResultsAnalysisTest { ...@@ -32,7 +32,6 @@ public class LimitResultsAnalysisTest {
analysis.verifyResult("_id", 5, 100, "ObjectId"); analysis.verifyResult("_id", 5, 100, "ObjectId");
analysis.verifyResult("name", 5, 100, "String"); analysis.verifyResult("name", 5, 100, "String");
// TODO: there is only one document with 'someBinData'. Why variety returns 5/100% instead of 1/20% ? analysis.verifyResult("someBinData", 1, 20, "BinData-old");
// FIXME: analysis.verifyResult("someBinData", 1, 20, "BinData-old");
} }
} }
...@@ -27,9 +27,9 @@ public class QueryLimitedAnalysisTest { ...@@ -27,9 +27,9 @@ public class QueryLimitedAnalysisTest {
final VarietyAnalysis analysis = variety.withQuery("{someBinData:{$exists: true}}").runAnalysis(); final VarietyAnalysis analysis = variety.withQuery("{someBinData:{$exists: true}}").runAnalysis();
Assert.assertEquals(3, analysis.getResultsCollection().count()); Assert.assertEquals(3, analysis.getResultsCollection().count());
// TODO: are those percentContaining numbers correct? Should percents be limited to all data or query data? // we analyzed only the keys of objects defined by query. But total counts and percents are computed from the complete collection
analysis.verifyResult("_id", 1, 20, "ObjectId"); analysis.verifyResult("_id", 5, 100, "ObjectId");
analysis.verifyResult("name", 1, 20, "String"); analysis.verifyResult("name", 5, 100, "String");
analysis.verifyResult("someBinData", 1, 20, "BinData-old"); analysis.verifyResult("someBinData", 1, 20, "BinData-old");
} }
......
...@@ -49,14 +49,11 @@ public class SortedAnalysisTest { ...@@ -49,14 +49,11 @@ public class SortedAnalysisTest {
Assert.assertEquals(5, analysis.getResultsCollection().count()); Assert.assertEquals(5, analysis.getResultsCollection().count());
// TODO: are those percentContaining numbers correct? Should percents be limited to all data or query data?
// Why total counts are always 5, when 'someWeirdLegacyKey' has only one object?
// Keys and types are correct, total count and percents seems not right.
analysis.verifyResult("_id", 5, 100, "ObjectId"); analysis.verifyResult("_id", 5, 100, "ObjectId");
analysis.verifyResult("name", 5, 100, "String"); analysis.verifyResult("name", 5, 100, "String");
analysis.verifyResult("bio", 5, 100, "String"); analysis.verifyResult("bio", 3, 60, "String");
analysis.verifyResult("pets", 5, 100, "Array"); analysis.verifyResult("pets", 2, 40, "Array");
analysis.verifyResult("someWeirdLegacyKey", 5, 100, "String"); analysis.verifyResult("someWeirdLegacyKey", 1, 20, "String");
} }
} }
...@@ -209,7 +209,7 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) { ...@@ -209,7 +209,7 @@ resultsDB[resultsCollectionName].find({}).forEach(function(key) {
if(limit < numDocuments) { if(limit < numDocuments) {
var existsQuery = {}; var existsQuery = {};
existsQuery[keyName] = {$exists: true}; existsQuery[keyName] = {$exists: true};
key.totalOccurrences = db[collection].find(query).count(existsQuery); key.totalOccurrences = db[collection].count(existsQuery);
} }
key.percentContaining = (key.totalOccurrences / numDocuments) * 100.0; key.percentContaining = (key.totalOccurrences / numDocuments) * 100.0;
resultsDB[resultsCollectionName].save(key); resultsDB[resultsCollectionName].save(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment