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
|
@ -403,7 +403,38 @@ AccountingPersistenceBackendQuery {
|
||||||
return reduceFunction;
|
return reduceFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**EXPERIMENTAL
|
/**
|
||||||
|
* 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 DEPRECATED
|
||||||
* generate a name of design doc id for a top
|
* generate a name of design doc id for a top
|
||||||
* @param collection
|
* @param collection
|
||||||
* @return
|
* @return
|
||||||
|
@ -866,8 +897,9 @@ AccountingPersistenceBackendQuery {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logger.debug("usingNextPossibleValuesWithMap complete key and name");
|
logger.debug("usingNextPossibleValuesWithMap complete key and name");
|
||||||
String viewName=getMapReduceFunctionName(keys);
|
String viewName=getMapReduceFunctionNameTopMap(topKey,keys);
|
||||||
String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
//String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||||
|
String designDocId =DESIGN_DOC_ID+topKey;
|
||||||
|
|
||||||
|
|
||||||
BucketManager bucketManager = connectionMap.get(clz.getSimpleName()).bucketManager();
|
BucketManager bucketManager = connectionMap.get(clz.getSimpleName()).bucketManager();
|
||||||
|
@ -1035,8 +1067,9 @@ AccountingPersistenceBackendQuery {
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
String viewName = getMapReduceFunctionName(keys);
|
String viewName = getMapReduceFunctionNameTopMap(key,keys);
|
||||||
String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
//String designDocId =DESIGN_DOC_ID+getDesignDocIdName(keys);
|
||||||
|
String designDocId =DESIGN_DOC_ID+key;
|
||||||
logger.trace("keys:{}",keys.toString());
|
logger.trace("keys:{}",keys.toString());
|
||||||
ViewQuery query = ViewQuery.from(designDocId, viewName);
|
ViewQuery query = ViewQuery.from(designDocId, viewName);
|
||||||
query.inclusiveEnd();
|
query.inclusiveEnd();
|
||||||
|
|
|
@ -86,7 +86,8 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
||||||
public void before() throws Exception{
|
public void before() throws Exception{
|
||||||
|
|
||||||
//ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
//ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
ScopeProvider.instance.set("/gcube/devNext");
|
//ScopeProvider.instance.set("/gcube/devNext");
|
||||||
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
|
||||||
AccountingPersistenceBackendQueryConfiguration configuration = new
|
AccountingPersistenceBackendQueryConfiguration configuration = new
|
||||||
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
|
AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchBase.class);
|
||||||
|
@ -348,7 +349,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
accountingPersistenceQueryCouchBase.getTopValues(
|
||||||
clz, temporalConstraint, filters,
|
clz, temporalConstraint, filters,
|
||||||
AggregatedServiceUsageRecord.CALLER_HOST, null);
|
AggregatedServiceUsageRecord.OPERATION_RESULT, null);
|
||||||
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
|
|
||||||
|
@ -357,13 +358,13 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTopStorage() throws Exception {
|
public void testTopStorage() throws Exception {
|
||||||
Calendar startTime = Calendar.getInstance();
|
Calendar startTime = Calendar.getInstance();
|
||||||
startTime.set(2016, Calendar.AUGUST, 27);
|
startTime.set(2017, Calendar.FEBRUARY, 1);
|
||||||
Calendar endTime = Calendar.getInstance();
|
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>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
|
filters.add(new Filter(AggregatedServiceUsageRecord.CONSUMER_ID, "scarponi"));
|
||||||
TemporalConstraint temporalConstraint =
|
TemporalConstraint temporalConstraint =
|
||||||
new TemporalConstraint(startTime.getTimeInMillis(),
|
new TemporalConstraint(startTime.getTimeInMillis(),
|
||||||
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
endTime.getTimeInMillis(), AggregationMode.DAILY);
|
||||||
|
@ -374,7 +375,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
|
||||||
accountingPersistenceQueryCouchBase.getTopValues(
|
accountingPersistenceQueryCouchBase.getTopValues(
|
||||||
clz, temporalConstraint, filters,
|
clz, temporalConstraint, filters,
|
||||||
AggregatedStorageUsageRecord.CONSUMER_ID, null);
|
AggregatedStorageUsageRecord.OPERATION_TYPE, null);
|
||||||
|
|
||||||
logger.debug("Result final{}", set);
|
logger.debug("Result final{}", set);
|
||||||
|
|
||||||
|
|
Reference in New Issue