var ErrRevisionNotFound … type keyIndex … // put puts a revision to the keyIndex. func (ki *keyIndex) put(lg *zap.Logger, main int64, sub int64) { … } func (ki *keyIndex) restore(lg *zap.Logger, created, modified revision, ver int64) { … } // tombstone puts a revision, pointing to a tombstone, to the keyIndex. // It also creates a new empty generation in the keyIndex. // It returns ErrRevisionNotFound when tombstone on an empty generation. func (ki *keyIndex) tombstone(lg *zap.Logger, main int64, sub int64) error { … } // get gets the modified, created revision and version of the key that satisfies the given atRev. // Rev must be higher than or equal to the given atRev. func (ki *keyIndex) get(lg *zap.Logger, atRev int64) (modified, created revision, ver int64, err error) { … } // since returns revisions since the given rev. Only the revision with the // largest sub revision will be returned if multiple revisions have the same // main revision. func (ki *keyIndex) since(lg *zap.Logger, rev int64) []revision { … } // compact compacts a keyIndex by removing the versions with smaller or equal // revision than the given atRev except the largest one. // If a generation becomes empty during compaction, it will be removed. func (ki *keyIndex) compact(lg *zap.Logger, atRev int64, available map[revision]struct{ … } // keep finds the revision to be kept if compact is called at given atRev. func (ki *keyIndex) keep(atRev int64, available map[revision]struct{ … } func (ki *keyIndex) doCompact(atRev int64, available map[revision]struct{ … } func (ki *keyIndex) isEmpty() bool { … } // findGeneration finds out the generation of the keyIndex that the // given rev belongs to. If the given rev is at the gap of two generations, // which means that the key does not exist at the given rev, it returns nil. func (ki *keyIndex) findGeneration(rev int64) *generation { … } func (ki *keyIndex) Less(b btree.Item) bool { … } func (ki *keyIndex) equal(b *keyIndex) bool { … } func (ki *keyIndex) String() string { … } type generation … func (g *generation) isEmpty() bool { … } // walk walks through the revisions in the generation in descending order. // It passes the revision to the given function. // walk returns until: 1. it finishes walking all pairs 2. the function returns false. // walk returns the position at where it stopped. If it stopped after // finishing walking, -1 will be returned. func (g *generation) walk(f func(rev revision) bool) int { … } func (g *generation) String() string { … } func (g generation) equal(b generation) bool { … }