From 64f019bbd84423c96e497a8a7a3e3521efe2a6fd Mon Sep 17 00:00:00 2001 From: Yiran Date: Wed, 25 Dec 2024 15:35:50 +0800 Subject: [PATCH] add Java code --- docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md | 2 +- docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md | 8 ++++++-- .../user-guide/ingest-data/for-iot/grpc-sdks/go.md | 2 +- .../user-guide/ingest-data/for-iot/grpc-sdks/java.md | 9 +++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md b/docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md index cb05d6946..8e7589dd0 100644 --- a/docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md +++ b/docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md @@ -77,7 +77,7 @@ hints := []*ingesterContext.Hint{ ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) ctx = ingesterContext.New(ctx, ingesterContext.WithHints(hints)) // Use the ingesterContext when writing data to GreptimeDB. -// The data object is described in the following sections. +// The `data` object is described in the following sections. resp, err := c.client.Write(ctx, data) if err != nil { return err diff --git a/docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md b/docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md index 9087dfc98..bb58a6119 100644 --- a/docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md +++ b/docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md @@ -85,11 +85,15 @@ For customizing the connection options, please refer to [API Documentation](#ing
-You can set table options using the `ingesterContext` context. +You can set table options using the `Context`. For example, to set the `ttl` option, use the following code: ```java -TODO +Context ctx = Context.newDefault(); +ctx.withHint("ttl", "3d"); +// Use the ctx when writing data to GreptimeDB +// The data object `cpuMetric` and `memMetric` are described in the following sections +CompletableFuture> future = greptimeDB.write(Arrays.asList(cpuMetric, memMetric), WriteOp.Insert, ctx); ```
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/go.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/go.md index ba2543c24..803e45f43 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/go.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/go.md @@ -76,7 +76,7 @@ hints := []*ingesterContext.Hint{ ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) ctx = ingesterContext.New(ctx, ingesterContext.WithHints(hints)) // 使用 ingesterContext写入数据到 GreptimeDB -// data 对象在之后的章节中描述 +// `data` 对象在之后的章节中描述 resp, err := c.client.Write(ctx, data) if err != nil { return err diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/java.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/java.md index d836d100d..7a538124e 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/java.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/grpc-sdks/java.md @@ -82,10 +82,15 @@ GreptimeDB client = GreptimeDB.create(opts);
-你可以 +你可以使用 `Context` 设置表选项。 +例如,使用以下代码设置 `ttl` 选项: ```java -TODO +Context ctx = Context.newDefault(); +ctx.withHint("ttl", "3d"); +// 使用 ctx 对象写入数据 +// `cpuMetric` 和 `memMetric` 是定义的数据对象,之后的章节中有详细描述 +CompletableFuture> future = greptimeDB.write(Arrays.asList(cpuMetric, memMetric), WriteOp.Insert, ctx); ```