{
  "id": "asyncmap",
  "title": "AsyncMap",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsbuilder/asyncmap/",
  "summary": "Asynchronously maps records one-to-one.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "c50c40a347252212b7a6cc6f5cb9719cb9490f47e4e3d09d615a99a3a11b0af9",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "[code example]\n\nThe `asyncMap` function allows you to use a [`GearsFuture`](https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsfuture) object to asynchronously map each input record in the pipe to an output record, one-to-one."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "Type parameters:\n\n| Name | Description |\n|------|-------------|\n| I | The template type of the returned builder |\n\nFunction parameters:\n\n| Name | Type | Description |\n|------|------|-------------|\n| mapper | <nobr>AsyncMapOperation<T,​I></nobr> | For each input record, returns a new output record |"
    },
    {
      "id": "returns",
      "title": "Returns",
      "role": "returns",
      "text": "Returns a GearsBuilder object with a new template type."
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "java",
      "code": "public <I extends java.io.Serializable> GearsBuilder<I> asyncMap​(\n\tgears.operations.AsyncMapOperation<T,​I> mapper)",
      "section_id": "overview"
    },
    {
      "id": "example-ex0",
      "language": "java",
      "code": "GearsBuilder.CreateGearsBuilder(reader).\n\tasyncMap(r->{\n\t\tGearsFuture<String> f = new GearsFuture<String>();\n\t\tnew Thread(new Runnable() {\n\t\t\t\t\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1);\n\t\t\t\t\t\n\t\t\t\t\tf.setResult(\"done\");\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\t\t\t\t\t\n\t\t\t}\n\t\t}).start();\n\t\treturn f;\n});",
      "section_id": "example"
    }
  ]
}
