3.1.0 • Published 11 years ago

level-map-merge v3.1.0

Weekly downloads
9
License
-
Repository
github
Last release
11 years ago

level-map-merge

Like a simple realtime map-reduce, but simpler.

map-merge has two parts, a batch part, and a real-time part. the batch is run (say) every few hours, and the real-time part is run the rest of the time. The realtime map-merge can add things, but only the batch part can delete things.

map-merge is suitable for situations where it's okay to have slightly old or incorrect data, like an inverted index!

The included ./example.js builds a full text index for the npm registry is about ~1.5 minutes.

Example

Inverted Index (word -> list of documents it appears in)

See also ./example.js

var LevelMapMerge = require('level-map-merge')
var LevelUp       = require('levelup')

var db = LevelUp()
LevelMapMerge(db, {
  json:true, 
  map: function (key, val, emit) {
    val.split(/\W+/).forEach(function (e) {
      emit(e, [key])
    })
  },
  merge: function (big, little, key) {
    little.forEach(function (e) {
      if(-1 == big.indexOf(e))
        big.push(e)
    })
    return big
  }
}

Licence

MIT

3.1.0

11 years ago

3.0.1

11 years ago

3.0.0

11 years ago

2.0.1

11 years ago

2.0.0

11 years ago

1.0.0

11 years ago