add data caching on sampling and smartSampling

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100290 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-09-30 12:40:52 +00:00
parent 53ac9390b7
commit 67dc075dcc
1 changed files with 4 additions and 40 deletions

View File

@ -907,7 +907,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// data output
// List<Result> output = new ArrayList<Result>();
List<Result> output = null;
SubmitQueryResultWithFileFromServlet result;
// list that contains table attributes
List<String> listAttributes = null;
@ -964,31 +964,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(4).setValue(language);
inputParameters.get(5).setValue(query);
// get data from cache
// check if data exist considering as key the input parameters
// parse the query in order to remove spaces
String queryParsed = parseQuery(inputParameters.get(5).getValue());
String key = inputParameters.get(0).getValue()
+ inputParameters.get(1).getValue()
+ inputParameters.get(2).getValue()
+ inputParameters.get(3).getValue()
+ inputParameters.get(4).getValue()
+ queryParsed;
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
Object value = null;
if (dataFromCache != null) {
value = dataFromCache.getObjectValue();
// System.out.println("***GETTING DATA FROM CACHE");
}
if (value != null) {
result = (SubmitQueryResultWithFileFromServlet) value;
} else {
// create data structure
ComputationOutput outputData = new ComputationOutput();
@ -1056,16 +1032,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
String partialPathFile = applicationPath + "/computationResult/"
+ fileName;
result = new SubmitQueryResultWithFileFromServlet(
SubmitQueryResultWithFileFromServlet result = new SubmitQueryResultWithFileFromServlet(
listAttributes, convertedQuery, partialPathFile);
// put data in cache
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
key, result);
insertDataIntoCache(dataToCache);
}
return result;
} catch (Exception e) {
@ -2443,11 +2413,5 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
.getSession());
}
private String parseQuery(String query) {
String queryParsed;
queryParsed = query.trim();
queryParsed = queryParsed.replaceAll(" +", " ");
return queryParsed;
}
}