// Builder pre-finalization read probes: staged counts, property and label// reads, value-scan and neighbor projections. All are O(pairs)/O(rels)// scans over the staging state, never interning (reads must not grow the// atom table).package chickpeas// NodeCount is the number of distinct nodes staged so far.func ( *Builder) () int {returnint(.knownNodes.GetCardinality())}// RelCount is the number of live relationships staged so far (tombstoned// rels and pending detach-delete cascades excluded).func ( *Builder) () int {if !.hasRemovals() {returnlen(.rels) } := 0for := range .rels {if !.relRemoved() { ++ } }return}// Prop reads node's staged value for key -- an O(pairs) pre-finalization// probe that never interns (a string value never interned can't be staged// anywhere). Returns the FIRST staged write, matching the Rust builder.func ( *Builder) ( NodeID, string) (Value, bool) { , := .interner.Get()if ! {returnValue{}, false }for , := range .nodeColStr[] {if .id == {returnStrValue(.val), true } }for , := range .nodeColI64[] {if .id == {returnI64Value(.val), true } }for , := range .nodeColF64[] {if .id == {returnF64Value(.val), true } }for , := range .nodeColBool[] {if .id == {returnBoolValue(.val), true } }returnValue{}, false}// ResolveString resolves an interner atom back to its string (for reading// staged Prop values); ok is false when out of range.func ( *Builder) ( uint32) (string, bool) {return .interner.Resolve()}// NodesWithProperty lists the label-carrying nodes whose staged property// key equals value, in staging order -- an O(pairs) pre-finalization scan.// A string value never interned in this builder can't be on any node, so// the probe returns empty WITHOUT interning it (reads must not grow the// atom table).func ( *Builder) (, string, any) []NodeID { , := .interner.Get()if ! {returnnil } , := .interner.Get()if ! {returnnil }varValueswitch v := .(type) {caseValue: = casestring: , := .interner.Get()if ! {returnnil } = StrValue()default: , := .stageValue() // numeric/bool: never internsif != nil {returnnil } = } := func( NodeID) bool {ifint() >= len(.nodeLabels) {returnfalse }for , := range .nodeLabels[] {if .ID() == {returntrue } }returnfalse }var []NodeID// Scan only the column whose type matches the probe value.switch .Kind() {caseKindI64: , := .I64()for , := range .nodeColI64[] {if .val == && (.id) { = append(, .id) } }caseKindF64:for , := range .nodeColF64[] {ifF64Value(.val) == && (.id) { = append(, .id) } }caseKindBool: , := .Bool()for , := range .nodeColBool[] {if .val == && (.id) { = append(, .id) } }caseKindStr: , := .StrID()for , := range .nodeColStr[] {if .val == && (.id) { = append(, .id) } } }return}// NodeLabels lists node's staged labels in insertion order.func ( *Builder) ( NodeID) []string {ifint() >= len(.nodeLabels) {returnnil } := make([]string, 0, len(.nodeLabels[]))for , := range .nodeLabels[] {if , := .interner.Resolve(.ID()); { = append(, ) } }return}// NeighborIDs lists node's staged neighbors in direction (outgoing then// incoming for Both), skipping removed rels -- an O(rels) pre-finalization// scan.func ( *Builder) ( NodeID, Direction) []NodeID {var []NodeIDif == Outgoing || == Both {for , := range .rels {if [0] == && !.relRemoved() { = append(, [1]) } } }if == Incoming || == Both {for , := range .rels {if [1] == && !.relRemoved() { = append(, [0]) } } }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.