Handle remainders for unint64 slice writing
@@ -131,8 +131,9 @@ func (c *MemoryCondensor2) writeCommitType(w *bufWriter, in HnswCommitType) erro
}
func (c *MemoryCondensor2) writeUint64Slice(w *bufWriter, in []uint64) error {
- buf := make([]byte, 64)
- for i := 0; i < len(in); i++{
+ buf := make([]byte, 8*len(in))
+ i := 0
+ for i < len(in){
if i != 0 && i%8 == 0 {
if _, err := w.Write(buf); err != nil {
return err
@@ -143,6 +144,19 @@ func (c *MemoryCondensor2) writeUint64Slice(w *bufWriter, in []uint64) error {
start := pos * 8
end := start + 8
binary.LittleEndian.PutUint64(buf[start:end], in[i])
+ i++
+ }
+
+ if i != 0 {
+ start := 0
+ end := i % 8 * 8
+ if end == 0 {
+ end = 64
+ }
+
+ if _, err := w.Write(buf[start:end]); err != nil {
+ return err
+ }
}
return nil
