projects
/
lightning.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add copyright headers.
[lightning.git]
/
gob.go
diff --git
a/gob.go
b/gob.go
index 2fb061c5b1fc1770982dbeb9400d35b33ef562fb..893b8cadc6d25d4c0fb6d8cd9e8dc1a0ef95d6ce 100644
(file)
--- a/
gob.go
+++ b/
gob.go
@@
-1,11
+1,17
@@
-package main
+// Copyright (C) The Lightning Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+package lightning
import (
"bufio"
"encoding/gob"
"io"
import (
"bufio"
"encoding/gob"
"io"
+ "io/ioutil"
_ "net/http/pprof"
_ "net/http/pprof"
+ "github.com/klauspost/pgzip"
"golang.org/x/crypto/blake2b"
)
"golang.org/x/crypto/blake2b"
)
@@
-14,6
+20,11
@@
type CompactGenome struct {
Variants []tileVariantID
}
Variants []tileVariantID
}
+type CompactSequence struct {
+ Name string
+ TileSequences map[string][]tileLibRef
+}
+
type TileVariant struct {
Tag tagID
Variant tileVariantID
type TileVariant struct {
Tag tagID
Variant tileVariantID
@@
-22,23
+33,31
@@
type TileVariant struct {
}
type LibraryEntry struct {
}
type LibraryEntry struct {
- TagSet [][]byte
- CompactGenomes []CompactGenome
- TileVariants []TileVariant
+ TagSet [][]byte
+ CompactGenomes []CompactGenome
+ CompactSequences []CompactSequence
+ TileVariants []TileVariant
}
}
-func ReadCompactGenomes(rdr io.Reader) ([]CompactGenome, error) {
+func ReadCompactGenomes(rdr io.Reader
, gz bool
) ([]CompactGenome, error) {
var ret []CompactGenome
var ret []CompactGenome
- err := DecodeLibrary(rdr, func(ent *LibraryEntry) error {
+ err := DecodeLibrary(rdr,
gz,
func(ent *LibraryEntry) error {
ret = append(ret, ent.CompactGenomes...)
return nil
})
return ret, err
}
ret = append(ret, ent.CompactGenomes...)
return nil
})
return ret, err
}
-func DecodeLibrary(rdr io.Reader, cb func(*LibraryEntry) error) error {
-
dec := gob.NewDecoder(bufio.NewReaderSize(rdr, 1<<26)
)
+func DecodeLibrary(rdr io.Reader,
gz bool,
cb func(*LibraryEntry) error) error {
+
zrdr := ioutil.NopCloser(rdr
)
var err error
var err error
+ if gz {
+ zrdr, err = pgzip.NewReader(bufio.NewReaderSize(rdr, 1<<20))
+ if err != nil {
+ return err
+ }
+ }
+ dec := gob.NewDecoder(zrdr)
for err == nil {
var ent LibraryEntry
err = dec.Decode(&ent)
for err == nil {
var ent LibraryEntry
err = dec.Decode(&ent)
@@
-46,9
+65,8
@@
func DecodeLibrary(rdr io.Reader, cb func(*LibraryEntry) error) error {
err = cb(&ent)
}
}
err = cb(&ent)
}
}
- if err == io.EOF {
- return nil
- } else {
+ if err != io.EOF {
return err
}
return err
}
+ return zrdr.Close()
}
}