func (l *List) init(key []byte, pstore *store.Store, clog *commit.Logger) { l.Lock() defer l.Unlock() defer l.wg.Done() if len(empty) == 0 { glog.Fatal("empty should have some bytes.") } l.key = key l.pstore = pstore l.clog = clog posting := l.getPostingList() l.maxMutationTs = posting.CommitTs() l.hash = farm.Fingerprint32(key) l.ghash = gotomic.IntKey(farm.Fingerprint64(key)) l.mlayer = make(map[int]types.Posting) if clog == nil { return } glog.Debug("Starting stream entries...") err := clog.StreamEntries(posting.CommitTs()+1, l.hash, func(hdr commit.Header, buffer []byte) { uo := flatbuffers.GetUOffsetT(buffer) m := new(types.Posting) m.Init(buffer, uo) if m.Ts() > l.maxMutationTs { l.maxMutationTs = m.Ts() } glog.WithFields(logrus.Fields{ "uid": m.Uid(), "source": string(m.Source()), "ts": m.Ts(), }).Debug("Got entry from log") l.mergeMutation(m) }) if err != nil { glog.WithError(err).Error("While streaming entries.") } glog.Debug("Done streaming entries.") }
func closeAll(dir1, dir2 string, clog *commit.Logger) { clog.Close() os.RemoveAll(dir2) os.RemoveAll(dir1) }