{"id":19839361,"url":"https://github.com/redislabs/rmr","last_synced_at":"2026-01-31T03:02:06.314Z","repository":{"id":141980784,"uuid":"73619410","full_name":"RedisLabs/rmr","owner":"RedisLabs","description":"POC Redis Module MapReduce operations","archived":false,"fork":false,"pushed_at":"2016-11-17T12:56:31.000Z","size":631,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-16T13:04:59.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedisLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-13T14:01:50.000Z","updated_at":"2016-11-25T16:57:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"1762fca7-7347-4781-9010-2f1b28b148d0","html_url":"https://github.com/RedisLabs/rmr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RedisLabs/rmr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisLabs%2Frmr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisLabs%2Frmr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisLabs%2Frmr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisLabs%2Frmr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedisLabs","download_url":"https://codeload.github.com/RedisLabs/rmr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedisLabs%2Frmr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28927769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T02:59:34.861Z","status":"ssl_error","status_checked_at":"2026-01-31T02:59:05.369Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T12:22:01.406Z","updated_at":"2026-01-31T03:02:06.298Z","avatar_url":"https://github.com/RedisLabs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LibRMR - RedisMapReduce\n\n## What?\n\nThis is a **Proof of Concept** of a library, that allows redis modules to communicate with nodes in a cluster in an asynchronous way. \n\nIt allows the same command to be fanned-out to all the nodes; or sending a list of commands, each to its relevant shard or node. \n\nIt loosely follows a map/reduce pattern, where each command executed is considered a \"map\" operation, and a \"reducer\" callback is responsible for merging the results. \nA reducer can reply to the client, *or trigger another map/reduce step*. \n\n## NOTE: \n\n\u003e **This is only a POC, and it only supports dummy cluster configuration and sharding. It works, but not really usable - just an example of how the API would work.** \n\n---\n\n## Why?\n\nThe idea is to be able to scale module logic across many nodes, where a merged result is sent to the client. \n\nFor example, let's say we have a search engine running on `N` redis instances. We can index `1/N` of our documents in each engine to scale it if more data is added. \n\nThen, when searching, we need to distribute the query to all nodes, and reduce the top N results from all nodes to a single list. \nRMR allows us to do it easily and abstracts the details of networking and threading. (it uses libuv and hiredis under the hood).\n\n## How?\n\nWhen loading the module, you need to initialize the RMR engine, and inject it with:\n\n1. A *NodeProvider* - an interface supplying the engine with a list of the cluster's node (and in the future slots and other state info).\n\n2. A *ShardFunc* - a callback that, given a list of nodes and a command's arguments, tells the engine which node/shard the command should be mapped to.\n\nAfter the engine is initialized, you can trigger MapReduce steps from any of the module's command handlers. Two sorts of operations are supported:\n\n1. *Map* - give the engine a list of commands, and it will execute each on its appropriate shard, and call a reducer with the results.\n\n2. *FanOut* - give the engine a single command, and it will execute it on ALL shards, and call a reducer with the results.\n\n## Example:\n\nThis SUM example takes a list of keys from the command arguments, performs GET on each key's appropriate shard, and reduces the result to a single sum (if they are numeric):\n\n1. Triggering the map operation in a command handler: \n\n```c\n/* RMR.SUM key key ... */\nint SumCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {\n\n  if (argc \u003c 2) return RedisModule_WrongArity(ctx);\n  \n  /* Create a list of commands to distribute */\n  MRCommand cmds[argc-1];\n  for (int i = 0; i \u003c argc - 1; i++) {\n    cmds[i] = MR_NewCommand(2, \"GET\", RedisModule_StringPtrLen(argv[i+1], NULL));\n  }\n\n  /* Create a new MapReduce context wrapping our redis context */\n  MRCtx *mc = MR_CreateCtx(ctx)\n\n  /* Trigger a Map operation for the commands, with a reducer callback */ \n  MR_Map(mc, sumReducer, cmds, argc-1);\n\n  return REDISMODULE_OK;\n}\n\n```\n\n2. Summing up the results in the reducer:\n\n(Note: `MRReply` is an abstraction built on hiredis reply objects, that has some convenience functions)\n\n```c\n/* A reducer that sums up numeric replies from a request */\nint sumReducer(struct MRCtx *mc, int count, MRReply **replies) {\n\n  /* Get the redis context saved in the MapReduce context */\n  RedisModuleCtx *ctx = MRCtx_GetPrivdata(mc);\n  long long sum = 0;\n  for (int i = 0; i \u003c count; i++) {\n    long long n = 0;\n    \n    /* a convenience function to extract an integer value from the reply if possible */\n    if (MRReply_ToInteger(replies[i], \u0026n)) {\n      sum += n;\n    }\n  }\n\n   return RedisModule_ReplyWithLongLong(ctx, sum);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredislabs%2Frmr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredislabs%2Frmr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredislabs%2Frmr/lists"}