wangtianyi2004 commented on code in PR #2071:
URL: https://github.com/apache/doris-website/pull/2071#discussion_r1964887700


##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/dictionary.md:
##########
@@ -0,0 +1,433 @@
+---
+{
+    "title": "字典表(实验性功能)",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## 概述
+
+字典表(Dictionary)是 Doris 提供的一种用于加速 JOIN 
操作的特殊数据结构。它通过将常用的键值对预先加载到内存中,实现快速的查找操作,从而提升查询性能。字典表特别适用于需要频繁进行键值查找的场景。

Review Comment:
   可以加上一句与基表的关系。



##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/dictionary.md:
##########
@@ -0,0 +1,433 @@
+---
+{
+    "title": "字典表(实验性功能)",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## 概述
+
+字典表(Dictionary)是 Doris 提供的一种用于加速 JOIN 
操作的特殊数据结构。它通过将常用的键值对预先加载到内存中,实现快速的查找操作,从而提升查询性能。字典表特别适用于需要频繁进行键值查找的场景。
+
+## 使用场景
+
+字典表主要适用于以下场景:
+
+1. 需要频繁进行键值查找的场景
+2. 维度表较小,可以完全加载到内存中
+3. 数据更新频率相对较低的场景
+4. 需要优化 JOIN 操作性能的场景
+
+## 字典表定义
+
+### 基本语法
+
+```sql
+CREATE DICTIONARY <dict_name> USING <source_table>
+(
+    <key_column> KEY[,
+    ...,
+    <key_columns> VALUE]
+    <value_column> VALUE[,
+    ...,
+    <value_columns> VALUE]
+)
+LAYOUT(<layout_type>)
+PROPERTIES(
+    "<priority_item_key>" = "<priority_item_value>"[,
+    ...,
+    "<priority_item_key>" = "<priority_item_value>"]
+);
+```
+
+其中:
+
+- `<dict_name>`:字典表的名字
+- `<source_table>`:源数据表
+- `<key_column>`:作为键的列在源表中的列名
+- `<value_column>`:作为值的列在源表中的列名
+- `<layout_type>`:字典表的存储布局类型,详见后文。
+- `<priority_item_key>`:表的某项属性名
+- `<priority_item_value>`:表的某项属性取值
+
+`<key_column>` 不必出现在 `<value_column>` 前。
+
+### 布局类型
+
+目前支持两种布局类型:
+
+- `HASH_MAP`:基于哈希表的实现,适用于一般的键值查找场景
+- `IP_TRIE`:基于 Trie 树的实现,专门优化用于 IP 地址类型的查找。Key 列需要为 CIDR 表示法表示的 IP 地址,查询时依 
CIDR 表示法匹配。
+
+### 属性
+
+|属性名|值类型|含义|必须项|
+|-|-|-|-|
+|`date_lifetime`|整数,单位为秒|数据有效期。当该字典上次更新距今时间超过该值时,将会自动发起重新导入|是|
+|`skip_null_key`|布尔值|向字典导入时如果 Key 列中出现 null 值,如果该值为 `true`,跳过该行数据,否则报错。缺省值为 
`false`|否|
+
+### 示例
+
+```sql
+-- 创建源数据表
+CREATE TABLE source_table (
+    id INT NOT NULL,
+    city VARCHAR(32) NOT NULL,
+    code VARCHAR(32) NOT NULL
+) ENGINE=OLAP
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES("replication_num" = "1");
+
+-- 创建字典表
+CREATE DICTIONARY city_dict USING source_table
+(
+    city KEY,
+    id VALUE
+)
+LAYOUT(HASH_MAP)
+PROPERTIES('data_lifetime' = '600');
+```
+
+基于该表,我们可以使用字典 `city_dict` 通过 `dict_get` 函数,基于 `source_table` 的 `city` 值查询对应的 
`id`。
+
+### 使用限制
+
+1. Key 列
+
+   - IP_TRIE 类型字典的 Key 列必须为 Varchar 或 String 类型,**Key 列中的值必须为 CIDR 格式**。
+   - HASH_MAP 类型字典的 Key 列支持所有简单类型(即排除所有 Map、Array 等嵌套类型)。
+   - 作为 Key 列的列,**在源表中不得存在重复值**,否则字典导入数据时将报错。
+
+2. Null 值处理
+
+   - 字典的所有列都可以是 Nullable 列,但 Key 列不应当实际出现 null 值。如果出现,行为取决于[属性](#属性)当中的 
`skip_null_key`。
+
+## 使用与管理
+
+### 导入(刷新)数据
+
+字典支持自动与手动导入。
+
+#### 自动导入
+
+自动导入发生在以下时机:
+
+1. 字典建立以后
+2. 字典数据过期时(见[属性](#属性))
+3. BE 状态显示丢失该字典数据(有新 BE 上线,或旧 BE 重启等均有可能造成)
+
+#### 手动导入
+
+Doris 支持通过以下命令手动刷新字典的数据:
+
+```sql
+REFRESH DICTIONARY <dict_name>;
+```
+
+其中 `<dict_name>` 为要导入数据的字典名。
+
+#### 导入注意事项
+
+1. 只有导入数据后的字典才可以查询。
+2. 如果导入时 Key 列具有重复值,导入事务会失败。
+3. 如果导入的数据版本早于 BE 已有的版本,则事务会失败。

Review Comment:
   这个注意事项,用户需要通过什么行为避免



##########
i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/dictionary.md:
##########
@@ -0,0 +1,433 @@
+---
+{
+    "title": "字典表(实验性功能)",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+  http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## 概述
+
+字典表(Dictionary)是 Doris 提供的一种用于加速 JOIN 
操作的特殊数据结构。它通过将常用的键值对预先加载到内存中,实现快速的查找操作,从而提升查询性能。字典表特别适用于需要频繁进行键值查找的场景。
+
+## 使用场景
+
+字典表主要适用于以下场景:
+
+1. 需要频繁进行键值查找的场景
+2. 维度表较小,可以完全加载到内存中
+3. 数据更新频率相对较低的场景
+4. 需要优化 JOIN 操作性能的场景
+
+## 字典表定义
+
+### 基本语法
+
+```sql
+CREATE DICTIONARY <dict_name> USING <source_table>
+(
+    <key_column> KEY[,
+    ...,
+    <key_columns> VALUE]
+    <value_column> VALUE[,
+    ...,
+    <value_columns> VALUE]
+)
+LAYOUT(<layout_type>)
+PROPERTIES(
+    "<priority_item_key>" = "<priority_item_value>"[,
+    ...,
+    "<priority_item_key>" = "<priority_item_value>"]
+);
+```
+
+其中:
+
+- `<dict_name>`:字典表的名字
+- `<source_table>`:源数据表
+- `<key_column>`:作为键的列在源表中的列名
+- `<value_column>`:作为值的列在源表中的列名
+- `<layout_type>`:字典表的存储布局类型,详见后文。
+- `<priority_item_key>`:表的某项属性名
+- `<priority_item_value>`:表的某项属性取值
+
+`<key_column>` 不必出现在 `<value_column>` 前。
+
+### 布局类型
+
+目前支持两种布局类型:
+
+- `HASH_MAP`:基于哈希表的实现,适用于一般的键值查找场景
+- `IP_TRIE`:基于 Trie 树的实现,专门优化用于 IP 地址类型的查找。Key 列需要为 CIDR 表示法表示的 IP 地址,查询时依 
CIDR 表示法匹配。
+
+### 属性
+
+|属性名|值类型|含义|必须项|
+|-|-|-|-|
+|`date_lifetime`|整数,单位为秒|数据有效期。当该字典上次更新距今时间超过该值时,将会自动发起重新导入|是|
+|`skip_null_key`|布尔值|向字典导入时如果 Key 列中出现 null 值,如果该值为 `true`,跳过该行数据,否则报错。缺省值为 
`false`|否|
+
+### 示例
+
+```sql
+-- 创建源数据表
+CREATE TABLE source_table (
+    id INT NOT NULL,
+    city VARCHAR(32) NOT NULL,
+    code VARCHAR(32) NOT NULL
+) ENGINE=OLAP
+DISTRIBUTED BY HASH(id) BUCKETS 1
+PROPERTIES("replication_num" = "1");
+
+-- 创建字典表
+CREATE DICTIONARY city_dict USING source_table
+(
+    city KEY,
+    id VALUE
+)
+LAYOUT(HASH_MAP)
+PROPERTIES('data_lifetime' = '600');
+```
+
+基于该表,我们可以使用字典 `city_dict` 通过 `dict_get` 函数,基于 `source_table` 的 `city` 值查询对应的 
`id`。
+
+### 使用限制
+
+1. Key 列
+
+   - IP_TRIE 类型字典的 Key 列必须为 Varchar 或 String 类型,**Key 列中的值必须为 CIDR 格式**。
+   - HASH_MAP 类型字典的 Key 列支持所有简单类型(即排除所有 Map、Array 等嵌套类型)。
+   - 作为 Key 列的列,**在源表中不得存在重复值**,否则字典导入数据时将报错。
+
+2. Null 值处理
+
+   - 字典的所有列都可以是 Nullable 列,但 Key 列不应当实际出现 null 值。如果出现,行为取决于[属性](#属性)当中的 
`skip_null_key`。
+
+## 使用与管理
+
+### 导入(刷新)数据
+
+字典支持自动与手动导入。
+
+#### 自动导入
+
+自动导入发生在以下时机:
+
+1. 字典建立以后
+2. 字典数据过期时(见[属性](#属性))
+3. BE 状态显示丢失该字典数据(有新 BE 上线,或旧 BE 重启等均有可能造成)
+
+#### 手动导入
+
+Doris 支持通过以下命令手动刷新字典的数据:
+
+```sql
+REFRESH DICTIONARY <dict_name>;
+```
+
+其中 `<dict_name>` 为要导入数据的字典名。
+
+#### 导入注意事项
+
+1. 只有导入数据后的字典才可以查询。
+2. 如果导入时 Key 列具有重复值,导入事务会失败。

Review Comment:
   这一句是啥意思,为什么 key 列会重复。dup 表不能创建字典?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to