vibhatha commented on issue #44410:
URL: https://github.com/apache/arrow/issues/44410#issuecomment-2412841514
You could try something like the following, but since this is not using the
recommended high level APIs of Vector, user has to take responsibility in
reserving memory and keeping track of buffers if they are explicitly created.
A naive example of shifting `["Hello", "World"]` vector by shifting the byte
value by 1.
```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();
byte[] resAtZero = new byte[10];
dataBuffer.getBytes(0, resAtZero);
for (int i = 0; i < resAtZero.length; i++) {
System.out.print(resAtZero[i] + ", ");
resAtZero[i] += 1;
}
dataBuffer.setBytes(0, resAtZero);
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]