|
35 | 35 | import org.apache.arrow.memory.ArrowBuf; |
36 | 36 | import org.apache.arrow.memory.BufferAllocator; |
37 | 37 | import org.apache.arrow.memory.RootAllocator; |
38 | | -import org.apache.arrow.memory.util.hash.ArrowBufHasher; |
39 | 38 | import org.apache.arrow.vector.BaseLargeVariableWidthVector; |
40 | 39 | import org.apache.arrow.vector.BaseVariableWidthVector; |
41 | 40 | import org.apache.arrow.vector.BigIntVector; |
|
44 | 43 | import org.apache.arrow.vector.DateMilliVector; |
45 | 44 | import org.apache.arrow.vector.DecimalVector; |
46 | 45 | import org.apache.arrow.vector.DurationVector; |
47 | | -import org.apache.arrow.vector.ExtensionTypeVector; |
48 | 46 | import org.apache.arrow.vector.FieldVector; |
49 | 47 | import org.apache.arrow.vector.FixedSizeBinaryVector; |
50 | 48 | import org.apache.arrow.vector.Float2Vector; |
|
74 | 72 | import org.apache.arrow.vector.UInt2Vector; |
75 | 73 | import org.apache.arrow.vector.UInt4Vector; |
76 | 74 | import org.apache.arrow.vector.UInt8Vector; |
| 75 | +import org.apache.arrow.vector.UuidVector; |
77 | 76 | import org.apache.arrow.vector.ValueVector; |
78 | 77 | import org.apache.arrow.vector.VarBinaryVector; |
79 | 78 | import org.apache.arrow.vector.VarCharVector; |
|
92 | 91 | import org.apache.arrow.vector.complex.StructVector; |
93 | 92 | import org.apache.arrow.vector.complex.UnionVector; |
94 | 93 | import org.apache.arrow.vector.complex.impl.UnionMapWriter; |
| 94 | +import org.apache.arrow.vector.extension.UuidType; |
95 | 95 | import org.apache.arrow.vector.holders.IntervalDayHolder; |
96 | 96 | import org.apache.arrow.vector.holders.NullableLargeVarBinaryHolder; |
97 | 97 | import org.apache.arrow.vector.holders.NullableUInt4Holder; |
|
100 | 100 | import org.apache.arrow.vector.types.Types.MinorType; |
101 | 101 | import org.apache.arrow.vector.types.pojo.ArrowType; |
102 | 102 | import org.apache.arrow.vector.types.pojo.ArrowType.ExtensionType; |
103 | | -import org.apache.arrow.vector.types.pojo.ExtensionTypeRegistry; |
104 | 103 | import org.apache.arrow.vector.types.pojo.Field; |
105 | 104 | import org.apache.arrow.vector.types.pojo.FieldType; |
106 | 105 | import org.apache.arrow.vector.types.pojo.Schema; |
@@ -810,7 +809,6 @@ public void testEmptyRunEndEncodedVector() { |
810 | 809 |
|
811 | 810 | @Test |
812 | 811 | public void testExtensionTypeVector() { |
813 | | - ExtensionTypeRegistry.register(UuidType.INSTANCE); |
814 | 812 | final Schema schema = |
815 | 813 | new Schema(Collections.singletonList(Field.nullable("a", UuidType.INSTANCE))); |
816 | 814 | try (final VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator)) { |
@@ -1114,72 +1112,4 @@ private VectorSchemaRoot createTestVSR() { |
1114 | 1112 |
|
1115 | 1113 | return new VectorSchemaRoot(fields, vectors); |
1116 | 1114 | } |
1117 | | - |
1118 | | - static class UuidType extends ExtensionType { |
1119 | | - |
1120 | | - @Override |
1121 | | - public ArrowType storageType() { |
1122 | | - return new ArrowType.FixedSizeBinary(16); |
1123 | | - } |
1124 | | - |
1125 | | - @Override |
1126 | | - public String extensionName() { |
1127 | | - return "uuid"; |
1128 | | - } |
1129 | | - |
1130 | | - @Override |
1131 | | - public boolean extensionEquals(ExtensionType other) { |
1132 | | - return other instanceof UuidType; |
1133 | | - } |
1134 | | - |
1135 | | - @Override |
1136 | | - public ArrowType deserialize(ArrowType storageType, String serializedData) { |
1137 | | - if (!storageType.equals(storageType())) { |
1138 | | - throw new UnsupportedOperationException( |
1139 | | - "Cannot construct UuidType from underlying type " + storageType); |
1140 | | - } |
1141 | | - return UuidType.INSTANCE; |
1142 | | - } |
1143 | | - |
1144 | | - @Override |
1145 | | - public String serialize() { |
1146 | | - return ""; |
1147 | | - } |
1148 | | - |
1149 | | - @Override |
1150 | | - public FieldVector getNewVector(String name, FieldType fieldType, BufferAllocator allocator) { |
1151 | | - return new UuidVector(name, allocator, new FixedSizeBinaryVector(name, allocator, 16)); |
1152 | | - } |
1153 | | - } |
1154 | | - |
1155 | | - static class UuidVector extends ExtensionTypeVector<FixedSizeBinaryVector> { |
1156 | | - |
1157 | | - public UuidVector( |
1158 | | - String name, BufferAllocator allocator, FixedSizeBinaryVector underlyingVector) { |
1159 | | - super(name, allocator, underlyingVector); |
1160 | | - } |
1161 | | - |
1162 | | - @Override |
1163 | | - public UUID getObject(int index) { |
1164 | | - final ByteBuffer bb = ByteBuffer.wrap(getUnderlyingVector().getObject(index)); |
1165 | | - return new UUID(bb.getLong(), bb.getLong()); |
1166 | | - } |
1167 | | - |
1168 | | - @Override |
1169 | | - public int hashCode(int index) { |
1170 | | - return hashCode(index, null); |
1171 | | - } |
1172 | | - |
1173 | | - @Override |
1174 | | - public int hashCode(int index, ArrowBufHasher hasher) { |
1175 | | - return getUnderlyingVector().hashCode(index, hasher); |
1176 | | - } |
1177 | | - |
1178 | | - public void set(int index, UUID uuid) { |
1179 | | - ByteBuffer bb = ByteBuffer.allocate(16); |
1180 | | - bb.putLong(uuid.getMostSignificantBits()); |
1181 | | - bb.putLong(uuid.getLeastSignificantBits()); |
1182 | | - getUnderlyingVector().set(index, bb.array()); |
1183 | | - } |
1184 | | - } |
1185 | 1115 | } |
0 commit comments