mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Patch a small bug on json write
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
@ -84,6 +85,7 @@ func FormatJSONBatch(batch obiiter.BioSequenceBatch) *bytes.Buffer {
|
||||
func WriteJSON(iterator obiiter.IBioSequence,
|
||||
file io.WriteCloser,
|
||||
options ...WithOption) (obiiter.IBioSequence, error) {
|
||||
var latestChunk atomic.Int64
|
||||
|
||||
opt := MakeOptions(options)
|
||||
|
||||
@ -97,6 +99,12 @@ func WriteJSON(iterator obiiter.IBioSequence,
|
||||
|
||||
go func() {
|
||||
newIter.WaitAndClose()
|
||||
|
||||
chunkchan <- FileChunk{
|
||||
Source: "end",
|
||||
Raw: bytes.NewBuffer([]byte("\n]\n")),
|
||||
Order: int(latestChunk.Load()) + 1,
|
||||
}
|
||||
for len(chunkchan) > 0 {
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
@ -115,6 +123,7 @@ func WriteJSON(iterator obiiter.IBioSequence,
|
||||
}
|
||||
|
||||
chunkchan <- ss
|
||||
latestChunk.Store(int64(batch.Order()))
|
||||
newIter.Push(batch)
|
||||
}
|
||||
newIter.Done()
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
// TODO: The version number is extracted from git. This induces that the version
|
||||
// corresponds to the last commit, and not the one when the file will be
|
||||
// commited
|
||||
var _Commit = "69ef175"
|
||||
var _Commit = "00b0edc"
|
||||
var _Version = "Release 4.2.0"
|
||||
|
||||
// Version returns the version of the obitools package.
|
||||
|
Reference in New Issue
Block a user