22
22
import org .apache .arrow .memory .BufferAllocator ;
23
23
import org .apache .arrow .memory .RootAllocator ;
24
24
import org .apache .arrow .vector .LargeVarBinaryVector ;
25
+ import org .apache .arrow .vector .LargeVarCharVector ;
25
26
import org .apache .arrow .vector .VarBinaryVector ;
27
+ import org .apache .arrow .vector .VarCharVector ;
26
28
import org .apache .arrow .vector .complex .impl .LargeVarBinaryWriterImpl ;
29
+ import org .apache .arrow .vector .complex .impl .LargeVarCharWriterImpl ;
27
30
import org .apache .arrow .vector .complex .impl .VarBinaryWriterImpl ;
31
+ import org .apache .arrow .vector .complex .impl .VarCharWriterImpl ;
32
+ import org .apache .arrow .vector .util .Text ;
28
33
import org .junit .After ;
29
34
import org .junit .Assert ;
30
35
import org .junit .Before ;
@@ -45,9 +50,9 @@ public void terminate() throws Exception {
45
50
}
46
51
47
52
@ Test
48
- public void testWriteByteArrayToVarBinary () {
53
+ public void testWriteByteArrayToVarBinary () throws Exception {
49
54
try (VarBinaryVector vector = new VarBinaryVector ("test" , allocator );
50
- VarBinaryWriterImpl writer = new VarBinaryWriterImpl (vector )) {
55
+ VarBinaryWriter writer = new VarBinaryWriterImpl (vector )) {
51
56
byte [] input = new byte [] { 0x01 , 0x02 };
52
57
writer .writeToVarBinary (input );
53
58
byte [] result = vector .get (0 );
@@ -56,9 +61,9 @@ public void testWriteByteArrayToVarBinary() {
56
61
}
57
62
58
63
@ Test
59
- public void testWriteByteArrayWithOffsetToVarBinary () {
64
+ public void testWriteByteArrayWithOffsetToVarBinary () throws Exception {
60
65
try (VarBinaryVector vector = new VarBinaryVector ("test" , allocator );
61
- VarBinaryWriterImpl writer = new VarBinaryWriterImpl (vector )) {
66
+ VarBinaryWriter writer = new VarBinaryWriterImpl (vector )) {
62
67
byte [] input = new byte [] { 0x01 , 0x02 };
63
68
writer .writeToVarBinary (input , 1 , 1 );
64
69
byte [] result = vector .get (0 );
@@ -67,9 +72,9 @@ public void testWriteByteArrayWithOffsetToVarBinary() {
67
72
}
68
73
69
74
@ Test
70
- public void testWriteByteBufferToVarBinary () {
75
+ public void testWriteByteBufferToVarBinary () throws Exception {
71
76
try (VarBinaryVector vector = new VarBinaryVector ("test" , allocator );
72
- VarBinaryWriterImpl writer = new VarBinaryWriterImpl (vector )) {
77
+ VarBinaryWriter writer = new VarBinaryWriterImpl (vector )) {
73
78
byte [] input = new byte [] { 0x01 , 0x02 };
74
79
ByteBuffer buffer = ByteBuffer .wrap (input );
75
80
writer .writeToVarBinary (buffer );
@@ -79,9 +84,9 @@ public void testWriteByteBufferToVarBinary() {
79
84
}
80
85
81
86
@ Test
82
- public void testWriteByteBufferWithOffsetToVarBinary () {
87
+ public void testWriteByteBufferWithOffsetToVarBinary () throws Exception {
83
88
try (VarBinaryVector vector = new VarBinaryVector ("test" , allocator );
84
- VarBinaryWriterImpl writer = new VarBinaryWriterImpl (vector )) {
89
+ VarBinaryWriter writer = new VarBinaryWriterImpl (vector )) {
85
90
byte [] input = new byte [] { 0x01 , 0x02 };
86
91
ByteBuffer buffer = ByteBuffer .wrap (input );
87
92
writer .writeToVarBinary (buffer , 1 , 1 );
@@ -91,9 +96,9 @@ public void testWriteByteBufferWithOffsetToVarBinary() {
91
96
}
92
97
93
98
@ Test
94
- public void testWriteByteArrayToLargeVarBinary () {
99
+ public void testWriteByteArrayToLargeVarBinary () throws Exception {
95
100
try (LargeVarBinaryVector vector = new LargeVarBinaryVector ("test" , allocator );
96
- LargeVarBinaryWriterImpl writer = new LargeVarBinaryWriterImpl (vector )) {
101
+ LargeVarBinaryWriter writer = new LargeVarBinaryWriterImpl (vector )) {
97
102
byte [] input = new byte [] { 0x01 , 0x02 };
98
103
writer .writeToLargeVarBinary (input );
99
104
byte [] result = vector .get (0 );
@@ -102,9 +107,9 @@ public void testWriteByteArrayToLargeVarBinary() {
102
107
}
103
108
104
109
@ Test
105
- public void testWriteByteArrayWithOffsetToLargeVarBinary () {
110
+ public void testWriteByteArrayWithOffsetToLargeVarBinary () throws Exception {
106
111
try (LargeVarBinaryVector vector = new LargeVarBinaryVector ("test" , allocator );
107
- LargeVarBinaryWriterImpl writer = new LargeVarBinaryWriterImpl (vector )) {
112
+ LargeVarBinaryWriter writer = new LargeVarBinaryWriterImpl (vector )) {
108
113
byte [] input = new byte [] { 0x01 , 0x02 };
109
114
writer .writeToLargeVarBinary (input , 1 , 1 );
110
115
byte [] result = vector .get (0 );
@@ -113,9 +118,9 @@ public void testWriteByteArrayWithOffsetToLargeVarBinary() {
113
118
}
114
119
115
120
@ Test
116
- public void testWriteByteBufferToLargeVarBinary () {
121
+ public void testWriteByteBufferToLargeVarBinary () throws Exception {
117
122
try (LargeVarBinaryVector vector = new LargeVarBinaryVector ("test" , allocator );
118
- LargeVarBinaryWriterImpl writer = new LargeVarBinaryWriterImpl (vector )) {
123
+ LargeVarBinaryWriter writer = new LargeVarBinaryWriterImpl (vector )) {
119
124
byte [] input = new byte [] { 0x01 , 0x02 };
120
125
ByteBuffer buffer = ByteBuffer .wrap (input );
121
126
writer .writeToLargeVarBinary (buffer );
@@ -125,14 +130,58 @@ public void testWriteByteBufferToLargeVarBinary() {
125
130
}
126
131
127
132
@ Test
128
- public void testWriteByteBufferWithOffsetToLargeVarBinary () {
133
+ public void testWriteByteBufferWithOffsetToLargeVarBinary () throws Exception {
129
134
try (LargeVarBinaryVector vector = new LargeVarBinaryVector ("test" , allocator );
130
- LargeVarBinaryWriterImpl writer = new LargeVarBinaryWriterImpl (vector )) {
135
+ LargeVarBinaryWriter writer = new LargeVarBinaryWriterImpl (vector )) {
131
136
byte [] input = new byte [] { 0x01 , 0x02 };
132
137
ByteBuffer buffer = ByteBuffer .wrap (input );
133
138
writer .writeToLargeVarBinary (buffer , 1 , 1 );
134
139
byte [] result = vector .get (0 );
135
140
Assert .assertArrayEquals (new byte [] { 0x02 }, result );
136
141
}
137
142
}
143
+
144
+ @ Test
145
+ public void testWriteStringToVarChar () throws Exception {
146
+ try (VarCharVector vector = new VarCharVector ("test" , allocator );
147
+ VarCharWriter writer = new VarCharWriterImpl (vector )) {
148
+ String input = "testInput" ;
149
+ writer .writeVarChar (input );
150
+ String result = vector .getObject (0 ).toString ();
151
+ Assert .assertEquals (input , result );
152
+ }
153
+ }
154
+
155
+ @ Test
156
+ public void testWriteTextToVarChar () throws Exception {
157
+ try (VarCharVector vector = new VarCharVector ("test" , allocator );
158
+ VarCharWriter writer = new VarCharWriterImpl (vector )) {
159
+ String input = "testInput" ;
160
+ writer .writeVarChar (new Text (input ));
161
+ String result = vector .getObject (0 ).toString ();
162
+ Assert .assertEquals (input , result );
163
+ }
164
+ }
165
+
166
+ @ Test
167
+ public void testWriteStringToLargeVarChar () throws Exception {
168
+ try (LargeVarCharVector vector = new LargeVarCharVector ("test" , allocator );
169
+ LargeVarCharWriter writer = new LargeVarCharWriterImpl (vector )) {
170
+ String input = "testInput" ;
171
+ writer .writeLargeVarChar (input );
172
+ String result = vector .getObject (0 ).toString ();
173
+ Assert .assertEquals (input , result );
174
+ }
175
+ }
176
+
177
+ @ Test
178
+ public void testWriteTextToLargeVarChar () throws Exception {
179
+ try (LargeVarCharVector vector = new LargeVarCharVector ("test" , allocator );
180
+ LargeVarCharWriter writer = new LargeVarCharWriterImpl (vector )) {
181
+ String input = "testInput" ;
182
+ writer .writeLargeVarChar (new Text (input ));
183
+ String result = vector .getObject (0 ).toString ();
184
+ Assert .assertEquals (input , result );
185
+ }
186
+ }
138
187
}
0 commit comments