diff options
| author | alex <[email protected]> | 2026-07-28 17:37:06 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-28 17:37:06 +0200 |
| commit | c91c3afd8700138f8eb8a25a4ae422c2c9e46cea (patch) | |
| tree | fd9b5ea4f3b821581b2ceb4e7fa8afc1a84c0eeb /ingest/ingest.go | |
| parent | 5858d34b8ab573e18a4f6ddc5ee962b24ea269dc (diff) | |
| download | search-engine-c91c3afd8700138f8eb8a25a4ae422c2c9e46cea.tar.xz search-engine-c91c3afd8700138f8eb8a25a4ae422c2c9e46cea.zip | |
refactored entire code base to be in the package core so i can later implement interfaces to interact with the engine
Diffstat (limited to 'ingest/ingest.go')
| -rw-r--r-- | ingest/ingest.go | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/ingest/ingest.go b/ingest/ingest.go deleted file mode 100644 index bffc417..0000000 --- a/ingest/ingest.go +++ /dev/null @@ -1,48 +0,0 @@ -package ingest - -import ( - "encoding/xml" - "io" - "os" -) - -type Page struct { - Title string `xml:"title"` - Text string `xml:"revision>text"` - Id int `xml:"id"` -} - -func IngestWikiDump(filePath string, jobQueue chan<- Page) error { - file, err := os.Open(filePath) - if err != nil { - return err - } - defer file.Close() - - // 3. Attach the streaming XML decoder - decoder := xml.NewDecoder(file) - - for { - t, err := decoder.Token() - if err == io.EOF { - break - } - if err != nil { - return err - } - - // Look for the opening <page> tag - switch se := t.(type) { - case xml.StartElement: - if se.Name.Local == "page" { - var p Page - // Decode the entire page element into the struct - if err := decoder.DecodeElement(&p, &se); err == nil { - // Push to your worker pool channel - jobQueue <- p - } - } - } - } - return nil -} |
