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