Package org.apache.drill.exec.record

Examples of org.apache.drill.exec.record.TypedFieldId


   
    JExpression inIndex = JExpr.direct("inIndex");
    JExpression outIndex = JExpr.direct("outIndex");
    g.rotateBlock();
    for(VectorWrapper<?> vv : incoming){
      JVar inVV = g.declareVectorValueSetupAndMember("incoming", new TypedFieldId(vv.getField().getType(), fieldId, vv.isHyper()));
      JVar outVV = g.declareVectorValueSetupAndMember("outgoing", new TypedFieldId(vv.getField().getType(), fieldId, false));

      if(hyper){
       
        g.getEvalBlock().add(
            outVV
View Full Code Here


    }

    @Override
    public LogicalExpression visitSchemaPath(SchemaPath path) {
//      logger.debug("Visiting schema path {}", path);
      TypedFieldId tfId = batch.getValueVectorId(path);
      if (tfId == null) {
        logger.warn("Unable to find value vector of path {}, returning null instance.", path);
        return NullExpression.INSTANCE;
      } else {
        return new ValueVectorReadExpression(tfId);
View Full Code Here

    System.out.println(getExpressionCode("if(true) then 1 else 0 end", batch));
  }

  @Test
  public void testSpecial(final @Injectable RecordBatch batch, @Injectable ValueVector vector) throws Exception {
    final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.INT),0, false);
   
    new NonStrictExpectations() {
      @NonStrict VectorWrapper<?> wrapper;
      {
        batch.getValueVectorId(new SchemaPath("alpha", ExpressionPosition.UNKNOWN));
        result = tfid;
        batch.getValueAccessorById(tfid.getFieldId(), IntVector.class);
        result = wrapper;
        wrapper.getValueVector();
        result = new IntVector(null, null);
      }
View Full Code Here

    return incoming.getSelectionVector2();
  }

  @SuppressWarnings("unchecked")
  public <T extends ValueVector> T getValueVectorById(SchemaPath path, Class<?> vvClass){
    TypedFieldId tfid = incoming.getValueVectorId(path);
    return (T) incoming.getValueAccessorById(tfid.getFieldId(), vvClass).getValueVector();
  }
View Full Code Here

    System.out.println(getExpressionCode("1 + 1", batch));
  }

  @Test
  public void testSchemaExpression(final @Injectable RecordBatch batch) throws Exception {
    final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.BIGINT), 0, false);

    new Expectations() {
      {
        batch.getValueVectorId(new SchemaPath("alpha", ExpressionPosition.UNKNOWN));
        result = tfid;
View Full Code Here

      logger.error("Failure while materializing expression [{}].  Errors: {}", expression, error);
      assertEquals(0, error.getErrorCount());
    }

    CodeGenerator<Projector> cg = new CodeGenerator<Projector>(Projector.TEMPLATE_DEFINITION, new FunctionImplementationRegistry(DrillConfig.create()));
    cg.addExpr(new ValueVectorWriteExpression(new TypedFieldId(materializedExpr.getMajorType(), -1), materializedExpr));
    return cg.generate();
  }
View Full Code Here

    //////////////////////
    cg.setMappingSet(COPY_LEFT_MAPPING);
    int vectorId = 0;
    for (VectorWrapper<?> vw : left) {
      JVar vvIn = cg.declareVectorValueSetupAndMember("incomingLeft",
                                                      new TypedFieldId(vw.getField().getType(), vectorId));
      JVar vvOut = cg.declareVectorValueSetupAndMember("outgoing",
                                                       new TypedFieldId(vw.getField().getType(),vectorId));
      // todo: check result of copyFromSafe and grow allocation
      cg.getEvalBlock().add(vvOut.invoke("copyFromSafe")
                                   .arg(COPY_LEFT_MAPPING.getValueReadIndex())
                                   .arg(COPY_LEFT_MAPPING.getValueWriteIndex())
                                   .arg(vvIn));
      ++vectorId;
    }
    cg.getEvalBlock()._return(JExpr.lit(true));

    // generate copyRight()
    ///////////////////////
    cg.setMappingSet(COPY_RIGHT_MAPPING);

    int rightVectorBase = vectorId;
    for (VectorWrapper<?> vw : right) {
      JVar vvIn = cg.declareVectorValueSetupAndMember("incomingRight",
                                                      new TypedFieldId(vw.getField().getType(), vectorId - rightVectorBase));
      JVar vvOut = cg.declareVectorValueSetupAndMember("outgoing",
                                                       new TypedFieldId(vw.getField().getType(),vectorId));
      // todo: check result of copyFromSafe and grow allocation
      cg.getEvalBlock().add(vvOut.invoke("copyFromSafe")
          .arg(COPY_RIGHT_MAPPING.getValueReadIndex())
          .arg(COPY_RIGHT_MAPPING.getValueWriteIndex())
          .arg(vvIn));
View Full Code Here

      if(expr == null) continue;
     
      final MaterializedField outputField = MaterializedField.create(ne.getRef(), expr.getMajorType());
      ValueVector vector = TypeHelper.getNewVector(outputField, context.getAllocator());
      allocators.add(VectorAllocator.getAllocator(vector, 50));
      TypedFieldId id = container.add(vector);
      valueExprs[i] = new ValueVectorWriteExpression(id, expr, true);
    }
   
    if(collector.hasErrors()) throw new SchemaChangeException("Failure while materializing expression. " + collector.toErrorString());
   
View Full Code Here

      JArray outgoingVectorInitBatch = JExpr.newArray(cg.getModel().ref(ValueVector.class));
      for (VectorWrapper<?> vv : batch) {
        // declare outgoing value vector and assign it to the array
        JVar outVV = cg.declareVectorValueSetupAndMember("outgoing[" + batchId + "]",
                                                         new TypedFieldId(vv.getField().getType(),
                                                                          fieldId,
                                                                          false));
        // add vv to initialization list (e.g. { vv1, vv2, vv3 } )
        outgoingVectorInitBatch.add(outVV);
        ++fieldId;
      }

      // add VV array to initialization list (e.g. new ValueVector[] { ... })
      outgoingVectorInit.add(outgoingVectorInitBatch);
      ++batchId;
      fieldId = 0;
    }

    // generate outgoing value vector 2d array initialization list.
    cg.getSetupBlock().assign(outgoingVectors, outgoingVectorInit);

    for (VectorWrapper<?> vvIn : incoming) {
      // declare incoming value vectors
      JVar incomingVV = cg.declareVectorValueSetupAndMember("incoming", new TypedFieldId(vvIn.getField().getType(),
                                                                                         fieldId,
                                                                                         vvIn.isHyper()));

      // generate the copyFrom() invocation with explicit cast to the appropriate type
      Class<?> vvType = TypeHelper.getValueVectorClass(vvIn.getField().getType().getMinorType(),
View Full Code Here

        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

TOP

Related Classes of org.apache.drill.exec.record.TypedFieldId

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.