feedx 0.11.0 → 0.12.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +3 -0
  3. data/.github/workflows/test.yml +60 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +15 -4
  6. data/Gemfile +0 -2
  7. data/Gemfile.lock +80 -50
  8. data/Makefile +6 -6
  9. data/README.md +1 -1
  10. data/compression.go +18 -0
  11. data/compression_test.go +14 -2
  12. data/consumer_test.go +2 -2
  13. data/ext/parquet/decoder.go +170 -0
  14. data/ext/parquet/decoder_test.go +88 -0
  15. data/ext/parquet/go.mod +10 -0
  16. data/ext/parquet/go.sum +152 -0
  17. data/ext/parquet/parquet.go +78 -0
  18. data/ext/parquet/parquet_test.go +28 -0
  19. data/ext/parquet/reader.go +89 -0
  20. data/ext/parquet/testdata/alltypes_plain.parquet +0 -0
  21. data/ext/parquet/types.go +51 -0
  22. data/feedx.gemspec +5 -6
  23. data/feedx_test.go +2 -2
  24. data/format.go +45 -15
  25. data/format_test.go +4 -2
  26. data/go.mod +10 -5
  27. data/go.sum +90 -25
  28. data/internal/testdata/testdata.pb.go +176 -77
  29. data/lib/feedx/cache/abstract.rb +2 -2
  30. data/lib/feedx/cache/memory.rb +1 -0
  31. data/lib/feedx/compression/abstract.rb +2 -2
  32. data/lib/feedx/compression/gzip.rb +2 -2
  33. data/lib/feedx/compression/none.rb +2 -2
  34. data/lib/feedx/consumer.rb +15 -9
  35. data/lib/feedx/format.rb +4 -1
  36. data/lib/feedx/producer.rb +27 -22
  37. data/lib/feedx/stream.rb +30 -13
  38. data/producer_test.go +2 -2
  39. data/reader_test.go +2 -2
  40. data/spec/feedx/cache/memory_spec.rb +2 -2
  41. data/spec/feedx/cache/value_spec.rb +1 -1
  42. data/spec/feedx/compression/gzip_spec.rb +1 -1
  43. data/spec/feedx/compression/none_spec.rb +1 -1
  44. data/spec/feedx/compression_spec.rb +2 -2
  45. data/spec/feedx/consumer_spec.rb +5 -4
  46. data/spec/feedx/format/abstract_spec.rb +2 -1
  47. data/spec/feedx/format/json_spec.rb +6 -6
  48. data/spec/feedx/format/parquet_spec.rb +1 -1
  49. data/spec/feedx/format/protobuf_spec.rb +1 -1
  50. data/spec/feedx/format_spec.rb +2 -2
  51. data/spec/feedx/producer_spec.rb +15 -8
  52. data/spec/feedx/stream_spec.rb +36 -18
  53. data/writer_test.go +2 -2
  54. metadata +24 -23
  55. data/.travis.yml +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5662b9773c03d14b3d7d68b8a1ad208986b95c675cbf61d445f74ebdf3b86b09
4
- data.tar.gz: 074c6e5b86975aed1b31caa5250d7132a2d6bb68af7c221f89043f5f574d0268
3
+ metadata.gz: c1c91575fbae6b3b5df7c840d8355ec2d27916212a57d19192fe63288b39ed9e
4
+ data.tar.gz: e21dffcc3da9ebadd5f936380a00427339566bde0d058e66498528f9418942d6
5
5
  SHA512:
6
- metadata.gz: 3c39e851c7e9266c9b6248f6c6010d351ae9d57809c5f6d153bd6defdf4933fa6f138637e8ad6b0ee5f8cab07dec002b2995ecc0a7ff02222974a49ab1d646e3
7
- data.tar.gz: 1846a1ba29397928281d1ba4b5c683c6c4e097e2879acedc52de21d722033290e5aac72a8f001d2012643f67661aa9fd76bac27c925782b6760b2d96295e1e80
6
+ metadata.gz: d8f0e86db26b77894b062a9919c6f902ddb6123f218fdb9233ab8126b0905c023ba8a32d69cc90b3f035345e637cb6719bd43bee984f3f8c62460772f941405f
7
+ data.tar.gz: 7451b7e3305ce7ec05a8f7c7d4a8cd9a8b65b1eef417f419903f139d01db94cc75045e0fac105eac4dc78699e2012c7c1450b16ad213615fe563799cb7ab1fab
data/.editorconfig CHANGED
@@ -7,3 +7,6 @@ end_of_line = lf
7
7
  charset = utf-8
8
8
  trim_trailing_whitespace = true
9
9
  insert_final_newline = true
10
+
11
+ [{*.go,Makefile}]
12
+ indent_style = tab
@@ -0,0 +1,60 @@
1
+ name: Test
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
9
+ jobs:
10
+ go:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ go-version: [1.15.x, 1.16.x]
15
+ steps:
16
+ - name: Fetch staticcheck
17
+ uses: engineerd/configurator@v0.0.6
18
+ with:
19
+ name: staticcheck
20
+ fromGitHubReleases: true
21
+ repo: dominikh/go-tools
22
+ version: latest
23
+ urlTemplate: "https://github.com/dominikh/go-tools/releases/download/2020.2.3/staticcheck_linux_amd64.tar.gz"
24
+ pathInArchive: staticcheck/staticcheck
25
+ token: ${{ secrets.GITHUB_TOKEN }}
26
+ - name: Checkout
27
+ uses: actions/checkout@v2
28
+ - name: Cache dependencies
29
+ uses: actions/cache@v2
30
+ with:
31
+ path: ~/go/pkg/mod
32
+ key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
33
+ restore-keys: |
34
+ ${{ runner.os }}-go-
35
+ - name: Setup Go
36
+ uses: actions/setup-go@v2
37
+ with:
38
+ go-version: ${{ matrix.go-version }}
39
+ - name: Run tests
40
+ run: make test
41
+ - name: Run staticcheck
42
+ run: make staticcheck
43
+ ruby:
44
+ runs-on: ubuntu-latest
45
+ strategy:
46
+ matrix:
47
+ ruby-version: ["2.6", "2.7", "3.0"]
48
+ steps:
49
+ - name: Install libarrow
50
+ run: |
51
+ wget https://apache.bintray.com/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb
52
+ sudo apt install -y ./apache-arrow-archive-keyring-latest-$(lsb_release --codename --short).deb
53
+ sudo apt update
54
+ sudo apt install -y libarrow-dev libarrow-glib-dev libarrow-dataset-dev libplasma-dev libplasma-glib-dev libgandiva-dev libgandiva-glib-dev libparquet-dev libparquet-glib-dev
55
+ - uses: actions/checkout@v2
56
+ - uses: ruby/setup-ruby@v1
57
+ with:
58
+ ruby-version: ${{ matrix.ruby-version }}
59
+ bundler-cache: true
60
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .rubocop-*
2
2
  pkg/
3
3
  *~
4
+ *.makefile
data/.rubocop.yml CHANGED
@@ -1,6 +1,17 @@
1
- require: rubocop-performance
2
- inherit_from:
3
- - https://gitlab.com/bsm/misc/raw/master/rubocop/default.yml
1
+ inherit_gem:
2
+ rubocop-bsm:
3
+ - default.yml
4
+ inherit_mode:
5
+ merge:
6
+ - Exclude
4
7
 
5
8
  AllCops:
6
- TargetRubyVersion: "2.4"
9
+ TargetRubyVersion: 2.6
10
+ Naming/MethodParameterName:
11
+ MinNameLength: 2
12
+ Naming/MemoizedInstanceVariableName:
13
+ Enabled: false
14
+ Naming/FileName:
15
+ Exclude: [lib/sortable-by.rb]
16
+ Metrics/ParameterLists:
17
+ Max: 8
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
4
- gem 'google-protobuf', '>= 3.7.0-rc2'
data/Gemfile.lock CHANGED
@@ -1,70 +1,102 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feedx (0.11.0)
5
- bfs (>= 0.5.0)
4
+ feedx (0.12.5)
5
+ bfs (>= 0.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
11
- bfs (0.7.0)
12
- diff-lcs (1.3)
13
- extpp (0.0.8)
14
- gio2 (3.4.3)
15
- gobject-introspection (= 3.4.3)
16
- glib2 (3.4.3)
10
+ activesupport (6.1.3.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ ast (2.4.2)
17
+ bfs (0.8.1)
18
+ bigdecimal (3.0.2)
19
+ concurrent-ruby (1.1.8)
20
+ diff-lcs (1.4.4)
21
+ extpp (0.0.9)
22
+ gio2 (3.4.4)
23
+ gobject-introspection (= 3.4.4)
24
+ glib2 (3.4.4)
17
25
  native-package-installer (>= 1.0.3)
18
26
  pkg-config (>= 1.3.5)
19
- gobject-introspection (3.4.3)
20
- glib2 (= 3.4.3)
21
- google-protobuf (3.12.2)
22
- native-package-installer (1.0.9)
23
- parallel (1.19.1)
24
- parser (2.7.1.3)
25
- ast (~> 2.4.0)
26
- pbio (0.2.1)
27
+ gobject-introspection (3.4.4)
28
+ glib2 (= 3.4.4)
29
+ google-protobuf (3.15.8)
30
+ i18n (1.8.10)
31
+ concurrent-ruby (~> 1.0)
32
+ minitest (5.14.4)
33
+ native-package-installer (1.1.1)
34
+ parallel (1.20.1)
35
+ parser (3.0.1.1)
36
+ ast (~> 2.4.1)
37
+ pbio (0.2.2)
27
38
  google-protobuf
28
- pkg-config (1.4.1)
39
+ pkg-config (1.4.6)
40
+ rack (2.2.3)
29
41
  rainbow (3.0.0)
30
- rake (13.0.1)
31
- red-arrow (0.17.1)
42
+ rake (13.0.3)
43
+ red-arrow (3.0.0)
44
+ bigdecimal (>= 2.0.3)
32
45
  extpp (>= 0.0.7)
33
46
  gio2 (>= 3.3.6)
34
47
  native-package-installer
35
48
  pkg-config
36
- red-parquet (0.17.1)
37
- red-arrow (= 0.17.1)
38
- regexp_parser (1.7.1)
39
- rexml (3.2.4)
40
- rspec (3.9.0)
41
- rspec-core (~> 3.9.0)
42
- rspec-expectations (~> 3.9.0)
43
- rspec-mocks (~> 3.9.0)
44
- rspec-core (3.9.2)
45
- rspec-support (~> 3.9.3)
46
- rspec-expectations (3.9.2)
49
+ red-parquet (3.0.0)
50
+ red-arrow (= 3.0.0)
51
+ regexp_parser (2.1.1)
52
+ rexml (3.2.5)
53
+ rspec (3.10.0)
54
+ rspec-core (~> 3.10.0)
55
+ rspec-expectations (~> 3.10.0)
56
+ rspec-mocks (~> 3.10.0)
57
+ rspec-core (3.10.1)
58
+ rspec-support (~> 3.10.0)
59
+ rspec-expectations (3.10.1)
47
60
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.9.0)
49
- rspec-mocks (3.9.1)
61
+ rspec-support (~> 3.10.0)
62
+ rspec-mocks (3.10.2)
50
63
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.9.0)
52
- rspec-support (3.9.3)
53
- rubocop (0.85.1)
64
+ rspec-support (~> 3.10.0)
65
+ rspec-support (3.10.2)
66
+ rubocop (1.13.0)
54
67
  parallel (~> 1.10)
55
- parser (>= 2.7.0.1)
68
+ parser (>= 3.0.0.0)
56
69
  rainbow (>= 2.2.2, < 4.0)
57
- regexp_parser (>= 1.7)
70
+ regexp_parser (>= 1.8, < 3.0)
58
71
  rexml
59
- rubocop-ast (>= 0.0.3)
72
+ rubocop-ast (>= 1.2.0, < 2.0)
60
73
  ruby-progressbar (~> 1.7)
61
- unicode-display_width (>= 1.4.0, < 2.0)
62
- rubocop-ast (0.0.3)
63
- parser (>= 2.7.0.1)
64
- rubocop-performance (1.6.1)
65
- rubocop (>= 0.71.0)
66
- ruby-progressbar (1.10.1)
67
- unicode-display_width (1.7.0)
74
+ unicode-display_width (>= 1.4.0, < 3.0)
75
+ rubocop-ast (1.5.0)
76
+ parser (>= 3.0.1.1)
77
+ rubocop-bsm (0.5.9)
78
+ rubocop (~> 1.0)
79
+ rubocop-performance
80
+ rubocop-rails
81
+ rubocop-rake
82
+ rubocop-rspec
83
+ rubocop-performance (1.11.1)
84
+ rubocop (>= 1.7.0, < 2.0)
85
+ rubocop-ast (>= 0.4.0)
86
+ rubocop-rails (2.9.1)
87
+ activesupport (>= 4.2.0)
88
+ rack (>= 1.1)
89
+ rubocop (>= 0.90.0, < 2.0)
90
+ rubocop-rake (0.5.1)
91
+ rubocop
92
+ rubocop-rspec (2.3.0)
93
+ rubocop (~> 1.0)
94
+ rubocop-ast (>= 1.1.0)
95
+ ruby-progressbar (1.11.0)
96
+ tzinfo (2.0.4)
97
+ concurrent-ruby (~> 1.0)
98
+ unicode-display_width (2.0.0)
99
+ zeitwerk (2.4.2)
68
100
 
69
101
  PLATFORMS
70
102
  ruby
@@ -72,13 +104,11 @@ PLATFORMS
72
104
  DEPENDENCIES
73
105
  bundler
74
106
  feedx!
75
- google-protobuf (>= 3.7.0.pre.rc2)
76
107
  pbio
77
108
  rake
78
- red-parquet
109
+ red-parquet (>= 3.0, < 4.0)
79
110
  rspec
80
- rubocop
81
- rubocop-performance
111
+ rubocop-bsm
82
112
 
83
113
  BUNDLED WITH
84
114
  2.1.4
data/Makefile CHANGED
@@ -1,12 +1,12 @@
1
- default: vet test
1
+ default: test
2
2
 
3
- test:
4
- go test ./...
3
+ .common.makefile:
4
+ curl -fsSL -o $@ https://gitlab.com/bsm/misc/raw/master/make/go/common.makefile
5
5
 
6
- vet:
7
- go vet ./...
6
+ include .common.makefile
8
7
 
9
8
  proto: internal/testdata/testdata.pb.go
10
9
 
11
10
  %.pb.go: %.proto
12
- protoc -I=. --gogo_out=paths=source_relative:. $<
11
+ # may need to `go install google.golang.org/protobuf/cmd/protoc-gen-go`
12
+ protoc -I=. --go_out=paths=source_relative:. $<
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Feedx
2
2
 
3
- [![Build Status](https://travis-ci.org/bsm/feedx.png?branch=master)](https://travis-ci.org/bsm/feedx)
3
+ [![Test](https://github.com/bsm/feedx/actions/workflows/test.yml/badge.svg)](https://github.com/bsm/feedx/actions/workflows/test.yml)
4
4
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5
5
 
6
6
  Feed-based data exchange between services.
data/compression.go CHANGED
@@ -1,6 +1,7 @@
1
1
  package feedx
2
2
 
3
3
  import (
4
+ "compress/flate"
4
5
  "compress/gzip"
5
6
  "io"
6
7
  "path"
@@ -20,6 +21,8 @@ func DetectCompression(name string) Compression {
20
21
  ext := path.Ext(path.Base(name))
21
22
  if ext != "" && ext[0] == '.' && ext[len(ext)-1] == 'z' {
22
23
  return GZipCompression
24
+ } else if ext == ".flate" {
25
+ return FlateCompression
23
26
  }
24
27
  }
25
28
  return NoCompression
@@ -61,3 +64,18 @@ func (gzipCompression) NewReader(r io.Reader) (io.ReadCloser, error) {
61
64
  func (gzipCompression) NewWriter(w io.Writer) (io.WriteCloser, error) {
62
65
  return gzip.NewWriter(w), nil
63
66
  }
67
+
68
+ // --------------------------------------------------------------------
69
+
70
+ // FlateCompression supports flate compression format.
71
+ var FlateCompression = flateCompression{}
72
+
73
+ type flateCompression struct{}
74
+
75
+ func (flateCompression) NewReader(r io.Reader) (io.ReadCloser, error) {
76
+ return flate.NewReader(r), nil
77
+ }
78
+
79
+ func (flateCompression) NewWriter(w io.Writer) (io.WriteCloser, error) {
80
+ return flate.NewWriter(w, flate.BestSpeed)
81
+ }
data/compression_test.go CHANGED
@@ -4,8 +4,8 @@ import (
4
4
  "bytes"
5
5
 
6
6
  "github.com/bsm/feedx"
7
- . "github.com/onsi/ginkgo"
8
- . "github.com/onsi/gomega"
7
+ . "github.com/bsm/ginkgo"
8
+ . "github.com/bsm/gomega"
9
9
  )
10
10
 
11
11
  var _ = Describe("Compression", func() {
@@ -41,6 +41,9 @@ var _ = Describe("Compression", func() {
41
41
  Expect(feedx.DetectCompression("/path/to/file.pb.gz")).To(Equal(feedx.GZipCompression))
42
42
  Expect(feedx.DetectCompression("/path/to/file.pbz")).To(Equal(feedx.GZipCompression))
43
43
 
44
+ Expect(feedx.DetectCompression("/path/to/file.flate")).To(Equal(feedx.FlateCompression))
45
+ Expect(feedx.DetectCompression("/path/to/file.whatever.flate")).To(Equal(feedx.FlateCompression))
46
+
44
47
  Expect(feedx.DetectCompression("")).To(Equal(feedx.NoCompression))
45
48
  Expect(feedx.DetectCompression("/path/to/file")).To(Equal(feedx.NoCompression))
46
49
  Expect(feedx.DetectCompression("/path/to/file.txt")).To(Equal(feedx.NoCompression))
@@ -63,4 +66,13 @@ var _ = Describe("Compression", func() {
63
66
  runSharedTest(subject)
64
67
  })
65
68
  })
69
+
70
+ Describe("FlateCompression", func() {
71
+ var subject = feedx.FlateCompression
72
+ var _ feedx.Compression = subject
73
+
74
+ It("should write/read", func() {
75
+ runSharedTest(subject)
76
+ })
77
+ })
66
78
  })
data/consumer_test.go CHANGED
@@ -8,8 +8,8 @@ import (
8
8
  "github.com/bsm/bfs"
9
9
  "github.com/bsm/feedx"
10
10
  "github.com/bsm/feedx/internal/testdata"
11
- . "github.com/onsi/ginkgo"
12
- . "github.com/onsi/gomega"
11
+ . "github.com/bsm/ginkgo"
12
+ . "github.com/bsm/gomega"
13
13
  )
14
14
 
15
15
  var _ = Describe("Consumer", func() {
@@ -0,0 +1,170 @@
1
+ package parquet
2
+
3
+ import (
4
+ "encoding/binary"
5
+ "fmt"
6
+ "io"
7
+ "reflect"
8
+ "time"
9
+
10
+ kpq "github.com/bsm/parquet-go/parquet"
11
+ )
12
+
13
+ type decoder struct {
14
+ cols []*columnReader
15
+ closers []io.Closer
16
+ }
17
+
18
+ func newDecoder(rs io.ReadSeeker, names []string, batchSize int) (*decoder, error) {
19
+ file, err := kpq.FileFromReader(rs)
20
+ if err != nil {
21
+ return nil, err
22
+ }
23
+
24
+ // normalise column names
25
+ if len(names) == 0 {
26
+ for _, c := range file.Schema.Columns() {
27
+ names = append(names, c.String())
28
+ }
29
+ }
30
+
31
+ // normalise batch size
32
+ if batchSize < 1 {
33
+ batchSize = 1000
34
+ }
35
+
36
+ // initialise column buffers
37
+ cols := make([]*columnReader, 0, len(names))
38
+ for _, name := range names {
39
+ col, ok := file.Schema.ColumnByName(name)
40
+ if !ok {
41
+ _ = file.Close()
42
+ return nil, fmt.Errorf("column %q does not exist", name)
43
+ }
44
+ cols = append(cols, newColumnReader(file, col, batchSize))
45
+ }
46
+
47
+ return &decoder{cols: cols, closers: []io.Closer{file}}, nil
48
+ }
49
+
50
+ func (w *decoder) Decode(v interface{}) error {
51
+ rv := reflect.ValueOf(v)
52
+ rt := rv.Type()
53
+ if rt.Kind() != reflect.Ptr {
54
+ return fmt.Errorf("cannot decode non-pointer %s type", rt.String())
55
+ }
56
+
57
+ // field index by name
58
+ fidx := cachedTypeFields(rt.Elem())
59
+ elem := rv.Elem()
60
+
61
+ for _, r := range w.cols {
62
+ // next column value
63
+ val, err := r.Next()
64
+ if err != nil {
65
+ return err
66
+ }
67
+
68
+ // skip if value is NULL
69
+ if val == nil {
70
+ continue
71
+ }
72
+
73
+ // set field if exists
74
+ if fi, ok := fidx[r.Name()]; ok {
75
+ fv := elem.Field(fi)
76
+ if ok := setValue(fv, val); !ok {
77
+ return fmt.Errorf("cannot assign value of type %T to %s", val, fv.Type())
78
+ }
79
+ }
80
+ }
81
+
82
+ return nil
83
+ }
84
+
85
+ func (w *decoder) Close() (err error) {
86
+ for _, c := range w.closers {
87
+ if e := c.Close(); e != nil {
88
+ err = e
89
+ }
90
+ }
91
+ return
92
+ }
93
+
94
+ // --------------------------------------------------------------------
95
+
96
+ func setValue(rv reflect.Value, v interface{}) bool {
97
+ if rv.Kind() == reflect.Ptr {
98
+ if rv.IsNil() {
99
+ if ev := reflect.New(rv.Type().Elem()); setValue(ev, v) {
100
+ rv.Set(ev)
101
+ return true
102
+ }
103
+ return false
104
+ }
105
+ return setValue(rv.Elem(), v)
106
+ }
107
+
108
+ switch vv := v.(type) {
109
+ case bool:
110
+ switch rv.Kind() {
111
+ case reflect.Bool:
112
+ rv.SetBool(vv)
113
+ return true
114
+ }
115
+ case []byte:
116
+ switch rv.Kind() {
117
+ case reflect.String:
118
+ rv.SetString(string(vv))
119
+ return true
120
+ case reflect.Slice:
121
+ if rv.Type() == byteSliceType {
122
+ rv.SetBytes(vv)
123
+ return true
124
+ }
125
+ }
126
+ case int, int8, int16, int32, int64:
127
+ switch rv.Kind() {
128
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
129
+ rv.SetInt(reflect.ValueOf(v).Int())
130
+ return true
131
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
132
+ rv.SetUint(uint64(reflect.ValueOf(v).Int()))
133
+ return true
134
+ }
135
+ case uint, uint8, uint16, uint32, uint64:
136
+ switch rv.Kind() {
137
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
138
+ rv.SetInt(int64(reflect.ValueOf(v).Uint()))
139
+ return true
140
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
141
+ rv.SetUint(reflect.ValueOf(v).Uint())
142
+ return true
143
+ }
144
+ case float32, float64:
145
+ switch rv.Kind() {
146
+ case reflect.Float32, reflect.Float64:
147
+ rv.SetFloat(reflect.ValueOf(v).Float())
148
+ return true
149
+ }
150
+ case kpq.Int96:
151
+ if rt := rv.Type(); rt == timeType {
152
+ ns := int64(binary.LittleEndian.Uint64(vv[:8]))
153
+ jd := int64(binary.LittleEndian.Uint32(vv[8:]))
154
+ ts := time.Unix((jd-2440588)*86400, ns)
155
+ rv.Set(reflect.ValueOf(ts))
156
+ return true
157
+ } else if rt == int96Type {
158
+ rv.Set(reflect.ValueOf(v))
159
+ return true
160
+ }
161
+ }
162
+
163
+ return false
164
+ }
165
+
166
+ var (
167
+ byteSliceType = reflect.TypeOf(([]byte)(nil))
168
+ int96Type = reflect.TypeOf(kpq.Int96{})
169
+ timeType = reflect.TypeOf(time.Time{})
170
+ )