Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 9b11881

Browse files
author
Abraham Adberstein
committed
added block write column function for IP
1 parent 6b1ba59 commit 9b11881

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

clickhouse_columnar_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package clickhouse_test
22

33
import (
44
"database/sql/driver"
5+
"net"
56
"reflect"
67
"testing"
78
"time"
@@ -30,7 +31,9 @@ func Test_ColumnarInsert(t *testing.T) {
3031
array Array(String),
3132
arrayArray Array(Array(String)),
3233
arrayWithValue Array(UInt64),
33-
arrayWithValueFast Array(UInt64)
34+
arrayWithValueFast Array(UInt64),
35+
ipv4 IPv4,
36+
ipv6 IPv6
3437
) Engine=Memory
3538
`
3639
dml = `
@@ -50,7 +53,9 @@ func Test_ColumnarInsert(t *testing.T) {
5053
array,
5154
arrayArray,
5255
arrayWithValue,
53-
arrayWithValueFast
56+
arrayWithValueFast,
57+
ipv4,
58+
ipv6
5459
) VALUES (
5560
?,
5661
?,
@@ -65,6 +70,8 @@ func Test_ColumnarInsert(t *testing.T) {
6570
?,
6671
?,
6772
?,
73+
?,
74+
?,
6875
?
6976
)
7077
`
@@ -113,6 +120,8 @@ func Test_ColumnarInsert(t *testing.T) {
113120
block.WriteArray(13, [][]string{[]string{"A", "B"}, []string{"CC", "DD", "EE"}})
114121
block.WriteArrayWithValue(14, newUint64SliceValueSimple([]uint64{1, 2, 3}))
115122
block.WriteArrayWithValue(15, newUint64SliceValueFast([]uint64{10, 20, 30}))
123+
block.WriteIP(16, net.ParseIP("213.180.204.62"))
124+
block.WriteIP(17, net.ParseIP("2606:4700:5c::a29f:2e07"))
116125
if !assert.NoError(t, err) {
117126
return
118127
}

lib/data/block_write_column.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package data
22

33
import (
44
"fmt"
5+
"net"
56
"reflect"
67
"time"
78

@@ -89,6 +90,10 @@ func (block *Block) WriteFixedString(c int, v []byte) error {
8990
return block.Columns[c].Write(block.buffers[c].Column, v)
9091
}
9192

93+
func (block *Block) WriteIP(c int, v net.IP) error {
94+
return block.Columns[c].Write(block.buffers[c].Column, v)
95+
}
96+
9297
func (block *Block) WriteArray(c int, v interface{}) error {
9398
return block.WriteArrayWithValue(c, newValue(reflect.ValueOf(v)))
9499
}

0 commit comments

Comments
 (0)