MCPcopy Create free account
hub / github.com/PostHog/duckgres / encodeInt4

Function encodeInt4

server/types.go:350–379  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

348}
349
350func encodeInt4(v interface{}) []byte {
351 buf := make([]byte, 4)
352 var n int32
353 switch val := v.(type) {
354 case int:
355 n = int32(val)
356 case int8:
357 n = int32(val)
358 case int16:
359 n = int32(val)
360 case int32:
361 n = val
362 case int64:
363 n = int32(val)
364 case uint8:
365 n = int32(val)
366 case uint16:
367 n = int32(val)
368 case uint32:
369 n = int32(val)
370 case float32:
371 n = int32(val)
372 case float64:
373 n = int32(val)
374 default:
375 return nil
376 }
377 binary.BigEndian.PutUint32(buf, uint32(n))
378 return buf
379}
380
381func encodeInt8(v interface{}) []byte {
382 buf := make([]byte, 8)

Callers 2

TestEncodeInt4Function · 0.85
encodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEncodeInt4Function · 0.68