Distributed Services with Go: Index - Write Sync in index (Page 35)

@travisjeffery

PDF - Page 35

No need to synchronize this function? How mmap work with multiple writers?.

func (i *index) Write(off uint32, pos uint64) error {
if uint64(len(i.mmap)) < i.size+entWidth {
return io.EOF
}
enc.PutUint32(i.mmap[i.size:i.size+offWidth], off)
enc.PutUint64(i.mmap[i.size+offWidth:i.size+entWidth], pos)
i.size += uint64(entWidth)
return nil
}

Same question for function
func (s *segment) Append(record *api.Record) (offset uint64, err error)

Thank you,

JC.

1 Like