2nd row is not getting inserted with BitVector in Apache Arrow Flight Sql in Java

38 Views Asked by At

main.java

Schema schema = new Schema(mtasks.asFlightFieldList(), metadata);

try (VectorSchemaRoot vectorSchemaRoot = VectorSchemaRoot.create(schema, rootAllocator)) {
  VarCharVector idVector = (VarCharVector) vectorSchemaRoot.getVector("ID");
  idVector.allocateNew(1);
  idVector.set(0, mtasks.getId().getBytes(StandardCharsets.UTF_8));
 
  BitVector bitVector = (BitVector) vectorSchemaRoot.getVector("MOPT1");
  bitVector.allocateNew(1);
  bitVector.setSafe(0,mtasks.getMopT1() ? 1 : 0);
  bitVector.setValueCount(1);
 
  vectorSchemaRoot.setRowCount(1);
 
 var listener = 
      flightClient.startPut(FlightDescriptor.path("//" + dbSchemaName + "/" + tableName),
      vectorSchemaRoot, new AsyncPutListener());
 
   listener.putNext();
   listener.completed();
   listener.getResult();
 }
 
 
 **POJO class**
 
private final Map<String, ?> properties;
 
public mtasks(Map<String, ?> properties) {
  this.properties = properties;
}
 
public mtasks(String ID, Boolean bitVector) {
   Map<String, Object> properties = new HashMap<>();
   properties.put("BITVECTOR",bitvector);
   properties.put("ID", ID);
   this.properties = properties;
 }

public List<Field> asFlightFieldList() {
   return Arrays.asList(
   new Field("bitvector", new FieldType(false, new ArrowType.Bool(), null), null),
   new Field("ID", new FieldType(false, new ArrowType.Utf8(), null), null));
 }

I am creating vectorschemaroot and trying to get fieldvector of type boolean utilizing Apache arrow flight Sql and insert the data into database.

1st row is getting inserted but 2nd and so on is not inserting. Also, No error/exception is coming.

I tried to debug till listener.getResult() and transaction is getting succeeded.

0

There are 0 best solutions below