changed condition for full index

This commit is contained in:
Alexander Weiss 2020-05-24 09:19:42 +02:00
parent d70a4a9350
commit 8c1261ff02

View file

@ -59,10 +59,8 @@ func (idx *Index) Final() bool {
} }
const ( const (
indexMinBlobs = 20 indexMaxBlobs = 50000
indexMaxBlobs = 2000 indexMaxAge = 10 * time.Minute
indexMinAge = 2 * time.Minute
indexMaxAge = 15 * time.Minute
) )
// IndexFull returns true iff the index is "full enough" to be saved as a preliminary index. // IndexFull returns true iff the index is "full enough" to be saved as a preliminary index.
@ -72,26 +70,21 @@ var IndexFull = func(idx *Index) bool {
debug.Log("checking whether index %p is full", idx) debug.Log("checking whether index %p is full", idx)
packs := len(idx.pack) blobs := len(idx.pack)
age := time.Now().Sub(idx.created) age := time.Now().Sub(idx.created)
if age > indexMaxAge { switch {
case age >= indexMaxAge:
debug.Log("index %p is old enough", idx, age) debug.Log("index %p is old enough", idx, age)
return true return true
} case blobs >= indexMaxBlobs:
debug.Log("index %p has %d blobs", idx, blobs)
if packs < indexMinBlobs || age < indexMinAge {
debug.Log("index %p only has %d packs or is too young (%v)", idx, packs, age)
return false
}
if packs > indexMaxBlobs {
debug.Log("index %p has %d packs", idx, packs)
return true return true
} }
debug.Log("index %p is not full", idx) debug.Log("index %p only has %d blobs and is too young (%v)", idx, blobs, age)
return false return false
} }
// Store remembers the id and pack in the index. An existing entry will be // Store remembers the id and pack in the index. An existing entry will be