@@ -1314,6 +1314,84 @@ public void testCopyFromForExtensionType() throws Exception {
13141314 }
13151315 }
13161316
1317+ @ Test
1318+ public void testCopyValueSafeForExtensionType () throws Exception {
1319+ try (ListVector inVector = ListVector .empty ("input" , allocator );
1320+ ListVector outVector = ListVector .empty ("output" , allocator )) {
1321+ UnionListWriter writer = inVector .getWriter ();
1322+ writer .allocate ();
1323+
1324+ // Create first list with UUIDs
1325+ writer .setPosition (0 );
1326+ UUID u1 = UUID .randomUUID ();
1327+ UUID u2 = UUID .randomUUID ();
1328+ writer .startList ();
1329+ ExtensionWriter extensionWriter = writer .extension (new UuidType ());
1330+ extensionWriter .addExtensionTypeWriterFactory (new UuidWriterFactory ());
1331+ extensionWriter .writeExtension (u1 );
1332+ extensionWriter .writeExtension (u2 );
1333+ writer .endList ();
1334+
1335+ // Create second list with UUIDs
1336+ writer .setPosition (1 );
1337+ UUID u3 = UUID .randomUUID ();
1338+ UUID u4 = UUID .randomUUID ();
1339+ writer .startList ();
1340+ extensionWriter = writer .extension (new UuidType ());
1341+ extensionWriter .addExtensionTypeWriterFactory (new UuidWriterFactory ());
1342+ extensionWriter .writeExtension (u3 );
1343+ extensionWriter .writeExtension (u4 );
1344+ extensionWriter .writeNull ();
1345+
1346+ writer .endList ();
1347+ writer .setValueCount (2 );
1348+
1349+ // Use copyFromSafe with ExtensionTypeWriterFactory
1350+ // This internally calls TransferImpl.copyValueSafe with ExtensionTypeWriterFactory
1351+ outVector .allocateNew ();
1352+ outVector .copyFromSafe (0 , 0 , inVector , new UuidWriterFactory ());
1353+ outVector .copyFromSafe (1 , 1 , inVector , new UuidWriterFactory ());
1354+ outVector .setValueCount (2 );
1355+
1356+ // Verify first list
1357+ UnionListReader reader = outVector .getReader ();
1358+ reader .setPosition (0 );
1359+ assertTrue (reader .isSet (), "first list shouldn't be null" );
1360+ reader .next ();
1361+ FieldReader uuidReader = reader .reader ();
1362+ UuidHolder holder = new UuidHolder ();
1363+ uuidReader .read (holder );
1364+ ByteBuffer bb = ByteBuffer .wrap (holder .value );
1365+ UUID actualUuid = new UUID (bb .getLong (), bb .getLong ());
1366+ assertEquals (u1 , actualUuid );
1367+ reader .next ();
1368+ uuidReader = reader .reader ();
1369+ uuidReader .read (holder );
1370+ bb = ByteBuffer .wrap (holder .value );
1371+ actualUuid = new UUID (bb .getLong (), bb .getLong ());
1372+ assertEquals (u2 , actualUuid );
1373+
1374+ // Verify second list
1375+ reader .setPosition (1 );
1376+ assertTrue (reader .isSet (), "second list shouldn't be null" );
1377+ reader .next ();
1378+ uuidReader = reader .reader ();
1379+ uuidReader .read (holder );
1380+ bb = ByteBuffer .wrap (holder .value );
1381+ actualUuid = new UUID (bb .getLong (), bb .getLong ());
1382+ assertEquals (u3 , actualUuid );
1383+ reader .next ();
1384+ uuidReader = reader .reader ();
1385+ uuidReader .read (holder );
1386+ bb = ByteBuffer .wrap (holder .value );
1387+ actualUuid = new UUID (bb .getLong (), bb .getLong ());
1388+ assertEquals (u4 , actualUuid );
1389+ reader .next ();
1390+ uuidReader = reader .reader ();
1391+ assertFalse (uuidReader .isSet (), "third element should be null" );
1392+ }
1393+ }
1394+
13171395 private void writeIntValues (UnionListWriter writer , int [] values ) {
13181396 writer .startList ();
13191397 for (int v : values ) {
0 commit comments