]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/go/arrow/type_traits_numeric.gen.go
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / go / arrow / type_traits_numeric.gen.go
1 // Code generated by type_traits_numeric.gen.go.tmpl. DO NOT EDIT.
2
3 // Licensed to the Apache Software Foundation (ASF) under one
4 // or more contributor license agreements. See the NOTICE file
5 // distributed with this work for additional information
6 // regarding copyright ownership. The ASF licenses this file
7 // to you under the Apache License, Version 2.0 (the
8 // "License"); you may not use this file except in compliance
9 // with the License. You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18
19 package arrow // import "github.com/apache/arrow/go/v6/arrow"
20
21 import (
22 "math"
23 "reflect"
24 "unsafe"
25
26 "github.com/apache/arrow/go/v6/arrow/endian"
27 )
28
29 var (
30 Int64Traits int64Traits
31 Uint64Traits uint64Traits
32 Float64Traits float64Traits
33 Int32Traits int32Traits
34 Uint32Traits uint32Traits
35 Float32Traits float32Traits
36 Int16Traits int16Traits
37 Uint16Traits uint16Traits
38 Int8Traits int8Traits
39 Uint8Traits uint8Traits
40 TimestampTraits timestampTraits
41 Time32Traits time32Traits
42 Time64Traits time64Traits
43 Date32Traits date32Traits
44 Date64Traits date64Traits
45 DurationTraits durationTraits
46 )
47
48 // Int64 traits
49
50 const (
51 // Int64SizeBytes specifies the number of bytes required to store a single int64 in memory
52 Int64SizeBytes = int(unsafe.Sizeof(int64(0)))
53 )
54
55 type int64Traits struct{}
56
57 // BytesRequired returns the number of bytes required to store n elements in memory.
58 func (int64Traits) BytesRequired(n int) int { return Int64SizeBytes * n }
59
60 // PutValue
61 func (int64Traits) PutValue(b []byte, v int64) {
62 endian.Native.PutUint64(b, uint64(v))
63 }
64
65 // CastFromBytes reinterprets the slice b to a slice of type int64.
66 //
67 // NOTE: len(b) must be a multiple of Int64SizeBytes.
68 func (int64Traits) CastFromBytes(b []byte) []int64 {
69 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
70
71 var res []int64
72 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
73 s.Data = h.Data
74 s.Len = h.Len / Int64SizeBytes
75 s.Cap = h.Cap / Int64SizeBytes
76
77 return res
78 }
79
80 // CastToBytes reinterprets the slice b to a slice of bytes.
81 func (int64Traits) CastToBytes(b []int64) []byte {
82 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
83
84 var res []byte
85 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
86 s.Data = h.Data
87 s.Len = h.Len * Int64SizeBytes
88 s.Cap = h.Cap * Int64SizeBytes
89
90 return res
91 }
92
93 // Copy copies src to dst.
94 func (int64Traits) Copy(dst, src []int64) { copy(dst, src) }
95
96 // Uint64 traits
97
98 const (
99 // Uint64SizeBytes specifies the number of bytes required to store a single uint64 in memory
100 Uint64SizeBytes = int(unsafe.Sizeof(uint64(0)))
101 )
102
103 type uint64Traits struct{}
104
105 // BytesRequired returns the number of bytes required to store n elements in memory.
106 func (uint64Traits) BytesRequired(n int) int { return Uint64SizeBytes * n }
107
108 // PutValue
109 func (uint64Traits) PutValue(b []byte, v uint64) {
110 endian.Native.PutUint64(b, uint64(v))
111 }
112
113 // CastFromBytes reinterprets the slice b to a slice of type uint64.
114 //
115 // NOTE: len(b) must be a multiple of Uint64SizeBytes.
116 func (uint64Traits) CastFromBytes(b []byte) []uint64 {
117 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
118
119 var res []uint64
120 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
121 s.Data = h.Data
122 s.Len = h.Len / Uint64SizeBytes
123 s.Cap = h.Cap / Uint64SizeBytes
124
125 return res
126 }
127
128 // CastToBytes reinterprets the slice b to a slice of bytes.
129 func (uint64Traits) CastToBytes(b []uint64) []byte {
130 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
131
132 var res []byte
133 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
134 s.Data = h.Data
135 s.Len = h.Len * Uint64SizeBytes
136 s.Cap = h.Cap * Uint64SizeBytes
137
138 return res
139 }
140
141 // Copy copies src to dst.
142 func (uint64Traits) Copy(dst, src []uint64) { copy(dst, src) }
143
144 // Float64 traits
145
146 const (
147 // Float64SizeBytes specifies the number of bytes required to store a single float64 in memory
148 Float64SizeBytes = int(unsafe.Sizeof(float64(0)))
149 )
150
151 type float64Traits struct{}
152
153 // BytesRequired returns the number of bytes required to store n elements in memory.
154 func (float64Traits) BytesRequired(n int) int { return Float64SizeBytes * n }
155
156 // PutValue
157 func (float64Traits) PutValue(b []byte, v float64) {
158 endian.Native.PutUint64(b, math.Float64bits(v))
159 }
160
161 // CastFromBytes reinterprets the slice b to a slice of type float64.
162 //
163 // NOTE: len(b) must be a multiple of Float64SizeBytes.
164 func (float64Traits) CastFromBytes(b []byte) []float64 {
165 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
166
167 var res []float64
168 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
169 s.Data = h.Data
170 s.Len = h.Len / Float64SizeBytes
171 s.Cap = h.Cap / Float64SizeBytes
172
173 return res
174 }
175
176 // CastToBytes reinterprets the slice b to a slice of bytes.
177 func (float64Traits) CastToBytes(b []float64) []byte {
178 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
179
180 var res []byte
181 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
182 s.Data = h.Data
183 s.Len = h.Len * Float64SizeBytes
184 s.Cap = h.Cap * Float64SizeBytes
185
186 return res
187 }
188
189 // Copy copies src to dst.
190 func (float64Traits) Copy(dst, src []float64) { copy(dst, src) }
191
192 // Int32 traits
193
194 const (
195 // Int32SizeBytes specifies the number of bytes required to store a single int32 in memory
196 Int32SizeBytes = int(unsafe.Sizeof(int32(0)))
197 )
198
199 type int32Traits struct{}
200
201 // BytesRequired returns the number of bytes required to store n elements in memory.
202 func (int32Traits) BytesRequired(n int) int { return Int32SizeBytes * n }
203
204 // PutValue
205 func (int32Traits) PutValue(b []byte, v int32) {
206 endian.Native.PutUint32(b, uint32(v))
207 }
208
209 // CastFromBytes reinterprets the slice b to a slice of type int32.
210 //
211 // NOTE: len(b) must be a multiple of Int32SizeBytes.
212 func (int32Traits) CastFromBytes(b []byte) []int32 {
213 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
214
215 var res []int32
216 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
217 s.Data = h.Data
218 s.Len = h.Len / Int32SizeBytes
219 s.Cap = h.Cap / Int32SizeBytes
220
221 return res
222 }
223
224 // CastToBytes reinterprets the slice b to a slice of bytes.
225 func (int32Traits) CastToBytes(b []int32) []byte {
226 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
227
228 var res []byte
229 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
230 s.Data = h.Data
231 s.Len = h.Len * Int32SizeBytes
232 s.Cap = h.Cap * Int32SizeBytes
233
234 return res
235 }
236
237 // Copy copies src to dst.
238 func (int32Traits) Copy(dst, src []int32) { copy(dst, src) }
239
240 // Uint32 traits
241
242 const (
243 // Uint32SizeBytes specifies the number of bytes required to store a single uint32 in memory
244 Uint32SizeBytes = int(unsafe.Sizeof(uint32(0)))
245 )
246
247 type uint32Traits struct{}
248
249 // BytesRequired returns the number of bytes required to store n elements in memory.
250 func (uint32Traits) BytesRequired(n int) int { return Uint32SizeBytes * n }
251
252 // PutValue
253 func (uint32Traits) PutValue(b []byte, v uint32) {
254 endian.Native.PutUint32(b, uint32(v))
255 }
256
257 // CastFromBytes reinterprets the slice b to a slice of type uint32.
258 //
259 // NOTE: len(b) must be a multiple of Uint32SizeBytes.
260 func (uint32Traits) CastFromBytes(b []byte) []uint32 {
261 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
262
263 var res []uint32
264 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
265 s.Data = h.Data
266 s.Len = h.Len / Uint32SizeBytes
267 s.Cap = h.Cap / Uint32SizeBytes
268
269 return res
270 }
271
272 // CastToBytes reinterprets the slice b to a slice of bytes.
273 func (uint32Traits) CastToBytes(b []uint32) []byte {
274 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
275
276 var res []byte
277 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
278 s.Data = h.Data
279 s.Len = h.Len * Uint32SizeBytes
280 s.Cap = h.Cap * Uint32SizeBytes
281
282 return res
283 }
284
285 // Copy copies src to dst.
286 func (uint32Traits) Copy(dst, src []uint32) { copy(dst, src) }
287
288 // Float32 traits
289
290 const (
291 // Float32SizeBytes specifies the number of bytes required to store a single float32 in memory
292 Float32SizeBytes = int(unsafe.Sizeof(float32(0)))
293 )
294
295 type float32Traits struct{}
296
297 // BytesRequired returns the number of bytes required to store n elements in memory.
298 func (float32Traits) BytesRequired(n int) int { return Float32SizeBytes * n }
299
300 // PutValue
301 func (float32Traits) PutValue(b []byte, v float32) {
302 endian.Native.PutUint32(b, math.Float32bits(v))
303 }
304
305 // CastFromBytes reinterprets the slice b to a slice of type float32.
306 //
307 // NOTE: len(b) must be a multiple of Float32SizeBytes.
308 func (float32Traits) CastFromBytes(b []byte) []float32 {
309 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
310
311 var res []float32
312 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
313 s.Data = h.Data
314 s.Len = h.Len / Float32SizeBytes
315 s.Cap = h.Cap / Float32SizeBytes
316
317 return res
318 }
319
320 // CastToBytes reinterprets the slice b to a slice of bytes.
321 func (float32Traits) CastToBytes(b []float32) []byte {
322 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
323
324 var res []byte
325 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
326 s.Data = h.Data
327 s.Len = h.Len * Float32SizeBytes
328 s.Cap = h.Cap * Float32SizeBytes
329
330 return res
331 }
332
333 // Copy copies src to dst.
334 func (float32Traits) Copy(dst, src []float32) { copy(dst, src) }
335
336 // Int16 traits
337
338 const (
339 // Int16SizeBytes specifies the number of bytes required to store a single int16 in memory
340 Int16SizeBytes = int(unsafe.Sizeof(int16(0)))
341 )
342
343 type int16Traits struct{}
344
345 // BytesRequired returns the number of bytes required to store n elements in memory.
346 func (int16Traits) BytesRequired(n int) int { return Int16SizeBytes * n }
347
348 // PutValue
349 func (int16Traits) PutValue(b []byte, v int16) {
350 endian.Native.PutUint16(b, uint16(v))
351 }
352
353 // CastFromBytes reinterprets the slice b to a slice of type int16.
354 //
355 // NOTE: len(b) must be a multiple of Int16SizeBytes.
356 func (int16Traits) CastFromBytes(b []byte) []int16 {
357 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
358
359 var res []int16
360 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
361 s.Data = h.Data
362 s.Len = h.Len / Int16SizeBytes
363 s.Cap = h.Cap / Int16SizeBytes
364
365 return res
366 }
367
368 // CastToBytes reinterprets the slice b to a slice of bytes.
369 func (int16Traits) CastToBytes(b []int16) []byte {
370 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
371
372 var res []byte
373 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
374 s.Data = h.Data
375 s.Len = h.Len * Int16SizeBytes
376 s.Cap = h.Cap * Int16SizeBytes
377
378 return res
379 }
380
381 // Copy copies src to dst.
382 func (int16Traits) Copy(dst, src []int16) { copy(dst, src) }
383
384 // Uint16 traits
385
386 const (
387 // Uint16SizeBytes specifies the number of bytes required to store a single uint16 in memory
388 Uint16SizeBytes = int(unsafe.Sizeof(uint16(0)))
389 )
390
391 type uint16Traits struct{}
392
393 // BytesRequired returns the number of bytes required to store n elements in memory.
394 func (uint16Traits) BytesRequired(n int) int { return Uint16SizeBytes * n }
395
396 // PutValue
397 func (uint16Traits) PutValue(b []byte, v uint16) {
398 endian.Native.PutUint16(b, uint16(v))
399 }
400
401 // CastFromBytes reinterprets the slice b to a slice of type uint16.
402 //
403 // NOTE: len(b) must be a multiple of Uint16SizeBytes.
404 func (uint16Traits) CastFromBytes(b []byte) []uint16 {
405 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
406
407 var res []uint16
408 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
409 s.Data = h.Data
410 s.Len = h.Len / Uint16SizeBytes
411 s.Cap = h.Cap / Uint16SizeBytes
412
413 return res
414 }
415
416 // CastToBytes reinterprets the slice b to a slice of bytes.
417 func (uint16Traits) CastToBytes(b []uint16) []byte {
418 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
419
420 var res []byte
421 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
422 s.Data = h.Data
423 s.Len = h.Len * Uint16SizeBytes
424 s.Cap = h.Cap * Uint16SizeBytes
425
426 return res
427 }
428
429 // Copy copies src to dst.
430 func (uint16Traits) Copy(dst, src []uint16) { copy(dst, src) }
431
432 // Int8 traits
433
434 const (
435 // Int8SizeBytes specifies the number of bytes required to store a single int8 in memory
436 Int8SizeBytes = int(unsafe.Sizeof(int8(0)))
437 )
438
439 type int8Traits struct{}
440
441 // BytesRequired returns the number of bytes required to store n elements in memory.
442 func (int8Traits) BytesRequired(n int) int { return Int8SizeBytes * n }
443
444 // PutValue
445 func (int8Traits) PutValue(b []byte, v int8) {
446 b[0] = byte(v)
447 }
448
449 // CastFromBytes reinterprets the slice b to a slice of type int8.
450 //
451 // NOTE: len(b) must be a multiple of Int8SizeBytes.
452 func (int8Traits) CastFromBytes(b []byte) []int8 {
453 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
454
455 var res []int8
456 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
457 s.Data = h.Data
458 s.Len = h.Len / Int8SizeBytes
459 s.Cap = h.Cap / Int8SizeBytes
460
461 return res
462 }
463
464 // CastToBytes reinterprets the slice b to a slice of bytes.
465 func (int8Traits) CastToBytes(b []int8) []byte {
466 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
467
468 var res []byte
469 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
470 s.Data = h.Data
471 s.Len = h.Len * Int8SizeBytes
472 s.Cap = h.Cap * Int8SizeBytes
473
474 return res
475 }
476
477 // Copy copies src to dst.
478 func (int8Traits) Copy(dst, src []int8) { copy(dst, src) }
479
480 // Uint8 traits
481
482 const (
483 // Uint8SizeBytes specifies the number of bytes required to store a single uint8 in memory
484 Uint8SizeBytes = int(unsafe.Sizeof(uint8(0)))
485 )
486
487 type uint8Traits struct{}
488
489 // BytesRequired returns the number of bytes required to store n elements in memory.
490 func (uint8Traits) BytesRequired(n int) int { return Uint8SizeBytes * n }
491
492 // PutValue
493 func (uint8Traits) PutValue(b []byte, v uint8) {
494 b[0] = byte(v)
495 }
496
497 // CastFromBytes reinterprets the slice b to a slice of type uint8.
498 //
499 // NOTE: len(b) must be a multiple of Uint8SizeBytes.
500 func (uint8Traits) CastFromBytes(b []byte) []uint8 {
501 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
502
503 var res []uint8
504 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
505 s.Data = h.Data
506 s.Len = h.Len / Uint8SizeBytes
507 s.Cap = h.Cap / Uint8SizeBytes
508
509 return res
510 }
511
512 // CastToBytes reinterprets the slice b to a slice of bytes.
513 func (uint8Traits) CastToBytes(b []uint8) []byte {
514 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
515
516 var res []byte
517 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
518 s.Data = h.Data
519 s.Len = h.Len * Uint8SizeBytes
520 s.Cap = h.Cap * Uint8SizeBytes
521
522 return res
523 }
524
525 // Copy copies src to dst.
526 func (uint8Traits) Copy(dst, src []uint8) { copy(dst, src) }
527
528 // Timestamp traits
529
530 const (
531 // TimestampSizeBytes specifies the number of bytes required to store a single Timestamp in memory
532 TimestampSizeBytes = int(unsafe.Sizeof(Timestamp(0)))
533 )
534
535 type timestampTraits struct{}
536
537 // BytesRequired returns the number of bytes required to store n elements in memory.
538 func (timestampTraits) BytesRequired(n int) int { return TimestampSizeBytes * n }
539
540 // PutValue
541 func (timestampTraits) PutValue(b []byte, v Timestamp) {
542 endian.Native.PutUint64(b, uint64(v))
543 }
544
545 // CastFromBytes reinterprets the slice b to a slice of type Timestamp.
546 //
547 // NOTE: len(b) must be a multiple of TimestampSizeBytes.
548 func (timestampTraits) CastFromBytes(b []byte) []Timestamp {
549 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
550
551 var res []Timestamp
552 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
553 s.Data = h.Data
554 s.Len = h.Len / TimestampSizeBytes
555 s.Cap = h.Cap / TimestampSizeBytes
556
557 return res
558 }
559
560 // CastToBytes reinterprets the slice b to a slice of bytes.
561 func (timestampTraits) CastToBytes(b []Timestamp) []byte {
562 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
563
564 var res []byte
565 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
566 s.Data = h.Data
567 s.Len = h.Len * TimestampSizeBytes
568 s.Cap = h.Cap * TimestampSizeBytes
569
570 return res
571 }
572
573 // Copy copies src to dst.
574 func (timestampTraits) Copy(dst, src []Timestamp) { copy(dst, src) }
575
576 // Time32 traits
577
578 const (
579 // Time32SizeBytes specifies the number of bytes required to store a single Time32 in memory
580 Time32SizeBytes = int(unsafe.Sizeof(Time32(0)))
581 )
582
583 type time32Traits struct{}
584
585 // BytesRequired returns the number of bytes required to store n elements in memory.
586 func (time32Traits) BytesRequired(n int) int { return Time32SizeBytes * n }
587
588 // PutValue
589 func (time32Traits) PutValue(b []byte, v Time32) {
590 endian.Native.PutUint32(b, uint32(v))
591 }
592
593 // CastFromBytes reinterprets the slice b to a slice of type Time32.
594 //
595 // NOTE: len(b) must be a multiple of Time32SizeBytes.
596 func (time32Traits) CastFromBytes(b []byte) []Time32 {
597 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
598
599 var res []Time32
600 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
601 s.Data = h.Data
602 s.Len = h.Len / Time32SizeBytes
603 s.Cap = h.Cap / Time32SizeBytes
604
605 return res
606 }
607
608 // CastToBytes reinterprets the slice b to a slice of bytes.
609 func (time32Traits) CastToBytes(b []Time32) []byte {
610 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
611
612 var res []byte
613 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
614 s.Data = h.Data
615 s.Len = h.Len * Time32SizeBytes
616 s.Cap = h.Cap * Time32SizeBytes
617
618 return res
619 }
620
621 // Copy copies src to dst.
622 func (time32Traits) Copy(dst, src []Time32) { copy(dst, src) }
623
624 // Time64 traits
625
626 const (
627 // Time64SizeBytes specifies the number of bytes required to store a single Time64 in memory
628 Time64SizeBytes = int(unsafe.Sizeof(Time64(0)))
629 )
630
631 type time64Traits struct{}
632
633 // BytesRequired returns the number of bytes required to store n elements in memory.
634 func (time64Traits) BytesRequired(n int) int { return Time64SizeBytes * n }
635
636 // PutValue
637 func (time64Traits) PutValue(b []byte, v Time64) {
638 endian.Native.PutUint64(b, uint64(v))
639 }
640
641 // CastFromBytes reinterprets the slice b to a slice of type Time64.
642 //
643 // NOTE: len(b) must be a multiple of Time64SizeBytes.
644 func (time64Traits) CastFromBytes(b []byte) []Time64 {
645 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
646
647 var res []Time64
648 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
649 s.Data = h.Data
650 s.Len = h.Len / Time64SizeBytes
651 s.Cap = h.Cap / Time64SizeBytes
652
653 return res
654 }
655
656 // CastToBytes reinterprets the slice b to a slice of bytes.
657 func (time64Traits) CastToBytes(b []Time64) []byte {
658 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
659
660 var res []byte
661 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
662 s.Data = h.Data
663 s.Len = h.Len * Time64SizeBytes
664 s.Cap = h.Cap * Time64SizeBytes
665
666 return res
667 }
668
669 // Copy copies src to dst.
670 func (time64Traits) Copy(dst, src []Time64) { copy(dst, src) }
671
672 // Date32 traits
673
674 const (
675 // Date32SizeBytes specifies the number of bytes required to store a single Date32 in memory
676 Date32SizeBytes = int(unsafe.Sizeof(Date32(0)))
677 )
678
679 type date32Traits struct{}
680
681 // BytesRequired returns the number of bytes required to store n elements in memory.
682 func (date32Traits) BytesRequired(n int) int { return Date32SizeBytes * n }
683
684 // PutValue
685 func (date32Traits) PutValue(b []byte, v Date32) {
686 endian.Native.PutUint32(b, uint32(v))
687 }
688
689 // CastFromBytes reinterprets the slice b to a slice of type Date32.
690 //
691 // NOTE: len(b) must be a multiple of Date32SizeBytes.
692 func (date32Traits) CastFromBytes(b []byte) []Date32 {
693 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
694
695 var res []Date32
696 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
697 s.Data = h.Data
698 s.Len = h.Len / Date32SizeBytes
699 s.Cap = h.Cap / Date32SizeBytes
700
701 return res
702 }
703
704 // CastToBytes reinterprets the slice b to a slice of bytes.
705 func (date32Traits) CastToBytes(b []Date32) []byte {
706 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
707
708 var res []byte
709 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
710 s.Data = h.Data
711 s.Len = h.Len * Date32SizeBytes
712 s.Cap = h.Cap * Date32SizeBytes
713
714 return res
715 }
716
717 // Copy copies src to dst.
718 func (date32Traits) Copy(dst, src []Date32) { copy(dst, src) }
719
720 // Date64 traits
721
722 const (
723 // Date64SizeBytes specifies the number of bytes required to store a single Date64 in memory
724 Date64SizeBytes = int(unsafe.Sizeof(Date64(0)))
725 )
726
727 type date64Traits struct{}
728
729 // BytesRequired returns the number of bytes required to store n elements in memory.
730 func (date64Traits) BytesRequired(n int) int { return Date64SizeBytes * n }
731
732 // PutValue
733 func (date64Traits) PutValue(b []byte, v Date64) {
734 endian.Native.PutUint64(b, uint64(v))
735 }
736
737 // CastFromBytes reinterprets the slice b to a slice of type Date64.
738 //
739 // NOTE: len(b) must be a multiple of Date64SizeBytes.
740 func (date64Traits) CastFromBytes(b []byte) []Date64 {
741 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
742
743 var res []Date64
744 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
745 s.Data = h.Data
746 s.Len = h.Len / Date64SizeBytes
747 s.Cap = h.Cap / Date64SizeBytes
748
749 return res
750 }
751
752 // CastToBytes reinterprets the slice b to a slice of bytes.
753 func (date64Traits) CastToBytes(b []Date64) []byte {
754 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
755
756 var res []byte
757 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
758 s.Data = h.Data
759 s.Len = h.Len * Date64SizeBytes
760 s.Cap = h.Cap * Date64SizeBytes
761
762 return res
763 }
764
765 // Copy copies src to dst.
766 func (date64Traits) Copy(dst, src []Date64) { copy(dst, src) }
767
768 // Duration traits
769
770 const (
771 // DurationSizeBytes specifies the number of bytes required to store a single Duration in memory
772 DurationSizeBytes = int(unsafe.Sizeof(Duration(0)))
773 )
774
775 type durationTraits struct{}
776
777 // BytesRequired returns the number of bytes required to store n elements in memory.
778 func (durationTraits) BytesRequired(n int) int { return DurationSizeBytes * n }
779
780 // PutValue
781 func (durationTraits) PutValue(b []byte, v Duration) {
782 endian.Native.PutUint64(b, uint64(v))
783 }
784
785 // CastFromBytes reinterprets the slice b to a slice of type Duration.
786 //
787 // NOTE: len(b) must be a multiple of DurationSizeBytes.
788 func (durationTraits) CastFromBytes(b []byte) []Duration {
789 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
790
791 var res []Duration
792 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
793 s.Data = h.Data
794 s.Len = h.Len / DurationSizeBytes
795 s.Cap = h.Cap / DurationSizeBytes
796
797 return res
798 }
799
800 // CastToBytes reinterprets the slice b to a slice of bytes.
801 func (durationTraits) CastToBytes(b []Duration) []byte {
802 h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
803
804 var res []byte
805 s := (*reflect.SliceHeader)(unsafe.Pointer(&res))
806 s.Data = h.Data
807 s.Len = h.Len * DurationSizeBytes
808 s.Cap = h.Cap * DurationSizeBytes
809
810 return res
811 }
812
813 // Copy copies src to dst.
814 func (durationTraits) Copy(dst, src []Duration) { copy(dst, src) }