Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/query-data/udf/java-user-defined-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,13 @@ The BE caches JARs globally and supports a customizable expiration time. Add the
| `static_load` | Whether to use the static cache loading method | `false` |
| `expiration_time` | JAR expiration time, in minutes | `360` |

- `expiration_time` will be removed after 4.1.1 version。

How it works:

- After static cache loading is enabled, the UDF instance is cached after initialization completes on the first call.
- On subsequent calls to the UDF, the cache is checked first; if there is a miss, the relevant initialization is executed.
- A background thread checks periodically. If the UDF has not been called within the configured expiration time, it is cleared from the cache.
- If the UDF is called again before expiration, the cache timestamp is automatically refreshed.
- When Drop Function, it's will be cleared from the cache.

Example code:

Expand All @@ -570,8 +571,7 @@ PROPERTIES (
"symbol" = "org.apache.doris.udf.Print",
"always_nullable"="true",
"type" = "JAVA_UDF",
"static_load" = "true", // default value is false
"expiration_time" = "60" // default value is 360 minutes
"static_load" = "true" // default value is false
);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,19 +537,20 @@ public class FunctionUdf {

### 方案 2:BE 全局缓存 JAR 包

BE 全局缓存 JAR 包,并支持自定义过期淘汰时间。在 `CREATE FUNCTION` 时增加以下两个属性字段
BE 全局缓存 JAR 包,并支持自定义过期淘汰时间。在 `CREATE FUNCTION` 时增加以下属性字段

| 属性 | 说明 | 默认值 |
| --- | --- | --- |
| `static_load` | 是否使用静态 cache 加载方式 | `false` |
| `expiration_time` | JAR 包过期时间,单位为分钟 | `360` |

- `expiration_time` 字段自 4.1.1 版本之后删除,但对之前的版本无任何兼容性问题。

工作机制如下:

- 启用静态 cache 加载方式后,第一次调用该 UDF 时,初始化完成后会将该 UDF 实例缓存起来。
- 后续调用该 UDF 时,先在 cache 中查找;若未命中,再执行相关初始化操作。
- 后台有线程定期检查,如果在配置的过期淘汰时间内一直未被调用,则会从 cache 中清理掉。
- 如果在过期前被再次调用,则会自动更新缓存时间点。
- 在 Drop Function 时,会自动清理相关的cache.

示例代码如下:

Expand All @@ -570,8 +571,7 @@ PROPERTIES (
"symbol" = "org.apache.doris.udf.Print",
"always_nullable"="true",
"type" = "JAVA_UDF",
"static_load" = "true", // default value is false
"expiration_time" = "60" // default value is 360 minutes
"static_load" = "true" // default value is false
);
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "Java UDF%2C UDAF%2C UDWF%2C UDTF - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @apache/doris-website-maintainers

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 74. Owner%3A @apache/doris-website-maintainers
{
"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "zh-CN",
Expand Down Expand Up @@ -90,7 +90,7 @@

## 快速上手

本节介绍如何开发并注册 Java UDF。在 `samples/doris-demo/java-udf-demo/` 目录下提供了示例代码供参考,也可以查看 GitHub 上的 [demo](https://github.com/apache/doris/tree/master/samples/doris-demo/java-udf-demo)。

Check notice on line 93 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//github.com/apache/doris/tree/master/samples/doris-demo/java-udf-demo. Owner%3A @apache/doris-website-maintainers

UDF 的使用方式与普通函数一致,唯一的区别在于:

Expand Down Expand Up @@ -530,7 +530,7 @@
CREATE FUNCTION java_udf_dict(string) RETURNS string PROPERTIES (
"file"="file:///pathTo/FunctionUdf.jar",
"symbol"="org.apache.doris.udf.FunctionUdf",
"always_nullable"="true",

Check warning on line 533 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

markdown-cjk-spacing

Chinese text should contain spaces around adjacent English words or numbers. Owner%3A @apache/doris-website-maintainers
"type"="JAVA_UDF"
);
```
Expand All @@ -544,12 +544,14 @@
| `static_load` | 是否使用静态 cache 加载方式 | `false` |
| `expiration_time` | JAR 包过期时间,单位为分钟 | `360` |

- `expiration_time` 字段自 4.1.1 版本之后删除,但对之前的版本无任何兼容性问题。

工作机制如下:

- 启用静态 cache 加载方式后,第一次调用该 UDF 时,初始化完成后会将该 UDF 实例缓存起来。
- 后续调用该 UDF 时,先在 cache 中查找;若未命中,再执行相关初始化操作。
- 后台有线程定期检查,如果在配置的过期淘汰时间内一直未被调用,则会从 cache 中清理掉。
- 如果在过期前被再次调用,则会自动更新缓存时间点。
- 在 Drop Function 时,会自动清理相关的cache.


示例代码如下:

Expand All @@ -570,8 +572,7 @@
"symbol" = "org.apache.doris.udf.Print",
"always_nullable"="true",
"type" = "JAVA_UDF",
"static_load" = "true", // default value is false
"expiration_time" = "60" // default value is 360 minutes
"static_load" = "true" // default value is false
);
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-locale-candidate

Japanese docs are report-only. Generate a candidate translation from the changed files and merge it only after human review. Owner%3A @apache/doris-website-maintainers

Check notice on line 1 in versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-version-candidate

A 3.x counterpart exists. Confirm whether the change is supported in 3.x before leaving it unsynced. Owner%3A @apache/doris-website-maintainers

Check warning on line 1 in versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-version-missing

English 4.x and current docs are strongly synchronized%2C but the current counterpart is missing. Add it or explain the version-specific exception in the PR description. Owner%3A @apache/doris-website-maintainers

Check warning on line 1 in versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "Java UDF%2C UDAF%2C UDWF%2C UDTF - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @apache/doris-website-maintainers
{
"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "en",
Expand Down Expand Up @@ -90,7 +90,7 @@

## Quick Start

This section describes how to develop and register Java UDFs. Sample code is provided in the `samples/doris-demo/java-udf-demo/` directory for reference, and you can also view the [demo](https://github.com/apache/doris/tree/master/samples/doris-demo/java-udf-demo) on GitHub.

Check notice on line 93 in versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md

View workflow job for this annotation

GitHub Actions / Build Check

link-external-report-only

External link is report-only and was not fetched%3A https%3A//github.com/apache/doris/tree/master/samples/doris-demo/java-udf-demo. Owner%3A @apache/doris-website-maintainers

UDFs are used in the same way as ordinary functions, with one difference:

Expand Down Expand Up @@ -544,12 +544,13 @@
| `static_load` | Whether to use the static cache loading method | `false` |
| `expiration_time` | JAR expiration time, in minutes | `360` |

- `expiration_time` will be removed after 4.1.1 version。

How it works:

- After static cache loading is enabled, the UDF instance is cached after initialization completes on the first call.
- On subsequent calls to the UDF, the cache is checked first; if there is a miss, the relevant initialization is executed.
- A background thread checks periodically. If the UDF has not been called within the configured expiration time, it is cleared from the cache.
- If the UDF is called again before expiration, the cache timestamp is automatically refreshed.
- When Drop Function, it's will be cleared from the cache.

Example code:

Expand Down
Loading