-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from go-faster/feat/speedup-ipv6
feat(proto): improve IPv6 column speed
- Loading branch information
Showing
9 changed files
with
263 additions
and
234 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | ||
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 |................| | ||
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 |................| | ||
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 |................| | ||
00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 |................| | ||
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 |................| | ||
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 |................| | ||
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 |................| | ||
00000080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 |................| | ||
00000090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 |................| | ||
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0a |................| | ||
000000b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0b |................| | ||
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c |................| | ||
000000d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d |................| | ||
000000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0e |................| | ||
000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0f |................| | ||
00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 |................| | ||
00000110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 |................| | ||
00000120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 |................| | ||
00000130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 |................| | ||
00000140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 |................| | ||
00000150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 |................| | ||
00000160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 |................| | ||
00000170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 |................| | ||
00000180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 |................| | ||
00000190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 |................| | ||
000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a |................| | ||
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1b |................| | ||
000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c |................| | ||
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1d |................| | ||
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1e |................| | ||
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1f |................| | ||
00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 |............... | | ||
00000210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 |...............!| | ||
00000220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 |..............."| | ||
00000230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 23 |...............#| | ||
00000240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 |...............$| | ||
00000250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 |...............%| | ||
00000260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 |...............&| | ||
00000270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 |...............'| | ||
00000280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 |...............(| | ||
00000290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 |...............)| | ||
000002a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2a |...............*| | ||
000002b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2b |...............+| | ||
000002c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2c |...............,| | ||
000002d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2d |...............-| | ||
000002e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2e |................| | ||
000002f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2f |.............../| | ||
00000300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 |...............0| | ||
00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 |...............1| | ||
00000010 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 |................| | ||
00000020 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 |................| | ||
00000030 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 |................| | ||
00000040 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 |................| | ||
00000050 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 00 |................| | ||
00000060 00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 |................| | ||
00000070 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 00 |................| | ||
00000080 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 |................| | ||
00000090 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 |................| | ||
000000a0 00 00 00 00 00 00 00 0a 00 00 00 00 00 00 00 00 |................| | ||
000000b0 00 00 00 00 00 00 00 0b 00 00 00 00 00 00 00 00 |................| | ||
000000c0 00 00 00 00 00 00 00 0c 00 00 00 00 00 00 00 00 |................| | ||
000000d0 00 00 00 00 00 00 00 0d 00 00 00 00 00 00 00 00 |................| | ||
000000e0 00 00 00 00 00 00 00 0e 00 00 00 00 00 00 00 00 |................| | ||
000000f0 00 00 00 00 00 00 00 0f 00 00 00 00 00 00 00 00 |................| | ||
00000100 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 |................| | ||
00000110 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 |................| | ||
00000120 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 |................| | ||
00000130 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 |................| | ||
00000140 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 |................| | ||
00000150 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 |................| | ||
00000160 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 |................| | ||
00000170 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 |................| | ||
00000180 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 |................| | ||
00000190 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 |................| | ||
000001a0 00 00 00 00 00 00 00 1a 00 00 00 00 00 00 00 00 |................| | ||
000001b0 00 00 00 00 00 00 00 1b 00 00 00 00 00 00 00 00 |................| | ||
000001c0 00 00 00 00 00 00 00 1c 00 00 00 00 00 00 00 00 |................| | ||
000001d0 00 00 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 |................| | ||
000001e0 00 00 00 00 00 00 00 1e 00 00 00 00 00 00 00 00 |................| | ||
000001f0 00 00 00 00 00 00 00 1f 00 00 00 00 00 00 00 00 |................| | ||
00000200 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 |....... ........| | ||
00000210 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 |.......!........| | ||
00000220 00 00 00 00 00 00 00 22 00 00 00 00 00 00 00 00 |......."........| | ||
00000230 00 00 00 00 00 00 00 23 00 00 00 00 00 00 00 00 |.......#........| | ||
00000240 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 |.......$........| | ||
00000250 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 |.......%........| | ||
00000260 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 |.......&........| | ||
00000270 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 |.......'........| | ||
00000280 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 |.......(........| | ||
00000290 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 |.......)........| | ||
000002a0 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00 00 |.......*........| | ||
000002b0 00 00 00 00 00 00 00 2b 00 00 00 00 00 00 00 00 |.......+........| | ||
000002c0 00 00 00 00 00 00 00 2c 00 00 00 00 00 00 00 00 |.......,........| | ||
000002d0 00 00 00 00 00 00 00 2d 00 00 00 00 00 00 00 00 |.......-........| | ||
000002e0 00 00 00 00 00 00 00 2e 00 00 00 00 00 00 00 00 |................| | ||
000002f0 00 00 00 00 00 00 00 2f 00 00 00 00 00 00 00 00 |......./........| | ||
00000300 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 |.......0........| | ||
00000310 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 |.......1........| |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,19 @@ | ||
package proto | ||
|
||
import ( | ||
"encoding/binary" | ||
|
||
"inet.af/netaddr" | ||
) | ||
|
||
// IPv6 represents UInt128 address as UInt128 number. | ||
// | ||
// Not using netaddr.IP because UInt128 is more efficient. | ||
// | ||
// Use ToIP helper for convenience. | ||
type IPv6 UInt128 | ||
// IPv6 represents IPv6 address. | ||
type IPv6 [16]byte | ||
|
||
// ToIP represents IPv6 as netaddr.IP. | ||
func (v IPv6) ToIP() netaddr.IP { | ||
var buf [16]byte | ||
binary.BigEndian.PutUint64(buf[0:8], v.High) | ||
binary.BigEndian.PutUint64(buf[8:16], v.Low) | ||
return netaddr.IPv6Raw(buf) | ||
return netaddr.IPv6Raw(v) | ||
} | ||
|
||
// ToIPv6 represents ip as IPv6. | ||
func ToIPv6(ip netaddr.IP) IPv6 { | ||
b := ip.As16() | ||
return IPv6{ | ||
High: binary.BigEndian.Uint64(b[0:8]), | ||
Low: binary.BigEndian.Uint64(b[8:16]), | ||
} | ||
} | ||
func ToIPv6(ip netaddr.IP) IPv6 { return ip.As16() } | ||
|
||
func binIPv6(b []byte) IPv6 { | ||
_ = b[:16] // bounds check hint to compiler; see golang.org/issue/14808 | ||
// Using BigEndian for IPv6 as per ClickHouse implementation. | ||
return IPv6{ | ||
High: binary.BigEndian.Uint64(b[0:8]), | ||
Low: binary.BigEndian.Uint64(b[8:16]), | ||
} | ||
} | ||
|
||
func binPutIPv6(b []byte, v IPv6) { | ||
_ = b[:16] // bounds check hint to compiler; see golang.org/issue/14808 | ||
// Using BigEndian for IPv6 as per ClickHouse implementation. | ||
binary.BigEndian.PutUint64(b[0:8], v.High) | ||
binary.BigEndian.PutUint64(b[8:16], v.Low) | ||
} | ||
func binIPv6(b []byte) IPv6 { return *(*[16]byte)(b) } | ||
func binPutIPv6(b []byte, v IPv6) { copy(b, v[:]) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters