Skip to content

Commit

Permalink
Added a cache to store filter values. This resolves issues #53 and #31.
Browse files Browse the repository at this point in the history
  • Loading branch information
artourkin committed Jun 22, 2016
1 parent 75de232 commit 76f363b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ public static long getConflictsCount(Filter filter){


List<BasicDBObject> basicDBObjects = persistence.mapReduceRaw(map2, reduce, filter);
if (basicDBObjects.size()==0){
return 0;
}
BasicDBObject basicDBObject = basicDBObjects.get(0);

Double conflictsDouble = basicDBObject.getDouble("value");
return conflictsDouble.longValue();
}
Expand Down
2 changes: 1 addition & 1 deletion c3po-webapi/app/controllers/Filters.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static Result addCondition() {
break;
case BOOL:
try {
propertyValue = Double.parseDouble(propertyValueString);
propertyValue = Boolean.parseBoolean(propertyValueString);
} catch (Exception ex){
if (propertyValueString.equals("Unknown"))
propertyValue = null;
Expand Down
26 changes: 19 additions & 7 deletions c3po-webapi/app/controllers/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ public static Result getValuesUnconditional() {
}

public static PropertyValuesFilter getValues(String property, String algorithm, String width, String selectedValue) {
PersistenceLayer persistence = Configurator.getDefaultConfigurator().getPersistence();
Property p = persistence.getCache().getProperty(property);
if (property.equals("collection")) {
PersistenceLayer persistence = Configurator.getDefaultConfigurator().getPersistence();
Property p = persistence.getCache().getProperty(property);

PropertyValuesFilter pvf = new PropertyValuesFilter();
pvf.setProperty(p.getKey());
pvf.setType(p.getType());
Expand All @@ -354,12 +355,20 @@ public static PropertyValuesFilter getValues(String property, String algorithm,
pvf.setSelected(getCollection());
return pvf;
} else {
Distribution d = Properties.getDistribution(property, null);
Graph graph = Properties.interpretDistribution(d, algorithm, width);

PropertyValuesFilter result = new PropertyValuesFilter();
result.setProperty(property);
result.setType(d.getType());
result.setValues(graph.getKeys());
if (allPropertyValues.containsKey(property)){
result.setProperty(property);
result.setType(p.getType());
result.setValues(allPropertyValues.get(property));
} else {
Distribution d = Properties.getDistribution(property, null);
Graph graph = Properties.interpretDistribution(d, algorithm, width);
result.setProperty(property);
result.setType(d.getType());
result.setValues(graph.getKeys());
allPropertyValues.put(property,graph.getKeys());
}
result.setSelected(selectedValue);
if (selectedValue != null)
result.setSelected(selectedValue);
Expand Down Expand Up @@ -414,4 +423,7 @@ static Object getTypedValue(String val) {
}
return value;
}
static Map<String, List<String>> allPropertyValues=new HashMap<String, List<String>>();


}
Binary file modified c3po-webapi/lib/c3po-core-0.5.0.jar
Binary file not shown.

0 comments on commit 76f363b

Please sign in to comment.