Optimize memory for readers and writers

This commit is contained in:
Eric Coissac
2024-08-05 10:48:28 +02:00
parent f83032e643
commit 886b5d9a96
11 changed files with 48 additions and 13 deletions

View File

@ -464,6 +464,39 @@ func (iterator IBioSequence) Rebatch(size int) IBioSequence {
return newIter
}
func (iterator IBioSequence) FilterEmpty() IBioSequence {
newIter := MakeIBioSequence()
newIter.Add(1)
go func() {
newIter.WaitAndClose()
}()
go func() {
order := 0
iterator = iterator.SortBatches()
for iterator.Next() {
seqs := iterator.Get()
lc := seqs.Len()
if lc > 0 {
newIter.Push(seqs.Reorder(order))
order++
}
}
newIter.Done()
}()
if iterator.IsPaired() {
newIter.MarkAsPaired()
}
return newIter
}
func (iterator IBioSequence) Recycle() {
log.Debugln("Start recycling of Bioseq objects")

View File

@ -1,6 +1,7 @@
package obiiter
import (
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
log "github.com/sirupsen/logrus"
)
@ -40,8 +41,8 @@ func (iter IBioSequence) PairTo(p IBioSequence) IBioSequence {
newIter := MakeIBioSequence()
iter = iter.SortBatches()
p = p.SortBatches()
iter = iter.SortBatches().Rebatch(obioptions.CLIBatchSize())
p = p.SortBatches().Rebatch(obioptions.CLIBatchSize())
newIter.Add(1)