Skip to content

Commit f3c7817

Browse files
recsplit: prepare for parallelism (#19514)
To introduce parallelism (in next PR) need first get-rid from "shared mutable fields" - `recsplit()` is now pure. it accepting in/out params: - `recsplitScratch` it's `in` parameter/bufs/configs - `result` is `out` param/bufs - write to files now happening outside of `recsplit()` func --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent f508f14 commit f3c7817

File tree

2 files changed

+179
-82
lines changed

2 files changed

+179
-82
lines changed

db/recsplit/golomb_rice.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,31 @@ func (g *GolombRice) Bits() int {
8787
return g.bitCount
8888
}
8989

90+
// Append concatenates another GolombRice bit-stream onto this one.
91+
func (g *GolombRice) Append(other *GolombRice) {
92+
if other.bitCount == 0 {
93+
return
94+
}
95+
shift := g.bitCount & 63
96+
targetSize := (g.bitCount + other.bitCount + 63) / 64
97+
for len(g.data) < targetSize {
98+
g.data = append(g.data, 0)
99+
}
100+
appendPtr := g.bitCount / 64
101+
nWords := (other.bitCount + 63) / 64
102+
if shift == 0 {
103+
copy(g.data[appendPtr:], other.data[:nWords])
104+
} else {
105+
for i, w := range other.data[:nWords] {
106+
g.data[appendPtr+i] |= w << shift
107+
if appendPtr+i+1 < len(g.data) {
108+
g.data[appendPtr+i+1] |= w >> (64 - shift)
109+
}
110+
}
111+
}
112+
g.bitCount += other.bitCount
113+
}
114+
90115
func (g *GolombRiceReader) ReadReset(bitPos, unaryOffset int) {
91116
g.currFixedOffset = bitPos
92117
unaryPos := bitPos + unaryOffset

0 commit comments

Comments
 (0)