mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-24 09:26:48 +08:00
### Summary Refactor dataset.go document.do file.go file2document.go in internal/service.
27 lines
766 B
Go
27 lines
766 B
Go
package document
|
|
|
|
import (
|
|
"encoding/hex"
|
|
|
|
pipelinepkg "ragflow/internal/ingestion/pipeline"
|
|
"ragflow/internal/utility"
|
|
|
|
"github.com/zeebo/xxh3"
|
|
)
|
|
|
|
// selectUploadParser resolves the parser_id for a document by delegating to
|
|
// the builtin pipeline registry, which owns the file-type-to-parser mapping.
|
|
func selectUploadParser(docType utility.FileType, filename, defaultParser string) string {
|
|
registry, err := pipelinepkg.DefaultRegistry()
|
|
if err != nil || registry == nil {
|
|
return defaultParser
|
|
}
|
|
return registry.DefaultParserID(string(docType), filename, defaultParser)
|
|
}
|
|
|
|
// contentHashHex mirrors Python xxhash.xxh128(blob).hexdigest().
|
|
func contentHashHex(blob []byte) string {
|
|
sum := xxh3.Hash128(blob).Bytes()
|
|
return hex.EncodeToString(sum[:])
|
|
}
|