vibhatha commented on issue #44410:
URL: https://github.com/apache/arrow/issues/44410#issuecomment-2412853936

   Or...
   
   ```java
   try (VarCharVector v = new VarCharVector("myvec", allocator)) {
         v.allocateNewSafe();
         v.set(0, new Text("Hello"));
         v.set(1, new Text("World"));
         v.setValueCount(2);
   
         System.out.println("Vector");
         System.out.println(v);
   
         final ArrowBuf dataBuffer = v.getDataBuffer();
         final ArrowBuf validityBuffer = v.getValidityBuffer();
         final ArrowBuf offsetBuffer = v.getOffsetBuffer();
   
         try (final ArrowBuf newDataBuffer = 
allocator.buffer(dataBuffer.capacity())) {
           byte[] resAtZero = new byte[20];
           dataBuffer.getBytes(0, resAtZero);
   
           for (int i = 0; i < resAtZero.length; i++) {
             System.out.print(resAtZero[i] + ", ");
             resAtZero[i] += 1;
           }
   
           newDataBuffer.writeBytes(resAtZero, 0, resAtZero.length);
           newDataBuffer.writerIndex(dataBuffer.writerIndex());
   
           // dataBuffer.setBytes(0, resAtZero);
   
           newDataBuffer.readerIndex(0);
   
           ArrowFieldNode fieldNode = new ArrowFieldNode(v.getValueCount(), 
v.getNullCount());
           v.loadFieldBuffers(fieldNode, List.of(validityBuffer, offsetBuffer, 
newDataBuffer));
   
           System.out.println();
           System.out.println("After");
   
           System.out.println(v);
         }
   
         /*
         *
         * Vector
           [Hello, World]
           72, 101, 108, 108, 111, 87, 111, 114, 108, 100,
           After
           [Ifmmp, Xpsme]
         *
         */
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to