コード例 #1
0
ファイル: PromotableWriter.java プロジェクト: laurentgo/drill
 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;
 }
コード例 #2
0
ファイル: PromotableWriter.java プロジェクト: laurentgo/drill
 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;
 }