1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-12-03 15:18:06 +00:00

Implement the rocket link migration algorithm

This commit is contained in:
Timur Ismagilov
2022-01-31 02:34:52 +05:00
parent 3281fadfc5
commit 86d1a00bfc
7 changed files with 142 additions and 7 deletions

View File

@@ -41,7 +41,7 @@ var backlinkIndex = make(map[string]linkSet)
// IndexBacklinks traverses all text hyphae, extracts links from them and forms an initial index. Call it when indexing and reindexing hyphae.
func IndexBacklinks() {
// It is safe to ignore the mutex, because there is only one worker.
for h := range hyphae.FilterTextHyphae(hyphae.YieldExistingHyphae()) {
for h := range hyphae.FilterHyphaeWithText(hyphae.YieldExistingHyphae()) {
foundLinks := extractHyphaLinksFromContent(h.Name, fetchText(h))
for _, link := range foundLinks {
if _, exists := backlinkIndex[link]; !exists {

View File

@@ -21,8 +21,9 @@ func YieldExistingHyphae() chan *Hypha {
return ch
}
// FilterTextHyphae filters the source channel and yields only those hyphae than have text parts.
func FilterTextHyphae(src chan *Hypha) chan *Hypha {
// FilterHyphaeWithText filters the source channel and yields only those hyphae than have text parts.
func FilterHyphaeWithText(src chan *Hypha) chan *Hypha {
// TODO: reimplement as a function with a callback?
sink := make(chan *Hypha)
go func() {
for h := range src {