Log tile library size periodically.
authorTom Clegg <tom@tomclegg.ca>
Fri, 17 Jan 2020 18:20:03 +0000 (13:20 -0500)
committerTom Clegg <tom@tomclegg.ca>
Fri, 17 Jan 2020 18:20:03 +0000 (13:20 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

gvcf2numpy.go
tilelib.go

index a8922d3f3cbb8ac0bb97aeb0280788e94865141c..3b0f34bf29b14f020821b053d5eadfa3e02cd052 100644 (file)
@@ -81,6 +81,11 @@ func (cmd *gvcf2numpy) RunCommand(prog string, args []string, stdin io.Reader, s
        log.Printf("tag library %s load done", cmd.tagLibraryFile)
 
        tilelib := tileLibrary{taglib: &taglib}
+       go func() {
+               for range time.Tick(10 * time.Second) {
+                       log.Printf("tilelib.Len() == %d", tilelib.Len())
+               }
+       }()
        tseqs, err := cmd.tileGVCFs(&tilelib, infiles)
        if err != nil {
                return 1
index 0a8ebfac6497688e38184909acea5bd9ed12875e..8d4afa0f6965180f2b328bf18d3bdb72a7ab79fc 100644 (file)
@@ -24,6 +24,7 @@ type tileLibrary struct {
        variant [][][blake2b.Size]byte
        // count [][]int
        // seq map[[blake2b.Size]byte][]byte
+       variants int
 
        mtx sync.Mutex
 }
@@ -76,6 +77,12 @@ func (tilelib *tileLibrary) TileFasta(filelabel string, rdr io.Reader) (tileSeq,
        return ret, scanner.Err()
 }
 
+func (tilelib *tileLibrary) Len() int {
+       tilelib.mtx.Lock()
+       defer tilelib.mtx.Unlock()
+       return tilelib.variants
+}
+
 // Return a tileLibRef for a tile with the given tag and sequence,
 // adding the sequence to the library if needed.
 func (tilelib *tileLibrary) getRef(tag tagID, seq []byte) tileLibRef {
@@ -84,8 +91,8 @@ func (tilelib *tileLibrary) getRef(tag tagID, seq []byte) tileLibRef {
        // if tilelib.seq == nil {
        //      tilelib.seq = map[[blake2b.Size]byte][]byte{}
        // }
-       if len(tilelib.variant) <= int(tag) {
-               tilelib.variant = append(tilelib.variant, make([][][blake2b.Size]byte, int(tag)-len(tilelib.variant)+1)...)
+       if tilelib.variant == nil {
+               tilelib.variant = make([][][blake2b.Size]byte, tilelib.taglib.Len())
        }
        hash, err := blake2b.New(32, nil)
        if err != nil {
@@ -102,6 +109,7 @@ func (tilelib *tileLibrary) getRef(tag tagID, seq []byte) tileLibRef {
                        return tileLibRef{tag: tag, variant: tileVariantID(i + 1)}
                }
        }
+       tilelib.variants++
        tilelib.variant[tag] = append(tilelib.variant[tag], seqhash)
        // tilelib.seq[seqhash] = append([]byte(nil), seq...)
        return tileLibRef{tag: tag, variant: tileVariantID(len(tilelib.variant[tag]))}