2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org
.apache
.arrow
.vector
.types
;
20 import static org
.apache
.arrow
.vector
.types
.FloatingPointPrecision
.DOUBLE
;
21 import static org
.apache
.arrow
.vector
.types
.FloatingPointPrecision
.SINGLE
;
22 import static org
.apache
.arrow
.vector
.types
.UnionMode
.Dense
;
23 import static org
.apache
.arrow
.vector
.types
.UnionMode
.Sparse
;
25 import org
.apache
.arrow
.memory
.BufferAllocator
;
26 import org
.apache
.arrow
.vector
.BigIntVector
;
27 import org
.apache
.arrow
.vector
.BitVector
;
28 import org
.apache
.arrow
.vector
.DateDayVector
;
29 import org
.apache
.arrow
.vector
.DateMilliVector
;
30 import org
.apache
.arrow
.vector
.Decimal256Vector
;
31 import org
.apache
.arrow
.vector
.DecimalVector
;
32 import org
.apache
.arrow
.vector
.DurationVector
;
33 import org
.apache
.arrow
.vector
.ExtensionTypeVector
;
34 import org
.apache
.arrow
.vector
.FieldVector
;
35 import org
.apache
.arrow
.vector
.FixedSizeBinaryVector
;
36 import org
.apache
.arrow
.vector
.Float4Vector
;
37 import org
.apache
.arrow
.vector
.Float8Vector
;
38 import org
.apache
.arrow
.vector
.IntVector
;
39 import org
.apache
.arrow
.vector
.IntervalDayVector
;
40 import org
.apache
.arrow
.vector
.IntervalMonthDayNanoVector
;
41 import org
.apache
.arrow
.vector
.IntervalYearVector
;
42 import org
.apache
.arrow
.vector
.LargeVarBinaryVector
;
43 import org
.apache
.arrow
.vector
.LargeVarCharVector
;
44 import org
.apache
.arrow
.vector
.NullVector
;
45 import org
.apache
.arrow
.vector
.SmallIntVector
;
46 import org
.apache
.arrow
.vector
.TimeMicroVector
;
47 import org
.apache
.arrow
.vector
.TimeMilliVector
;
48 import org
.apache
.arrow
.vector
.TimeNanoVector
;
49 import org
.apache
.arrow
.vector
.TimeSecVector
;
50 import org
.apache
.arrow
.vector
.TimeStampMicroTZVector
;
51 import org
.apache
.arrow
.vector
.TimeStampMicroVector
;
52 import org
.apache
.arrow
.vector
.TimeStampMilliTZVector
;
53 import org
.apache
.arrow
.vector
.TimeStampMilliVector
;
54 import org
.apache
.arrow
.vector
.TimeStampNanoTZVector
;
55 import org
.apache
.arrow
.vector
.TimeStampNanoVector
;
56 import org
.apache
.arrow
.vector
.TimeStampSecTZVector
;
57 import org
.apache
.arrow
.vector
.TimeStampSecVector
;
58 import org
.apache
.arrow
.vector
.TinyIntVector
;
59 import org
.apache
.arrow
.vector
.UInt1Vector
;
60 import org
.apache
.arrow
.vector
.UInt2Vector
;
61 import org
.apache
.arrow
.vector
.UInt4Vector
;
62 import org
.apache
.arrow
.vector
.UInt8Vector
;
63 import org
.apache
.arrow
.vector
.ValueVector
;
64 import org
.apache
.arrow
.vector
.VarBinaryVector
;
65 import org
.apache
.arrow
.vector
.VarCharVector
;
66 import org
.apache
.arrow
.vector
.complex
.DenseUnionVector
;
67 import org
.apache
.arrow
.vector
.complex
.FixedSizeListVector
;
68 import org
.apache
.arrow
.vector
.complex
.LargeListVector
;
69 import org
.apache
.arrow
.vector
.complex
.ListVector
;
70 import org
.apache
.arrow
.vector
.complex
.MapVector
;
71 import org
.apache
.arrow
.vector
.complex
.StructVector
;
72 import org
.apache
.arrow
.vector
.complex
.UnionVector
;
73 import org
.apache
.arrow
.vector
.complex
.impl
.BigIntWriterImpl
;
74 import org
.apache
.arrow
.vector
.complex
.impl
.BitWriterImpl
;
75 import org
.apache
.arrow
.vector
.complex
.impl
.DateDayWriterImpl
;
76 import org
.apache
.arrow
.vector
.complex
.impl
.DateMilliWriterImpl
;
77 import org
.apache
.arrow
.vector
.complex
.impl
.Decimal256WriterImpl
;
78 import org
.apache
.arrow
.vector
.complex
.impl
.DecimalWriterImpl
;
79 import org
.apache
.arrow
.vector
.complex
.impl
.DenseUnionWriter
;
80 import org
.apache
.arrow
.vector
.complex
.impl
.DurationWriterImpl
;
81 import org
.apache
.arrow
.vector
.complex
.impl
.FixedSizeBinaryWriterImpl
;
82 import org
.apache
.arrow
.vector
.complex
.impl
.Float4WriterImpl
;
83 import org
.apache
.arrow
.vector
.complex
.impl
.Float8WriterImpl
;
84 import org
.apache
.arrow
.vector
.complex
.impl
.IntWriterImpl
;
85 import org
.apache
.arrow
.vector
.complex
.impl
.IntervalDayWriterImpl
;
86 import org
.apache
.arrow
.vector
.complex
.impl
.IntervalMonthDayNanoWriterImpl
;
87 import org
.apache
.arrow
.vector
.complex
.impl
.IntervalYearWriterImpl
;
88 import org
.apache
.arrow
.vector
.complex
.impl
.LargeVarBinaryWriterImpl
;
89 import org
.apache
.arrow
.vector
.complex
.impl
.LargeVarCharWriterImpl
;
90 import org
.apache
.arrow
.vector
.complex
.impl
.NullableStructWriter
;
91 import org
.apache
.arrow
.vector
.complex
.impl
.SmallIntWriterImpl
;
92 import org
.apache
.arrow
.vector
.complex
.impl
.TimeMicroWriterImpl
;
93 import org
.apache
.arrow
.vector
.complex
.impl
.TimeMilliWriterImpl
;
94 import org
.apache
.arrow
.vector
.complex
.impl
.TimeNanoWriterImpl
;
95 import org
.apache
.arrow
.vector
.complex
.impl
.TimeSecWriterImpl
;
96 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampMicroTZWriterImpl
;
97 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampMicroWriterImpl
;
98 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampMilliTZWriterImpl
;
99 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampMilliWriterImpl
;
100 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampNanoTZWriterImpl
;
101 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampNanoWriterImpl
;
102 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampSecTZWriterImpl
;
103 import org
.apache
.arrow
.vector
.complex
.impl
.TimeStampSecWriterImpl
;
104 import org
.apache
.arrow
.vector
.complex
.impl
.TinyIntWriterImpl
;
105 import org
.apache
.arrow
.vector
.complex
.impl
.UInt1WriterImpl
;
106 import org
.apache
.arrow
.vector
.complex
.impl
.UInt2WriterImpl
;
107 import org
.apache
.arrow
.vector
.complex
.impl
.UInt4WriterImpl
;
108 import org
.apache
.arrow
.vector
.complex
.impl
.UInt8WriterImpl
;
109 import org
.apache
.arrow
.vector
.complex
.impl
.UnionLargeListWriter
;
110 import org
.apache
.arrow
.vector
.complex
.impl
.UnionListWriter
;
111 import org
.apache
.arrow
.vector
.complex
.impl
.UnionWriter
;
112 import org
.apache
.arrow
.vector
.complex
.impl
.VarBinaryWriterImpl
;
113 import org
.apache
.arrow
.vector
.complex
.impl
.VarCharWriterImpl
;
114 import org
.apache
.arrow
.vector
.complex
.writer
.FieldWriter
;
115 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
;
116 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.ArrowTypeVisitor
;
117 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Binary
;
118 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Bool
;
119 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Date
;
120 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Decimal
;
121 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Duration
;
122 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.ExtensionType
;
123 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.FixedSizeBinary
;
124 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.FixedSizeList
;
125 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.FloatingPoint
;
126 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Int
;
127 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Interval
;
128 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.LargeBinary
;
129 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.LargeUtf8
;
130 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.List
;
131 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Map
;
132 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Null
;
133 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Struct
;
134 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Time
;
135 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Timestamp
;
136 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Union
;
137 import org
.apache
.arrow
.vector
.types
.pojo
.ArrowType
.Utf8
;
138 import org
.apache
.arrow
.vector
.types
.pojo
.Field
;
139 import org
.apache
.arrow
.vector
.types
.pojo
.FieldType
;
140 import org
.apache
.arrow
.vector
.util
.CallBack
;
142 /** An enumeration of all logical types supported by this library. */
146 * The actual enumeration of types.
148 public enum MinorType
{
149 NULL(Null
.INSTANCE
) {
151 public FieldVector
getNewVector(
153 BufferAllocator allocator
,
154 CallBack schemaChangeCallback
) {
155 return new NullVector(field
.getName());
159 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
163 STRUCT(Struct
.INSTANCE
) {
165 public FieldVector
getNewVector(
167 BufferAllocator allocator
,
168 CallBack schemaChangeCallback
) {
169 return new StructVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
173 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
174 return new NullableStructWriter((StructVector
) vector
);
177 TINYINT(new Int(8, true)) {
179 public FieldVector
getNewVector(
181 BufferAllocator allocator
,
182 CallBack schemaChangeCallback
) {
183 return new TinyIntVector(field
, allocator
);
187 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
188 return new TinyIntWriterImpl((TinyIntVector
) vector
);
191 SMALLINT(new Int(16, true)) {
193 public FieldVector
getNewVector(
195 BufferAllocator allocator
,
196 CallBack schemaChangeCallback
) {
197 return new SmallIntVector(field
, allocator
);
201 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
202 return new SmallIntWriterImpl((SmallIntVector
) vector
);
205 INT(new Int(32, true)) {
207 public FieldVector
getNewVector(
209 BufferAllocator allocator
,
210 CallBack schemaChangeCallback
) {
211 return new IntVector(field
, allocator
);
215 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
216 return new IntWriterImpl((IntVector
) vector
);
219 BIGINT(new Int(64, true)) {
221 public FieldVector
getNewVector(
223 BufferAllocator allocator
,
224 CallBack schemaChangeCallback
) {
225 return new BigIntVector(field
, allocator
);
229 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
230 return new BigIntWriterImpl((BigIntVector
) vector
);
233 DATEDAY(new Date(DateUnit
.DAY
)) {
235 public FieldVector
getNewVector(
237 BufferAllocator allocator
,
238 CallBack schemaChangeCallback
) {
239 return new DateDayVector(field
, allocator
);
243 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
244 return new DateDayWriterImpl((DateDayVector
) vector
);
247 DATEMILLI(new Date(DateUnit
.MILLISECOND
)) {
249 public FieldVector
getNewVector(
251 BufferAllocator allocator
,
252 CallBack schemaChangeCallback
) {
253 return new DateMilliVector(field
, allocator
);
257 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
258 return new DateMilliWriterImpl((DateMilliVector
) vector
);
261 TIMESEC(new Time(TimeUnit
.SECOND
, 32)) {
263 public FieldVector
getNewVector(
265 BufferAllocator allocator
,
266 CallBack schemaChangeCallback
) {
267 return new TimeSecVector(field
, allocator
);
271 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
272 return new TimeSecWriterImpl((TimeSecVector
) vector
);
275 TIMEMILLI(new Time(TimeUnit
.MILLISECOND
, 32)) {
277 public FieldVector
getNewVector(
279 BufferAllocator allocator
,
280 CallBack schemaChangeCallback
) {
281 return new TimeMilliVector(field
, allocator
);
285 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
286 return new TimeMilliWriterImpl((TimeMilliVector
) vector
);
289 TIMEMICRO(new Time(TimeUnit
.MICROSECOND
, 64)) {
291 public FieldVector
getNewVector(
293 BufferAllocator allocator
,
294 CallBack schemaChangeCallback
) {
295 return new TimeMicroVector(field
, allocator
);
299 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
300 return new TimeMicroWriterImpl((TimeMicroVector
) vector
);
303 TIMENANO(new Time(TimeUnit
.NANOSECOND
, 64)) {
305 public FieldVector
getNewVector(
307 BufferAllocator allocator
,
308 CallBack schemaChangeCallback
) {
309 return new TimeNanoVector(field
, allocator
);
313 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
314 return new TimeNanoWriterImpl((TimeNanoVector
) vector
);
317 // time in second from the Unix epoch, 00:00:00.000000 on 1 January 1970, UTC.
318 TIMESTAMPSEC(new Timestamp(org
.apache
.arrow
.vector
.types
.TimeUnit
.SECOND
, null)) {
320 public FieldVector
getNewVector(
322 BufferAllocator allocator
,
323 CallBack schemaChangeCallback
) {
324 return new TimeStampSecVector(field
, allocator
);
328 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
329 return new TimeStampSecWriterImpl((TimeStampSecVector
) vector
);
332 // time in millis from the Unix epoch, 00:00:00.000 on 1 January 1970, UTC.
333 TIMESTAMPMILLI(new Timestamp(org
.apache
.arrow
.vector
.types
.TimeUnit
.MILLISECOND
, null)) {
335 public FieldVector
getNewVector(
337 BufferAllocator allocator
,
338 CallBack schemaChangeCallback
) {
339 return new TimeStampMilliVector(field
, allocator
);
343 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
344 return new TimeStampMilliWriterImpl((TimeStampMilliVector
) vector
);
347 // time in microsecond from the Unix epoch, 00:00:00.000000 on 1 January 1970, UTC.
348 TIMESTAMPMICRO(new Timestamp(org
.apache
.arrow
.vector
.types
.TimeUnit
.MICROSECOND
, null)) {
350 public FieldVector
getNewVector(
352 BufferAllocator allocator
,
353 CallBack schemaChangeCallback
) {
354 return new TimeStampMicroVector(field
, allocator
);
358 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
359 return new TimeStampMicroWriterImpl((TimeStampMicroVector
) vector
);
362 // time in nanosecond from the Unix epoch, 00:00:00.000000000 on 1 January 1970, UTC.
363 TIMESTAMPNANO(new Timestamp(org
.apache
.arrow
.vector
.types
.TimeUnit
.NANOSECOND
, null)) {
365 public FieldVector
getNewVector(
367 BufferAllocator allocator
,
368 CallBack schemaChangeCallback
) {
369 return new TimeStampNanoVector(field
, allocator
);
373 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
374 return new TimeStampNanoWriterImpl((TimeStampNanoVector
) vector
);
377 INTERVALDAY(new Interval(IntervalUnit
.DAY_TIME
)) {
379 public FieldVector
getNewVector(
381 BufferAllocator allocator
,
382 CallBack schemaChangeCallback
) {
383 return new IntervalDayVector(field
, allocator
);
387 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
388 return new IntervalDayWriterImpl((IntervalDayVector
) vector
);
391 INTERVALMONTHDAYNANO(new Interval(IntervalUnit
.MONTH_DAY_NANO
)) {
393 public FieldVector
getNewVector(
395 BufferAllocator allocator
,
396 CallBack schemaChangeCallback
) {
397 return new IntervalMonthDayNanoVector(field
, allocator
);
401 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
402 return new IntervalMonthDayNanoWriterImpl((IntervalMonthDayNanoVector
) vector
);
407 public FieldVector
getNewVector(
409 BufferAllocator allocator
,
410 CallBack schemaChangeCallback
) {
411 return new DurationVector(field
, allocator
);
415 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
416 return new DurationWriterImpl((DurationVector
) vector
);
421 INTERVALYEAR(new Interval(IntervalUnit
.YEAR_MONTH
)) {
423 public FieldVector
getNewVector(
425 BufferAllocator allocator
,
426 CallBack schemaChangeCallback
) {
427 return new IntervalYearVector(field
, allocator
);
431 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
432 return new IntervalYearWriterImpl((IntervalYearVector
) vector
);
436 FLOAT4(new FloatingPoint(SINGLE
)) {
438 public FieldVector
getNewVector(
440 BufferAllocator allocator
,
441 CallBack schemaChangeCallback
) {
442 return new Float4Vector(field
, allocator
);
446 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
447 return new Float4WriterImpl((Float4Vector
) vector
);
451 FLOAT8(new FloatingPoint(DOUBLE
)) {
453 public FieldVector
getNewVector(
455 BufferAllocator allocator
,
456 CallBack schemaChangeCallback
) {
457 return new Float8Vector(field
, allocator
);
461 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
462 return new Float8WriterImpl((Float8Vector
) vector
);
467 public FieldVector
getNewVector(
469 BufferAllocator allocator
,
470 CallBack schemaChangeCallback
) {
471 return new BitVector(field
, allocator
);
475 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
476 return new BitWriterImpl((BitVector
) vector
);
479 VARCHAR(Utf8
.INSTANCE
) {
481 public FieldVector
getNewVector(
483 BufferAllocator allocator
,
484 CallBack schemaChangeCallback
) {
485 return new VarCharVector(field
, allocator
);
489 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
490 return new VarCharWriterImpl((VarCharVector
) vector
);
493 LARGEVARCHAR(LargeUtf8
.INSTANCE
) {
495 public FieldVector
getNewVector(
497 BufferAllocator allocator
,
498 CallBack schemaChangeCallback
) {
499 return new LargeVarCharVector(field
, allocator
);
503 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
504 return new LargeVarCharWriterImpl((LargeVarCharVector
) vector
);
507 LARGEVARBINARY(LargeBinary
.INSTANCE
) {
509 public FieldVector
getNewVector(
511 BufferAllocator allocator
,
512 CallBack schemaChangeCallback
) {
513 return new LargeVarBinaryVector(field
, allocator
);
517 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
518 return new LargeVarBinaryWriterImpl((LargeVarBinaryVector
) vector
);
521 VARBINARY(Binary
.INSTANCE
) {
523 public FieldVector
getNewVector(
525 BufferAllocator allocator
,
526 CallBack schemaChangeCallback
) {
527 return new VarBinaryVector(field
, allocator
);
531 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
532 return new VarBinaryWriterImpl((VarBinaryVector
) vector
);
537 public FieldVector
getNewVector(
539 BufferAllocator allocator
,
540 CallBack schemaChangeCallback
) {
541 return new DecimalVector(field
, allocator
);
545 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
546 return new DecimalWriterImpl((DecimalVector
) vector
);
551 public FieldVector
getNewVector(
553 BufferAllocator allocator
,
554 CallBack schemaChangeCallback
) {
555 return new Decimal256Vector(field
, allocator
);
559 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
560 return new Decimal256WriterImpl((Decimal256Vector
) vector
);
563 FIXEDSIZEBINARY(null) {
565 public FieldVector
getNewVector(
567 BufferAllocator allocator
,
568 CallBack schemaChangeCallback
) {
569 return new FixedSizeBinaryVector(field
, allocator
);
573 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
574 return new FixedSizeBinaryWriterImpl((FixedSizeBinaryVector
) vector
);
577 UINT1(new Int(8, false)) {
579 public FieldVector
getNewVector(
581 BufferAllocator allocator
,
582 CallBack schemaChangeCallback
) {
583 return new UInt1Vector(field
, allocator
);
587 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
588 return new UInt1WriterImpl((UInt1Vector
) vector
);
591 UINT2(new Int(16, false)) {
593 public FieldVector
getNewVector(
595 BufferAllocator allocator
,
596 CallBack schemaChangeCallback
) {
597 return new UInt2Vector(field
, allocator
);
601 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
602 return new UInt2WriterImpl((UInt2Vector
) vector
);
605 UINT4(new Int(32, false)) {
607 public FieldVector
getNewVector(
609 BufferAllocator allocator
,
610 CallBack schemaChangeCallback
) {
611 return new UInt4Vector(field
, allocator
);
615 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
616 return new UInt4WriterImpl((UInt4Vector
) vector
);
619 UINT8(new Int(64, false)) {
621 public FieldVector
getNewVector(
623 BufferAllocator allocator
,
624 CallBack schemaChangeCallback
) {
625 return new UInt8Vector(field
, allocator
);
629 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
630 return new UInt8WriterImpl((UInt8Vector
) vector
);
633 LIST(List
.INSTANCE
) {
635 public FieldVector
getNewVector(
637 BufferAllocator allocator
,
638 CallBack schemaChangeCallback
) {
639 return new ListVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
643 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
644 return new UnionListWriter((ListVector
) vector
);
647 LARGELIST(ArrowType
.LargeList
.INSTANCE
) {
649 public FieldVector
getNewVector(Field field
, BufferAllocator allocator
, CallBack schemaChangeCallback
) {
650 return new LargeListVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
654 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
655 return new UnionLargeListWriter((LargeListVector
) vector
);
658 FIXED_SIZE_LIST(null) {
660 public FieldVector
getNewVector(
662 BufferAllocator allocator
,
663 CallBack schemaChangeCallback
) {
664 return new FixedSizeListVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
668 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
669 throw new UnsupportedOperationException("FieldWriter not implemented for FixedSizeList " +
673 UNION(new Union(Sparse
, null)) {
675 public FieldVector
getNewVector(
677 BufferAllocator allocator
,
678 CallBack schemaChangeCallback
) {
679 if (field
.getFieldType().getDictionary() != null) {
680 throw new UnsupportedOperationException("Dictionary encoding not supported for complex " +
683 return new UnionVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
687 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
688 return new UnionWriter((UnionVector
) vector
);
691 DENSEUNION(new Union(Dense
, null)) {
693 public FieldVector
getNewVector(
695 BufferAllocator allocator
,
696 CallBack schemaChangeCallback
) {
697 if (field
.getFieldType().getDictionary() != null) {
698 throw new UnsupportedOperationException("Dictionary encoding not supported for complex " +
701 return new DenseUnionVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
705 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
706 return new DenseUnionWriter((DenseUnionVector
) vector
);
711 public FieldVector
getNewVector(
713 BufferAllocator allocator
,
714 CallBack schemaChangeCallback
) {
715 return new MapVector(field
.getName(), allocator
, field
.getFieldType(), schemaChangeCallback
);
719 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
720 return new UnionListWriter((MapVector
) vector
);
723 TIMESTAMPSECTZ(null) {
725 public FieldVector
getNewVector(
727 BufferAllocator allocator
,
728 CallBack schemaChangeCallback
) {
729 return new TimeStampSecTZVector(field
, allocator
);
733 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
734 return new TimeStampSecTZWriterImpl((TimeStampSecTZVector
) vector
);
737 TIMESTAMPMILLITZ(null) {
739 public FieldVector
getNewVector(
741 BufferAllocator allocator
,
742 CallBack schemaChangeCallback
) {
743 return new TimeStampMilliTZVector(field
, allocator
);
747 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
748 return new TimeStampMilliTZWriterImpl((TimeStampMilliTZVector
) vector
);
751 TIMESTAMPMICROTZ(null) {
753 public FieldVector
getNewVector(
755 BufferAllocator allocator
,
756 CallBack schemaChangeCallback
) {
757 return new TimeStampMicroTZVector(field
, allocator
);
761 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
762 return new TimeStampMicroTZWriterImpl((TimeStampMicroTZVector
) vector
);
765 TIMESTAMPNANOTZ(null) {
767 public FieldVector
getNewVector(
769 BufferAllocator allocator
,
770 CallBack schemaChangeCallback
) {
771 return new TimeStampNanoTZVector(field
, allocator
);
775 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
776 return new TimeStampNanoTZWriterImpl((TimeStampNanoTZVector
) vector
);
779 EXTENSIONTYPE(null) {
781 public FieldVector
getNewVector(
783 BufferAllocator allocator
,
784 CallBack schemaChangeCallback
) {
785 return ((ExtensionType
) field
.getFieldType().getType()).getNewVector(field
.getName(),
786 field
.getFieldType(), allocator
);
790 public FieldWriter
getNewFieldWriter(ValueVector vector
) {
791 return ((ExtensionTypeVector
) vector
).getUnderlyingVector().getMinorType().getNewFieldWriter(vector
);
796 private final ArrowType type
;
798 MinorType(ArrowType type
) {
803 * Returns the {@link ArrowType} equivalent of this type.
805 public final ArrowType
getType() {
807 throw new UnsupportedOperationException("Cannot get simple type for type " + name());
812 /** Constructs a new vector for the given type. */
813 public final FieldVector
getNewVector(
816 BufferAllocator allocator
,
817 CallBack schemaChangeCallback
) {
818 return getNewVector(new Field(name
, fieldType
, null), allocator
, schemaChangeCallback
);
821 /** Constructs a new vector for the given type. */
822 public abstract FieldVector
getNewVector(
824 BufferAllocator allocator
,
825 CallBack schemaChangeCallback
);
827 public abstract FieldWriter
getNewFieldWriter(ValueVector vector
);
831 * Maps the ArrowType to the java implementations MinorType.
833 public static MinorType
getMinorTypeForArrowType(ArrowType arrowType
) {
834 return arrowType
.accept(new ArrowTypeVisitor
<MinorType
>() {
836 public MinorType
visit(Null type
) {
837 return MinorType
.NULL
;
841 public MinorType
visit(Struct type
) {
842 return MinorType
.STRUCT
;
846 public MinorType
visit(List type
) {
847 return MinorType
.LIST
;
851 public MinorType
visit(FixedSizeList type
) {
852 return MinorType
.FIXED_SIZE_LIST
;
856 public MinorType
visit(Union type
) {
857 switch (type
.getMode()) {
859 return MinorType
.UNION
;
861 return MinorType
.DENSEUNION
;
863 throw new IllegalArgumentException("only Dense or Sparse unions supported: " + type
);
868 public MinorType
visit(Map type
) {
869 return MinorType
.MAP
;
873 public MinorType
visit(ArrowType
.LargeList type
) {
874 return MinorType
.LARGELIST
;
878 public MinorType
visit(Int type
) {
879 switch (type
.getBitWidth()) {
881 return type
.getIsSigned() ? MinorType
.TINYINT
: MinorType
.UINT1
;
883 return type
.getIsSigned() ? MinorType
.SMALLINT
: MinorType
.UINT2
;
885 return type
.getIsSigned() ? MinorType
.INT
: MinorType
.UINT4
;
887 return type
.getIsSigned() ? MinorType
.BIGINT
: MinorType
.UINT8
;
889 throw new IllegalArgumentException("only 8, 16, 32, 64 supported: " + type
);
894 public MinorType
visit(FloatingPoint type
) {
895 switch (type
.getPrecision()) {
897 throw new UnsupportedOperationException("NYI: " + type
);
899 return MinorType
.FLOAT4
;
901 return MinorType
.FLOAT8
;
903 throw new IllegalArgumentException("unknown precision: " + type
);
908 public MinorType
visit(Utf8 type
) {
909 return MinorType
.VARCHAR
;
913 public Types
.MinorType
visit(LargeUtf8 type
) {
914 return MinorType
.LARGEVARCHAR
;
918 public MinorType
visit(Binary type
) {
919 return MinorType
.VARBINARY
;
923 public MinorType
visit(LargeBinary type
) {
924 return MinorType
.LARGEVARBINARY
;
928 public MinorType
visit(Bool type
) {
929 return MinorType
.BIT
;
933 public MinorType
visit(Decimal type
) {
934 if (type
.getBitWidth() == 256) {
935 return MinorType
.DECIMAL256
;
937 return MinorType
.DECIMAL
;
941 public MinorType
visit(FixedSizeBinary type
) {
942 return MinorType
.FIXEDSIZEBINARY
;
946 public MinorType
visit(Date type
) {
947 switch (type
.getUnit()) {
949 return MinorType
.DATEDAY
;
951 return MinorType
.DATEMILLI
;
953 throw new IllegalArgumentException("unknown unit: " + type
);
958 public MinorType
visit(Time type
) {
959 switch (type
.getUnit()) {
961 return MinorType
.TIMESEC
;
963 return MinorType
.TIMEMILLI
;
965 return MinorType
.TIMEMICRO
;
967 return MinorType
.TIMENANO
;
969 throw new IllegalArgumentException("unknown unit: " + type
);
974 public MinorType
visit(Timestamp type
) {
975 String tz
= type
.getTimezone();
976 switch (type
.getUnit()) {
978 return tz
== null ? MinorType
.TIMESTAMPSEC
: MinorType
.TIMESTAMPSECTZ
;
980 return tz
== null ? MinorType
.TIMESTAMPMILLI
: MinorType
.TIMESTAMPMILLITZ
;
982 return tz
== null ? MinorType
.TIMESTAMPMICRO
: MinorType
.TIMESTAMPMICROTZ
;
984 return tz
== null ? MinorType
.TIMESTAMPNANO
: MinorType
.TIMESTAMPNANOTZ
;
986 throw new IllegalArgumentException("unknown unit: " + type
);
991 public MinorType
visit(Interval type
) {
992 switch (type
.getUnit()) {
994 return MinorType
.INTERVALDAY
;
996 return MinorType
.INTERVALYEAR
;
998 return MinorType
.INTERVALMONTHDAYNANO
;
1000 throw new IllegalArgumentException("unknown unit: " + type
);
1005 public MinorType
visit(Duration type
) {
1006 return MinorType
.DURATION
;
1010 public MinorType
visit(ExtensionType type
) {
1011 return MinorType
.EXTENSIONTYPE
;