╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Fork.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
87 88 if (!record.removed) { 89 try active.put(&order_key); 90 if (record.event.stage == .draft) { 91 const repo_id = try evt.parseEventId(&record.event.repo_id); 92 const by_repo = try DB.SortedSet(.read_write).init(try drafts.putCursor(hash.hashInt(hash_kind, &repo_id))); 93 try by_repo.put(&order_key); 94 } 95 } 96 } 97 98 fn removeFromParentSet( 99 comptime DB: type, 100 comptime hash_kind: hash.HashKind, 101 index: DB.HashMap(.read_write), 102 parent_id: *const [evt.event_id_size]u8, 103 order_key: *const [@sizeOf(u64) + evt.event_id_size]u8, 104 ) !void { 105 const cursor = try index.putCursor(hash.hashInt(hash_kind, parent_id)); 106 const ids = try DB.SortedSet(.read_write).init(cursor); 107 _ = try ids.remove(order_key); 108 } 109 110 pub fn readById( 111 comptime DB: type, 112 comptime hash_kind: hash.HashKind, 113 haxy_moment: DB.HashMap(.read_only), 114 arena: *std.heap.ArenaAllocator, 115 fork_id: []const u8, 116 ) !?Record { 117 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 118 const records = try DB.HashMap(.read_only).init(records_cursor); 119 const fork_cursor = try records.getCursor(hash.hashInt(hash_kind, fork_id)) orelse return null; 120 return try evt.read(Record, DB, hash_kind, arena, try DB.HashMap(.read_only).init(fork_cursor)); 121 } 122