Skip to content

Commit ef6ba2f

Browse files
authored
Merge branch 'main' into lupin012/uniform_blockOverrides
2 parents a8b4b3d + f3c7817 commit ef6ba2f

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)