{"id":13508982,"url":"https://github.com/kbrw/adap","last_synced_at":"2025-04-29T09:31:04.603Z","repository":{"id":30517420,"uuid":"34071899","full_name":"kbrw/adap","owner":"kbrw","description":"Create a data stream across your information systems to query, augment and transform data according to Elixir matching rules.","archived":false,"fork":false,"pushed_at":"2017-05-22T16:19:34.000Z","size":11,"stargazers_count":16,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-05T14:34:52.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbrw.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}},"created_at":"2015-04-16T18:02:48.000Z","updated_at":"2023-12-10T03:25:36.000Z","dependencies_parsed_at":"2022-07-24T16:47:17.220Z","dependency_job_id":null,"html_url":"https://github.com/kbrw/adap","commit_stats":null,"previous_names":["awetzel/adap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrw%2Fadap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrw%2Fadap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrw%2Fadap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrw%2Fadap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbrw","download_url":"https://codeload.github.com/kbrw/adap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251473200,"owners_count":21595023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-08-01T02:01:01.314Z","updated_at":"2025-04-29T09:31:04.289Z","avatar_url":"https://github.com/kbrw.png","language":"Elixir","funding_links":[],"categories":["Queue"],"sub_categories":[],"readme":"# ADAP\n## Awesome (big) Data Augmentation Pipeline\n\nCreate a data stream across your information systems to query,\naugment and transform data according to Elixir matching rules.\n\n[![Build Status](https://travis-ci.org/kbrw/adap.svg?branch=master)](https://travis-ci.org/kbrw/adap)\n\nSee the [generated documentation](http://hexdocs.pm/adap) for more detailed explanations.\n\nThe principle is:\n\n- to make each element hop from node to node in order to be processed\n  using the locally present data.\n- that any node at any time can emit new elements in the pipeline stream\n- to construct processing units on each node on demand. They can die at any time\n  to free memory or because of an exception: they will be restarted on demand. \n- to pull elements by chunk in order to allow long processing time\n  without the need of any back-pressure mechanism.\n\nLet's see a processing pipe example: \n\n- the input is a product stream : stream of `{:product,%{field1: value1, field2: value2}}`\n- `user@jsonserver1` contains a json file \"/color.json\" containing a COLOR mapping\n- `user@jsonserver2` contains a json file \"/size.json\" containing a SIZE mapping \n- you want to map product color and size according to these mappings\n- you want to add a field \"deleted\" when the mapped color is red\n\n```elixir\nAdap.Piper.defpipe ColorPipe, [{ColorPipe.Rules,[]}]\ndefmodule JSONMap do\n  use Adap.Unit.Simple, ttl: 1_000\n  def init(mapping), do: \n    {:ok,File.read!(\"/#{mapping}.json\") |\u003e JSON.decode!}\n  def node(\"color\"), do: :\"user@jsonserver1\"\n  def node(\"size\"), do: :\"user@jsonserver2\"\nend\ndefmodule ColorPipe.Rules do\n  use Adap.Piper, for: :product\n  defrule map_color(%{color: color}=prod,_) do\n    {JSONMap,\"color\"},color_map-\u003e\n      %{prod| color: color_map[color]}\n  end\n  defrule map_size(%{size: size}=prod,_) do\n    {JSONMap,\"size\"},size_map-\u003e\n      %{prod| size: size_map[size]}\n  end\n  defrule red_is_deleted(%{color: \"red\"}=prod,_) do\n    Dict.put(prod,:deleted,true)\n  end\nend\nresult = [\n  {:product,%{gender: \"male\", category: \"ipad\"}},\n  {:product,%{color: \"carmine\", category: \"shirt\"}},\n  {:product,%{color: \"periwinkle\", size: \"xxl\"}}\n] |\u003e Adap.Stream.new(ColorPipe) |\u003e Enum.to_list\nassert result == [\n  {:product,%{gender: \"male\", category: \"ipad\"}},\n  {:product,%{color: \"red\", category: \"shirt\", deleted: true}},\n  {:product,%{color: \"blue\", size: \"large\"}}\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrw%2Fadap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbrw%2Fadap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrw%2Fadap/lists"}