MCPcopy
hub / github.com/dgraph-io/dgraph / encodeIndex

Function encodeIndex

edgraph/server.go:2516–2525  ·  view source on GitHub ↗

encodeBit two uint32 numbers by bit. First 32 bits store k1 and last 32 bits store k2.

(k1, k2 int)

Source from the content-addressed store, hash-verified

2514// encodeBit two uint32 numbers by bit.
2515// First 32 bits store k1 and last 32 bits store k2.
2516func encodeIndex(k1, k2 int) uint64 {
2517 safeToConvert := func(num int) {
2518 if num > math.MaxUint32 {
2519 panic("unsafe conversion: integer value is too large for uint32")
2520 }
2521 }
2522 safeToConvert(k1)
2523 safeToConvert(k2)
2524 return uint64(uint32(k1))<<32 | uint64(uint32(k2))
2525}
2526
2527func decodeIndex(pair uint64) (uint32, uint32) {
2528 k1 := uint32(pair >> 32)

Callers 2

addQueryIfUniqueFunction · 0.85

Calls

no outgoing calls