git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics-persistence-couchbase@144524 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
65cf7ce332
commit
3d702a9b3a
|
@ -402,8 +402,39 @@ AccountingPersistenceBackendQuery {
|
|||
}
|
||||
return reduceFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a name of map-reduce view
|
||||
* @param collection
|
||||
* @return
|
||||
*/
|
||||
public static String getMapReduceFunctionNameTopMap(
|
||||
String top, Collection<String> collection) {
|
||||
logger.debug("top:{}",top);
|
||||
logger.debug("collection:{}",collection.toString());
|
||||
|
||||
String reduceFunction = MAP_REDUCE_ALL;
|
||||
|
||||
if (!collection.isEmpty()){
|
||||
reduceFunction = top;
|
||||
//reduceFunction = null;
|
||||
for (String property : collection) {
|
||||
if (!property.equals(top)){
|
||||
|
||||
if (reduceFunction == null) {
|
||||
reduceFunction = property;
|
||||
} else {
|
||||
reduceFunction = reduceFunction + KEYS_SEPARATOR + property;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reduceFunction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**EXPERIMENTAL
|
||||
/**EXPERIMENTAL DEPRECATED
|
||||
* generate a name of design doc id for a top
|
||||
* @param collection
|
||||
* @return
|
||||
|
@ -866,8 +897,9 @@ AccountingPersistenceBackendQuery {
|
|||
return false;
|
||||
}
|
||||
logger.debug("usingNextPossibleValuesWithMap complete key and name");
|
||||
String viewName=getMapReduceFunctionName(keys);
|
||||
String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||
String viewName=getMapReduceFunctionNameTopMap(topKey,keys);
|
||||
//String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||
String designDocId =DESIGN_DOC_ID+topKey;
|
||||
|
||||
|
||||
BucketManager bucketManager = connectionMap.get(clz.getSimpleName()).bucketManager();
|
||||
|
@ -1035,8 +1067,9 @@ AccountingPersistenceBackendQuery {
|
|||
}
|
||||
count++;
|
||||
}
|
||||
String viewName = getMapReduceFunctionName(keys);
|
||||
String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||
String viewName = getMapReduceFunctionNameTopMap(key,keys);
|
||||
//String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||
String designDocId =DESIGN_DOC_ID+key;
|
||||
logger.trace("keys:{}",keys.toString());
|
||||
ViewQuery query = ViewQuery.from(designDocId, viewName);
|
||||
query.inclusiveEnd();
|
||||
|
|
|
@ -86,7 +86,8 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
|||
public void before() throws Exception{
|
||||
|
||||
//ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
ScopeProvider.instance.set("/gcube/devNext");
|
||||
//ScopeProvider.instance.set("/gcube/devNext");
|
||||
ScopeProvider.instance.set("/gcube");
|
||||
|
||||
AccountingPersistenceBackendQueryConfiguration configuration = new
|
||||
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
|
||||
|
@ -348,7 +349,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
|||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
||||
accountingPersistenceQueryCouchBase.getTopValues(
|
||||
clz, temporalConstraint, filters,
|
||||
AggregatedServiceUsageRecord.CALLER_HOST, null);
|
||||
AggregatedServiceUsageRecord.OPERATION_RESULT, null);
|
||||
|
||||
logger.debug("Result final{}", set);
|
||||
|
||||
|
@ -357,13 +358,13 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
|||
@Test
|
||||
public void testTopStorage() throws Exception {
|
||||
Calendar startTime = Calendar.getInstance();
|
||||
startTime.set(2016, Calendar.AUGUST, 27);
|
||||
startTime.set(2017, Calendar.FEBRUARY, 1);
|
||||
Calendar endTime = Calendar.getInstance();
|
||||
endTime.set(2016, Calendar.SEPTEMBER, 28,23,59);
|
||||
endTime.set(2017, Calendar.FEBRUARY, 28,23,59);
|
||||
|
||||
|
||||
List<Filter> filters = new ArrayList<Filter>();
|
||||
|
||||
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "scarponi"));
|
||||
TemporalConstraint temporalConstraint =
|
||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||
|
@ -374,7 +375,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
|||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
||||
accountingPersistenceQueryCouchBase.getTopValues(
|
||||
clz, temporalConstraint, filters,
|
||||
AggregatedStorageUsageRecord.CONSUMER_ID, null);
|
||||
AggregatedStorageUsageRecord.OPERATION_TYPE, null);
|
||||
|
||||
logger.debug("Result final{}", set);
|
||||
|
||||
|
|
Reference in New Issue