private void createViewForSum ( Map < String , MapReduce > views ) { if ( views . get ( CouchDBConstants . SUM ) == null ) { MapReduce mapr = new MapReduce ( ) ; mapr . setMap ( "function(doc){for(field in doc){var o = doc[field];if(typeof(o)==\"number\")emit(field+\"_\"+doc." + CouchDBConstants . ENTITYNAME + ", o);}}" ) ; mapr . setReduce ( "function(keys, values){return sum(values);}" ) ; views . put ( CouchDBConstants . SUM , mapr ) ; } }
Creates the view for sum .