gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitaac9a98daac9a98dlog: evening re-measure startmreaac9a98d/lib/export.hl

1.8 KB

  1. // lib/export.hl — READING THE OLD TRACKER'S MONGO EXPORT (/media/STORAGE/projects/old-tracker/mongo-export/*.jsonl, EJSON, one
  2. // document per line): the lines of a file, a Mongo id, the chunk workaround for big files. Used by the one-off tools
  3. // tools/migrate.hl (tracker.worldapi.org#2) and tools/old-short-ids.hl (mission 060). Mission 028: was copied into both.
  4. import { run } from 'hl:proc'
  5. import { readFile, mkDir, exists } from 'hl:fs'
  6. static nl = "
  7. "
  8. static linesOf = (&path) => {
  9. raw = readFile(path)
  10. if (raw == null) { return [] }
  11. out = []
  12. for (l of raw.split(nl)) { if (l != '') { out.push(l) } }
  13. return out
  14. }
  15. static oidOf = (&v) => {
  16. if (v == null) { return null }
  17. if (hlTypeName(v) == 'String') { return v }
  18. return v['$oid']
  19. }
  20. // hl:fs readFile SILENTLY TRUNCATES at 10 MiB (fs.zig hl_fs_read_file, max_size = 1024*1024*10,
  21. // no error, no flag — reported as a Hybriel gap, tracker.worldapi.org#2): Show.jsonl (12.4 MB),
  22. // Season.jsonl (10.9 MB) and Episode.jsonl (140 MB) are all over it. Worked around WITHOUT
  23. // touching the vendored plugin: `split` (coreutils, via hl:proc run — no shell, no JS) cuts the
  24. // export into <10 MB chunks in a scratch dir first; each chunk is read whole (well under the cap).
  25. static padNum4 = (&n) => {
  26. let s = '' + n
  27. while (s.length < 4) { s = '0' + s }
  28. return s
  29. }
  30. static bigLinesOf = (&path, &chunkDir, &perChunk) => {
  31. mkDir(chunkDir, 448)
  32. r = run(['split', '-l', '' + perChunk, '-d', '-a', '4', '--additional-suffix=.jsonl', path, chunkDir + '/c_'])
  33. if (r == null || r.exit != 0) { hlError('split failed for ' + path) }
  34. out = []
  35. let idx = 0
  36. while (true) {
  37. let fp = chunkDir + '/c_' + padNum4(&idx) + '.jsonl'
  38. if (!exists(fp)) { break }
  39. for (l of linesOf(&fp)) { out.push(l) }
  40. idx = idx + 1
  41. }
  42. if (idx == 0) { hlError('no chunks produced for ' + path) }
  43. return out
  44. }

Branches

Latest commits

  • aac9a98dlog: evening re-measure startmre
  • 45163bd4log: person/tmdb error hypothesismre
  • cb38de2blog: swap 503 causemre
  • fd10c3d5log: CB livemre
  • 7557c025log: CB deploy try 2mre
  • 06a7534aMerge branch 'cb'mre
  • 2f8030d6log: CB gates greenmre
  • 498bf644log: CB gates startmre
  • f59c2847gc1: bound the five request caches (shows.hl cacheLimit)mre
  • 6ea2c6d6log: morning re-measure 11-04mre
  • 446290f0log: GC1 livemre
  • 8e6aa91dlog: GC1 deploy retrymre
  • 87ad2dc1log: GC1 deployingmre
  • 53f10fb8Merge branch 'gc1-deploy'mre
  • 7fcbf1d2log: GC1 deploy GOmre
  • 1fb6664bcompose: TRACKER_QSTATS=1 (GC1 measurement)mre
  • 6576c1cdgc1: release the people-view scan lists once the view is builtmre
  • 94f8a373gc1: back out the kept episode-id set (no measurable gain on /my/unwatched: 4.69 -> 4.61 GB per 150 loads)mre
  • a1a88bd4gc1: search skips the stale-key string while no entry is stale; /my/unwatched asks a kept id set instead of building a key string per episode rowmre
  • cd830744gc1: dbSearch: no split / map / list copy per candidate (scores from the stored text, top list touched only when the hit can enter)mre