Luciano Ramalho avatar Luciano Ramalho committed 5e953cf

added first map/reduce views; both need refactoring, with functions to ease subfield access

Comments (0)

Files changed (5)

+#!/bin/bash
+
+PYTHONPATH=~/prj/isisdm/github/isisdm:$PYTHONPATH
+export PYTHONPATH
+
+#~/prj/isisdm/github/tools/isis2json.py -c -t 2 -i 2 \
+#         ~/prj/isisdm/github/fixtures/lilacs1/LILACS.iso \
+#  | curl -d @- -X POST http://localhost:5984/lilcouch/_bulk_docs -H"Content-Type: application/json"
+
+~/prj/isisdm/github/tools/isis2json.py -c -t 2 -i 2 -q 1000 \
+       ~/Dropbox/tcc/lilacs/data/lilacs2010-10-17/lilacs100k.iso \
+  | curl -d @- -X POST http://localhost:5984/lilcouch/_bulk_docs \
+      -H"Content-Type: application/json"

lilacs/views/affiliation/map.js

+function(doc) {
+    var occur, subf;
+    if (doc.hasOwnProperty('10')) {
+        for (occur=0; occur<doc['10'].length; occur++) {
+            for (subf=0; subf<doc['10'][occur].length; subf++) {
+                if (doc['10'][occur][subf][0] === '1') {
+                    emit(doc['10'][occur][subf][1], 1);
+                    break;
+                }
+            }
+        }
+    } else {
+        emit('??', 1);
+    }
+}

lilacs/views/affiliation/reduce.js

+function(keys, values, rereduce) {
+    return sum(values);
+}

lilacs/views/countries/map.js

+function(doc) {
+    if (doc.hasOwnProperty('67')) {
+        emit(doc['67'][0][0][1], 1);
+    } else {
+        emit('??', 1);
+    }
+}

lilacs/views/countries/reduce.js

+function(keys, values, rereduce) {
+    return sum(values);
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.