Package org.apache.drill.exec.vector

Examples of org.apache.drill.exec.vector.ValueVector$Mutator


      }
     
      // add value vector to transfer if direct reference and this is allowed, otherwise, add to evaluation stack.
      if(expr instanceof ValueVectorReadExpression && incoming.getSchema().getSelectionVectorMode() == SelectionVectorMode.NONE){
        ValueVectorReadExpression vectorRead = (ValueVectorReadExpression) expr;
        ValueVector vvIn = incoming.getValueAccessorById(vectorRead.getFieldId().getFieldId(), TypeHelper.getValueVectorClass(vectorRead.getMajorType().getMinorType(), vectorRead.getMajorType().getMode())).getValueVector();
        Preconditions.checkNotNull(incoming);

        TransferPair tp = vvIn.getTransferPair(getRef(namedExpression));
        transfers.add(tp);
        container.add(tp.getTo());
        logger.debug("Added transfer.");
      }else{
        // need to do evaluation.
        ValueVector vector = TypeHelper.getNewVector(outputField, context.getAllocator());
        allocationVectors.add(vector);
        TypedFieldId fid = container.add(vector);
        ValueVectorWriteExpression write = new ValueVectorWriteExpression(fid, expr);
        cg.addExpr(write);
        logger.debug("Added eval.");
View Full Code Here


  private Copier getGenerated2Copier() throws SchemaChangeException{
    Preconditions.checkArgument(incoming.getSchema().getSelectionVectorMode() == SelectionVectorMode.TWO_BYTE);
   
    List<VectorAllocator> allocators = Lists.newArrayList();
    for(VectorWrapper<?> i : incoming){
      ValueVector v = TypeHelper.getNewVector(i.getField(), context.getAllocator());
      container.add(v);
      allocators.add(VectorAllocator.getAllocator(i.getValueVector(), v));
    }

    try {
View Full Code Here

    Preconditions.checkArgument(incoming.getSchema().getSelectionVectorMode() == SelectionVectorMode.FOUR_BYTE);
   
    List<VectorAllocator> allocators = Lists.newArrayList();
    for(VectorWrapper<?> i : incoming){
     
      ValueVector v = TypeHelper.getNewVector(i.getField(), context.getAllocator());
      container.add(v);
      allocators.add(getAllocator4(v));
    }

    try {
View Full Code Here

    this.valueCount = def.getRecordCount();
    boolean schemaChanged = schema == null;

    Map<MaterializedField, ValueVector> oldFields = Maps.newHashMap();
    for(VectorWrapper<?> w : container){
      ValueVector v = w.getValueVector();
      oldFields.put(v.getField(), v);
    }
   
    VectorContainer newVectors = new VectorContainer();

    List<FieldMetadata> fields = def.getFieldList();

    int bufOffset = 0;
    for (FieldMetadata fmd : fields) {
      FieldDef fieldDef = fmd.getDef();
      ValueVector v = oldFields.remove(fieldDef);
      if(v != null){
        container.add(v);
        continue;
      }

      // if we arrive here, we didn't have a matching vector.
      schemaChanged = true;
      MaterializedField m = new MaterializedField(fieldDef);
      v = TypeHelper.getNewVector(m, allocator);
      if (fmd.getValueCount() == 0){
        v.clear();
      } else {
        v.load(fmd, buf.slice(bufOffset, fmd.getBufferLength()));
      }
      bufOffset += fmd.getBufferLength();
      newVectors.add(v);
    }

    if(!oldFields.isEmpty()){
      schemaChanged = true;
      for(ValueVector v : oldFields.values()){
        v.close();
      }
    }

    // rebuild the schema.
    SchemaBuilder b = BatchSchema.newBuilder();
    for(VectorWrapper<?> v : newVectors){
      b.addField(v.getField());
    }
    b.setSelectionVectorMode(BatchSchema.SelectionVectorMode.NONE);
    this.schema = b.build();
    newVectors.buildSchema(BatchSchema.SelectionVectorMode.NONE);
    container = newVectors;
View Full Code Here

        column = columns.get(i);
        columnChunkMetaData = footer.getBlocks().get(0).getColumns().get(i);
        field = MaterializedField.create(toFieldName(column.getPath()),
            toMajorType(column.getType(), getDataMode(column)));
        fieldFixedLength = column.getType() != PrimitiveType.PrimitiveTypeName.BINARY;
        ValueVector v = TypeHelper.getNewVector(field, allocator);
        if (column.getType() != PrimitiveType.PrimitiveTypeName.BINARY) {
          createFixedColumnReader(fieldFixedLength, column, columnChunkMetaData, recordsPerBatch, v);
        } else {
          if (column.getMaxDefinitionLevel() == 0){// column is required
            varLengthColumns.add(new VarLenBinaryReader.VarLengthColumn(this, -1, column, columnChunkMetaData, false, v));
View Full Code Here

  }

  private ValueVector getVector(String name, MajorType type, int length) {
    assert context != null : "Context shouldn't be null.";
    MaterializedField f = MaterializedField.create(new SchemaPath(name, ExpressionPosition.UNKNOWN), type);
    ValueVector v;
    v = TypeHelper.getNewVector(f, context.getAllocator());
    AllocationHelper.allocate(v, length, 50, 4);
   
    return v;
View Full Code Here

        return null;
      }

      MaterializedField f = MaterializedField.create(new SchemaPath(fullFieldName, ExpressionPosition.UNKNOWN), type);

      ValueVector v = TypeHelper.getNewVector(f, allocator);
      AllocationHelper.allocate(v, batchSize, 50);
      holder = new VectorHolder(v);
      valueVectorMap.put(fullFieldName, holder);
      outputMutator.addField(v);
      return holder;
View Full Code Here

      for (QueryResultBatch b : results) {
        System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
        loader.load(b.getHeader().getDef(), b.getData());
        for (VectorWrapper vw : loader) {
          System.out.println(vw.getValueVector().getField().getName());
          ValueVector vv = vw.getValueVector();
          for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
            Object o = vv.getAccessor().getObject(i);
            System.out.println(vv.getAccessor().getObject(i));
          }
        }
      }
      client.close();
    }
View Full Code Here

      for (QueryResultBatch b : results) {
        System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
        loader.load(b.getHeader().getDef(), b.getData());
        for (VectorWrapper vw : loader) {
          System.out.println(vw.getValueVector().getField().getName());
          ValueVector vv = vw.getValueVector();
          for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
            Object o = vv.getAccessor().getObject(i);
            System.out.println(vv.getAccessor().getObject(i));
          }
        }
      }
      client.close();
    }
View Full Code Here

      for (QueryResultBatch b : results) {
        System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
        loader.load(b.getHeader().getDef(), b.getData());
        for (VectorWrapper vw : loader) {
          System.out.println(vw.getValueVector().getField().getName());
          ValueVector vv = vw.getValueVector();
          for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
            Object o = vv.getAccessor().getObject(i);
            if(vv instanceof VarBinaryVector){
              VarBinaryVector.Accessor x = ((VarBinaryVector) vv).getAccessor();
              VarBinaryHolder vbh = new VarBinaryHolder();
              x.get(i, vbh);
              System.out.printf("%d..%d", vbh.start, vbh.end);
             
              System.out.println("[" + new String( (byte[]) vv.getAccessor().getObject(i)) + "]")
            }else{
              System.out.println(vv.getAccessor().getObject(i));
            }
           
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.vector.ValueVector$Mutator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.