From 1bcf79b25911a48640a4b40146a396706a6db263 Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Tue, 9 May 2023 16:05:04 +0800 Subject: [PATCH 1/4] Add CPP client table view doc. --- docs/client-libraries-tableviews.md | 105 +++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 18 deletions(-) diff --git a/docs/client-libraries-tableviews.md b/docs/client-libraries-tableviews.md index 5ac0efbab113..e806e046902e 100644 --- a/docs/client-libraries-tableviews.md +++ b/docs/client-libraries-tableviews.md @@ -4,25 +4,68 @@ title: Work with TableView sidebar_label: "Work with TableView" --- +````mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +```` + After setting up your clients, you can explore more to start working with [TableView](concepts-clients.md#tableview). ## Configure TableView -The following is an example of how to configure a TableView. -```java -TableView tv = client.newTableViewBuilder(Schema.STRING) - .topic("my-tableview") - .create() -``` +````mdx-code-block + + + + The following is an example of how to configure a TableView. + ```java + TableView tv = client.newTableViewBuilder(Schema.STRING) + .topic("my-tableview") + .create() + ``` + + You can use the available parameters in the `loadConf` configuration or related [API](/api/client/2.10.0-SNAPSHOT/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. + + | Name | Type| Required? |
Description
| Default + |---|---|---|---|--- + | `topic` | string | yes | The topic name of the TableView. | N/A + | `autoUpdatePartitionInterval` | int | no | The interval to check for newly added partitions. | 60 (seconds) + | `subscriptionName` | string | no | The subscription name of the TableView. | null + +
+ + + + + This feature is supported in C++ client 3.2.0 or later versions. + + + ```cpp + ClientConfiguration clientConfiguration; + clientConfiguration.setPartititionsUpdateInterval(100); + Client client("pulsar://localhost:6650", clientConfiguration); + TableViewConfiguration tableViewConfiguration{schemaInfo, "test-subscription-name"}; + TableView tableView; + client.createTableView("my-tableview", tableViewConfiguration, tableView) + ``` + + You can use the available parameters to customize your TableView. + + | Name | Type| Required? |
Description
| Default + |---|---|---|---|--- + | `topic` | string | yes | The topic name of the TableView. | N/A + | `schemaInfo` | struct | no | Declare the schema of the data that this table view will be accepting. The schema will be checked against the schema of the topic, and the table view creation will fail if it's not compatible. | N/A + | `subscriptionName` | string | no | The subscription name of the TableView. | reader-{random string} + | `partititionsUpdateInterval` | int | no | Topic partitions update interval in seconds. In **C++ client**, `partititionsUpdateInterval` is global within the same client. | 60 -You can use the available parameters in the `loadConf` configuration or related [API](/api/client/2.10.0-SNAPSHOT/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. -| Name | Type| Required? |
Description
| Default -|---|---|---|---|--- -| `topic` | string | yes | The topic name of the TableView. | N/A -| `autoUpdatePartitionInterval` | int | no | The interval to check for newly added partitions. | 60 (seconds) -| `subscriptionName` | string | no | The subscription name of the TableView. | null +
+ +
+```` ## Register listeners @@ -30,10 +73,36 @@ You can register listeners for both existing messages on a topic and new message The following is an example of how to register listeners with TableView. -```java -// Register listeners for all existing and incoming messages -tv.forEachAndListen((key, value) -> /*operations on all existing and incoming messages*/) -// Register action for all existing messages -tv.forEach((key, value) -> /*operations on all existing messages*/) -``` +````mdx-code-block + + + + + ```java + // Register listeners for all existing and incoming messages + tv.forEachAndListen((key, value) -> /*operations on all existing and incoming messages*/) + + // Register action for all existing messages + tv.forEach((key, value) -> /*operations on all existing messages*/) + ``` + + + + + + + ```cpp + // Register listeners for all existing and incoming messages + tableView.forEach([](const std::string& key, const std::string& value) {}); + + // Register action for all existing messages + tableView.forEachAndListen([](const std::string& key, const std::string& value) {}); + ``` + + + + +```` \ No newline at end of file From 31e9c410fde7806f37fc0cae754bfedfce0f3241 Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Tue, 9 May 2023 18:42:32 +0800 Subject: [PATCH 2/4] Update docs/client-libraries-tableviews.md Co-authored-by: Jun Ma <60642177+momo-jun@users.noreply.github.com> --- docs/client-libraries-tableviews.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/client-libraries-tableviews.md b/docs/client-libraries-tableviews.md index e806e046902e..2e1de4c11bb2 100644 --- a/docs/client-libraries-tableviews.md +++ b/docs/client-libraries-tableviews.md @@ -57,7 +57,7 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> | Name | Type| Required? |
Description
| Default |---|---|---|---|--- | `topic` | string | yes | The topic name of the TableView. | N/A - | `schemaInfo` | struct | no | Declare the schema of the data that this table view will be accepting. The schema will be checked against the schema of the topic, and the table view creation will fail if it's not compatible. | N/A + | `schemaInfo` | struct | no | Declare the schema of the data that this TableView can accept. The schema will be checked against the schema of the topic, and the TableView creation will fail if it's incompatible. | N/A | `subscriptionName` | string | no | The subscription name of the TableView. | reader-{random string} | `partititionsUpdateInterval` | int | no | Topic partitions update interval in seconds. In **C++ client**, `partititionsUpdateInterval` is global within the same client. | 60 From 06cefc1501a9b04d328140b62a40028ba9af4362 Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Wed, 10 May 2023 10:07:42 +0800 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Anonymitaet <50226895+Anonymitaet@users.noreply.github.com> --- docs/client-libraries-tableviews.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/client-libraries-tableviews.md b/docs/client-libraries-tableviews.md index 2e1de4c11bb2..936e24752e17 100644 --- a/docs/client-libraries-tableviews.md +++ b/docs/client-libraries-tableviews.md @@ -21,13 +21,14 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> The following is an example of how to configure a TableView. + ```java TableView tv = client.newTableViewBuilder(Schema.STRING) .topic("my-tableview") .create() ``` - You can use the available parameters in the `loadConf` configuration or related [API](/api/client/2.10.0-SNAPSHOT/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. +You can use the available parameters in the `loadConf` configuration or the API [`TableViewBuilder`](/api/client/@pulsar:version_number@/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. | Name | Type| Required? |
Description
| Default |---|---|---|---|--- @@ -52,14 +53,14 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> client.createTableView("my-tableview", tableViewConfiguration, tableView) ``` - You can use the available parameters to customize your TableView. + You can use the following parameters to customize your TableView. | Name | Type| Required? |
Description
| Default |---|---|---|---|--- | `topic` | string | yes | The topic name of the TableView. | N/A - | `schemaInfo` | struct | no | Declare the schema of the data that this TableView can accept. The schema will be checked against the schema of the topic, and the TableView creation will fail if it's incompatible. | N/A + | `schemaInfo` | struct | no | Declare the schema of the data that this TableView can accept. The schema is checked against the schema of the topic, and the TableView creation fails if it's incompatible. | N/A | `subscriptionName` | string | no | The subscription name of the TableView. | reader-{random string} - | `partititionsUpdateInterval` | int | no | Topic partitions update interval in seconds. In **C++ client**, `partititionsUpdateInterval` is global within the same client. | 60 + | `partititionsUpdateInterval` | int | no | Topic partitions update interval in seconds. In the C++ client, `partititionsUpdateInterval` is global within the same client. | 60
@@ -85,7 +86,7 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> // Register listeners for all existing and incoming messages tv.forEachAndListen((key, value) -> /*operations on all existing and incoming messages*/) - // Register action for all existing messages + // Register actions for all existing messages tv.forEach((key, value) -> /*operations on all existing messages*/) ``` @@ -98,7 +99,7 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> // Register listeners for all existing and incoming messages tableView.forEach([](const std::string& key, const std::string& value) {}); - // Register action for all existing messages + // Register actions for all existing messages tableView.forEachAndListen([](const std::string& key, const std::string& value) {}); ``` From 15b5d6b08d66cadaeaeeda1b565afe86f400e3dd Mon Sep 17 00:00:00 2001 From: Baodi Shi Date: Tue, 16 May 2023 10:33:22 +0800 Subject: [PATCH 4/4] Update docs/client-libraries-tableviews.md Co-authored-by: tison --- docs/client-libraries-tableviews.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/client-libraries-tableviews.md b/docs/client-libraries-tableviews.md index 936e24752e17..6fa32e31081d 100644 --- a/docs/client-libraries-tableviews.md +++ b/docs/client-libraries-tableviews.md @@ -28,7 +28,7 @@ values={[{"label":"Java","value":"Java"},{"label":"C++","value":"C++"}]}> .create() ``` -You can use the available parameters in the `loadConf` configuration or the API [`TableViewBuilder`](/api/client/@pulsar:version_number@/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. +You can use the available parameters in the `loadConf` configuration or the API [`TableViewBuilder`](/api/client/org/apache/pulsar/client/api/TableViewBuilder.html) to customize your TableView. | Name | Type| Required? |
Description
| Default |---|---|---|---|---