ReaderUtils
public final class ReaderUtils
源码Source
io/agentscope/core/rag/reader/ReaderUtils.java:31–95读取器 Utils,把私有文档转化为可检索的知识。位于 io.agentscope.core.rag.reader 包。核心成员包括 generateDocId、generateDocIdMD5、generateDocIdSHA256、bytesToHex。
Utility class for common reader operations.
This class provides shared functionality for document readers, including:
-
Document ID generation using hash algorithms
-
Byte array to hex string conversion
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static String generateDocId(String input, String algorithm)static | 执行 `generateDocId` 方法。 Generates a deterministic document ID using the specified hash algorithm. |
public static String generateDocIdMD5(String input)static | 设置该参数。 Generates a deterministic document ID using MD5 hash. |
public static String generateDocIdSHA256(String input)static | 设置该参数。 Generates a deterministic document ID using SHA-256 hash. |
public static String bytesToHex(byte[] bytes)static | 设置该参数。 Converts byte array to hexadecimal string. |
方法详情Method Detail
generateDocId
public static String generateDocId(String input, String algorithm)
static
执行 generateDocId 方法。
Generates a deterministic document ID using the specified hash algorithm.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | String | 输入消息(类型 `String`)。the input string to hash (typically a file path) |
algorithm | String | algorithm(类型 `String`)。the hash algorithm to use (e.g., "MD5", "SHA-256") |
String返回字符串结果。the hash of the input as a hexadecimal string
RuntimeException可能抛出 `RuntimeException`。if the specified algorithm is not available
源码Source
io/agentscope/core/rag/reader/ReaderUtils.java:48–56generateDocIdMD5
public static String generateDocIdMD5(String input)
static
设置该参数。
Generates a deterministic document ID using MD5 hash.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | String | 输入消息(类型 `String`)。the input string to hash (typically a file path) |
String返回字符串结果。MD5 hash of the input as a hexadecimal string
源码Source
io/agentscope/core/rag/reader/ReaderUtils.java:66–68generateDocIdSHA256
public static String generateDocIdSHA256(String input)
static
设置该参数。
Generates a deterministic document ID using SHA-256 hash.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
input | String | 输入消息(类型 `String`)。the input string to hash (typically a file path) |
String返回字符串结果。SHA-256 hash of the input as a hexadecimal string
源码Source
io/agentscope/core/rag/reader/ReaderUtils.java:78–80bytesToHex
public static String bytesToHex(byte[] bytes)
static
设置该参数。
Converts byte array to hexadecimal string.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
bytes | byte[] | 字节(类型 `byte[]`)。the byte array to convert |
String返回字符串结果。hexadecimal string representation (lowercase)
源码Source
io/agentscope/core/rag/reader/ReaderUtils.java:88–94