File tree Expand file tree Collapse file tree 2 files changed +257
-0
lines changed
java/vector/src/test/java/org/apache/arrow/vector/file/json Expand file tree Collapse file tree 2 files changed +257
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "schema" : {
3+ "fields" : [
4+ {
5+ "name" : " struct_nullable" ,
6+ "type" : {
7+ "name" : " struct"
8+ },
9+ "nullable" : true ,
10+ "children" : [
11+ {
12+ "name" : " f1" ,
13+ "type" : {
14+ "name" : " int" ,
15+ "isSigned" : true ,
16+ "bitWidth" : 32
17+ },
18+ "nullable" : true ,
19+ "children" : [],
20+ "typeLayout" : {
21+ "vectors" : [
22+ {
23+ "type" : " VALIDITY" ,
24+ "typeBitWidth" : 1
25+ },
26+ {
27+ "type" : " DATA" ,
28+ "typeBitWidth" : 32
29+ }
30+ ]
31+ }
32+ },
33+ {
34+ "name" : " f2" ,
35+ "type" : {
36+ "name" : " utf8"
37+ },
38+ "nullable" : true ,
39+ "children" : [],
40+ "typeLayout" : {
41+ "vectors" : [
42+ {
43+ "type" : " VALIDITY" ,
44+ "typeBitWidth" : 1
45+ },
46+ {
47+ "type" : " OFFSET" ,
48+ "typeBitWidth" : 32
49+ },
50+ {
51+ "type" : " DATA" ,
52+ "typeBitWidth" : 8
53+ }
54+ ]
55+ }
56+ }
57+ ],
58+ "typeLayout" : {
59+ "vectors" : [
60+ {
61+ "type" : " VALIDITY" ,
62+ "typeBitWidth" : 1
63+ }
64+ ]
65+ }
66+ }
67+ ]
68+ },
69+ "batches" : [
70+ {
71+ "count" : 7 ,
72+ "columns" : [
73+ {
74+ "name" : " struct_nullable" ,
75+ "count" : 7 ,
76+ "VALIDITY" : [
77+ 0 ,
78+ 1 ,
79+ 1 ,
80+ 1 ,
81+ 0 ,
82+ 1 ,
83+ 0
84+ ],
85+ "children" : [
86+ {
87+ "name" : " f1" ,
88+ "count" : 7 ,
89+ "VALIDITY" : [
90+ 1 ,
91+ 0 ,
92+ 1 ,
93+ 1 ,
94+ 1 ,
95+ 0 ,
96+ 0
97+ ],
98+ "DATA" : [
99+ 1402032511 ,
100+ 290876774 ,
101+ 137773603 ,
102+ 410361374 ,
103+ 1959836418 ,
104+ 1995074679 ,
105+ -163525262
106+ ]
107+ },
108+ {
109+ "name" : " f2" ,
110+ "count" : 7 ,
111+ "VALIDITY" : [
112+ 0 ,
113+ 1 ,
114+ 1 ,
115+ 1 ,
116+ 0 ,
117+ 1 ,
118+ 0
119+ ],
120+ "OFFSET" : [
121+ 0 ,
122+ 0 ,
123+ 7 ,
124+ 14 ,
125+ 21 ,
126+ 21 ,
127+ 28 ,
128+ 28
129+ ],
130+ "DATA" : [
131+ " " ,
132+ " MhRNxD4" ,
133+ " 3F9HBxK" ,
134+ " aVd88fp" ,
135+ " " ,
136+ " 3loZrRf" ,
137+ " "
138+ ]
139+ }
140+ ]
141+ }
142+ ]
143+ },
144+ {
145+ "count" : 10 ,
146+ "columns" : [
147+ {
148+ "name" : " struct_nullable" ,
149+ "count" : 10 ,
150+ "VALIDITY" : [
151+ 0 ,
152+ 1 ,
153+ 1 ,
154+ 0 ,
155+ 1 ,
156+ 0 ,
157+ 0 ,
158+ 1 ,
159+ 1 ,
160+ 1
161+ ],
162+ "children" : [
163+ {
164+ "name" : " f1" ,
165+ "count" : 10 ,
166+ "VALIDITY" : [
167+ 0 ,
168+ 0 ,
169+ 0 ,
170+ 0 ,
171+ 0 ,
172+ 0 ,
173+ 1 ,
174+ 0 ,
175+ 0 ,
176+ 0
177+ ],
178+ "DATA" : [
179+ -2041500147 ,
180+ 1715692943 ,
181+ -35444996 ,
182+ 1425496657 ,
183+ 112765084 ,
184+ 1760754983 ,
185+ 413888857 ,
186+ 2039738337 ,
187+ -1924327700 ,
188+ 670528518
189+ ]
190+ },
191+ {
192+ "name" : " f2" ,
193+ "count" : 10 ,
194+ "VALIDITY" : [
195+ 1 ,
196+ 0 ,
197+ 0 ,
198+ 1 ,
199+ 1 ,
200+ 1 ,
201+ 1 ,
202+ 1 ,
203+ 1 ,
204+ 0
205+ ],
206+ "OFFSET" : [
207+ 0 ,
208+ 7 ,
209+ 7 ,
210+ 7 ,
211+ 14 ,
212+ 21 ,
213+ 28 ,
214+ 35 ,
215+ 42 ,
216+ 49 ,
217+ 49
218+ ],
219+ "DATA" : [
220+ " AS5oARE" ,
221+ " " ,
222+ " " ,
223+ " JGdagcX" ,
224+ " 78SLiRw" ,
225+ " vbGf7OY" ,
226+ " 5uh5fTs" ,
227+ " 0ilsf82" ,
228+ " LjS9MbU" ,
229+ " "
230+ ]
231+ }
232+ ]
233+ }
234+ ]
235+ }
236+ ]
237+ }
Original file line number Diff line number Diff line change 2121import java .io .IOException ;
2222
2323import org .apache .arrow .memory .BufferAllocator ;
24+ import org .apache .arrow .vector .FieldVector ;
2425import org .apache .arrow .vector .VectorSchemaRoot ;
2526import org .apache .arrow .vector .complex .MapVector ;
2627import org .apache .arrow .vector .complex .NullableMapVector ;
2728import org .apache .arrow .vector .file .BaseFileTest ;
2829import org .apache .arrow .vector .types .pojo .Schema ;
30+ import org .junit .Assert ;
2931import org .junit .Test ;
3032import org .slf4j .Logger ;
3133import org .slf4j .LoggerFactory ;
@@ -117,4 +119,22 @@ public void testWriteReadUnionJSON() throws IOException {
117119 }
118120 }
119121
122+ @ Test
123+ public void testSetStructLength () throws IOException {
124+ File file = new File ("../../integration/data/struct_example.json" );
125+ try (
126+ BufferAllocator readerAllocator = allocator .newChildAllocator ("reader" , 0 , Integer .MAX_VALUE );
127+ ) {
128+ JsonFileReader reader = new JsonFileReader (file , readerAllocator );
129+ Schema schema = reader .start ();
130+ LOGGER .debug ("reading schema: " + schema );
131+
132+ // initialize vectors
133+ try (VectorSchemaRoot root = reader .read ();) {
134+ FieldVector vector = root .getVector ("struct_nullable" );
135+ Assert .assertEquals (7 , vector .getAccessor ().getValueCount ());
136+ }
137+ }
138+ }
139+
120140}
You can’t perform that action at this time.
0 commit comments