Skip to content

Commit 03c12fc

Browse files
authored
Merge pull request #11 from weaviate/contains_optimizations
chore: optimizations
2 parents bd006ec + a5a0aeb commit 03c12fc

File tree

8 files changed

+2586
-37
lines changed

8 files changed

+2586
-37
lines changed

benchmark_opt_test.go

Lines changed: 712 additions & 0 deletions
Large diffs are not rendered by default.

bitmap.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,18 @@ func (ra *Bitmap) copyAt(offset uint64, src []uint16) {
345345
ra.data[offset] = targetSz
346346
}
347347

348-
func (ra Bitmap) getContainer(offset uint64) []uint16 {
348+
func (ra *Bitmap) insertAt(offset uint64, src []uint16) {
349+
dstSize := ra.data[offset]
350+
targetSz := src[indexSize]
351+
bySize := targetSz - dstSize
352+
353+
ra.scootRight(offset+uint64(dstSize), uint64(bySize))
354+
ra.keys.updateOffsets(offset, uint64(bySize), true)
355+
assert(copy(ra.data[offset:], src) == len(src))
356+
ra.data[offset] = targetSz
357+
}
358+
359+
func (ra *Bitmap) getContainer(offset uint64) []uint16 {
349360
data := ra.data[offset:]
350361
if len(data) == 0 {
351362
panic(fmt.Sprintf("No container found at offset: %d\n", offset))
@@ -782,7 +793,7 @@ func (ra *Bitmap) extreme(dir int) uint64 {
782793
}
783794
}
784795

785-
func (ra *Bitmap) And(bm *Bitmap) {
796+
func (ra *Bitmap) AndOld(bm *Bitmap) {
786797
if bm == nil {
787798
ra.Reset()
788799
return
@@ -827,7 +838,7 @@ func (ra *Bitmap) And(bm *Bitmap) {
827838
}
828839
}
829840

830-
func And(a, b *Bitmap) *Bitmap {
841+
func AndOld(a, b *Bitmap) *Bitmap {
831842
ai, an := 0, a.keys.numKeys()
832843
bi, bn := 0, b.keys.numKeys()
833844

@@ -860,7 +871,7 @@ func And(a, b *Bitmap) *Bitmap {
860871
return res
861872
}
862873

863-
func (ra *Bitmap) AndNot(bm *Bitmap) {
874+
func (ra *Bitmap) AndNotOld(bm *Bitmap) {
864875
if bm == nil {
865876
return
866877
}
@@ -898,7 +909,7 @@ func (ra *Bitmap) AndNot(bm *Bitmap) {
898909
}
899910

900911
// TODO: Check if we want to use lazyMode
901-
func (dst *Bitmap) Or(src *Bitmap) {
912+
func (dst *Bitmap) OrOld(src *Bitmap) {
902913
if src == nil {
903914
return
904915
}
@@ -935,7 +946,7 @@ func (dst *Bitmap) or(src *Bitmap, runMode int) {
935946
}
936947
}
937948

938-
func Or(a, b *Bitmap) *Bitmap {
949+
func OrOld(a, b *Bitmap) *Bitmap {
939950
ai, an := 0, a.keys.numKeys()
940951
bi, bn := 0, b.keys.numKeys()
941952

0 commit comments

Comments
 (0)