Example #1
0
 @Override
 public void setPosition(int index) {
   super.setPosition(index);
   FieldWriter w = getWriter();
   if (w == null) {
     position = index;
   } else {
     w.setPosition(index);
   }
 }
Example #2
0
 protected FieldWriter getWriter(MinorType type) {
   if (state == State.UNION) {
     return writer;
   }
   if (state == State.UNTYPED) {
     if (type == null) {
       return null;
     }
     ValueVector v =
         listVector.addOrGetVector(new VectorDescriptor(Types.optional(type))).getVector();
     v.allocateNew();
     setWriter(v);
     writer.setPosition(position);
   }
   if (type != this.type) {
     return promoteToUnion();
   }
   return writer;
 }
Example #3
0
 private FieldWriter promoteToUnion() {
   String name = vector.getField().getLastName();
   TransferPair tp =
       vector.getTransferPair(
           vector.getField().getType().getMinorType().name().toLowerCase(), vector.getAllocator());
   tp.transfer();
   if (parentContainer != null) {
     unionVector =
         parentContainer.addOrGet(name, Types.optional(MinorType.UNION), UnionVector.class);
   } else if (listVector != null) {
     unionVector = listVector.promoteToUnion();
   }
   unionVector.addVector(tp.getTo());
   writer = new UnionWriter(unionVector);
   writer.setPosition(idx());
   for (int i = 0; i < idx(); i++) {
     unionVector.getMutator().setType(i, vector.getField().getType().getMinorType());
   }
   vector = null;
   state = State.UNION;
   return writer;
 }