当前位置: 首页>>代码示例>>Java>>正文


Java TypeProtos.MajorType方法代码示例

本文整理汇总了Java中org.apache.drill.common.types.TypeProtos.MajorType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeProtos.MajorType方法的具体用法?Java TypeProtos.MajorType怎么用?Java TypeProtos.MajorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.drill.common.types.TypeProtos的用法示例。


在下文中一共展示了TypeProtos.MajorType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpreterDateTest

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterDateTest() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.INT)};
  final String expressionStr = "now()";
  final BitControl.PlanFragment planFragment = BitControl.PlanFragment.getDefaultInstance();
  final QueryContextInformation queryContextInfo = planFragment.getContext();
  final int                        timeZoneIndex = queryContextInfo.getTimeZone();
  final org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex));
  final org.joda.time.DateTime     now = new org.joda.time.DateTime(queryContextInfo.getQueryStartTime(), timeZone);

  final long queryStartDate = now.getMillis();

  final TimeStampHolder out = new TimeStampHolder();

  out.value = queryStartDate;

  final ByteBuffer buffer = ByteBuffer.allocate(12);
  buffer.putLong(out.value);
  final long l = buffer.getLong(0);
  final DateTime t = new DateTime(l);

  final String[] expectedFirstTwoValues = {t.toString(), t.toString()};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues, planFragment);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:27,代码来源:ExpressionInterpreterTest.java

示例2: materialize

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Override
boolean materialize(final NamedExpression ne, final VectorContainer batch, final FunctionLookupContext registry)
    throws SchemaChangeException {
  final FunctionCall call = (FunctionCall) ne.getExpr();
  final LogicalExpression input = ExpressionTreeMaterializer.materializeAndCheckErrors(call.args.get(0), batch, registry);
  if (input == null) {
    return false;
  }

  // make sure output vector type is Nullable, because we will write a null value in the first row of each partition
  TypeProtos.MajorType majorType = input.getMajorType();
  if (majorType.getMode() == TypeProtos.DataMode.REQUIRED) {
    majorType = Types.optional(majorType.getMinorType());
  }

  // add corresponding ValueVector to container
  final MaterializedField output = MaterializedField.create(ne.getRef(), majorType);
  batch.addOrGet(output).allocateNew();
  final TypedFieldId outputId =  batch.getValueVectorId(ne.getRef());

  writeInputToLead = new ValueVectorWriteExpression(outputId, input, true);
  return true;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:WindowFunction.java

示例3: logFunctionResolutionError

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
private static void logFunctionResolutionError(ErrorCollector errorCollector, FunctionCall call) {
  // add error to collector
  StringBuilder sb = new StringBuilder();
  sb.append("Missing function implementation: ");
  sb.append("[");
  sb.append(call.getName());
  sb.append("(");
  boolean first = true;
  for(LogicalExpression e : call.args) {
    TypeProtos.MajorType mt = e.getMajorType();
    if (first) {
      first = false;
    } else {
      sb.append(", ");
    }
    sb.append(mt.getMinorType().name());
    sb.append("-");
    sb.append(mt.getMode().name());
  }
  sb.append(")");
  sb.append("]");

  errorCollector.addGeneralError(call.getPosition(), sb.toString());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:25,代码来源:ExpressionTreeMaterializer.java

示例4: visitValueVectorReadExpression

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
protected ValueHolder visitValueVectorReadExpression(ValueVectorReadExpression e, Integer inIndex)
    throws RuntimeException {
  TypeProtos.MajorType type = e.getMajorType();

  ValueVector vv;
  ValueHolder holder;
  try {
    switch (type.getMode()) {
      case OPTIONAL:
      case REQUIRED:
        vv = incoming.getValueAccessorById(TypeHelper.getValueVectorClass(type.getMinorType(),type.getMode()), e.getFieldId().getFieldIds()).getValueVector();
        holder = TypeHelper.getValue(vv, inIndex.intValue());
        return holder;
      default:
        throw new UnsupportedOperationException("Type of " + type + " is not supported yet in interpreted expression evaluation!");
    }
  } catch (Exception ex){
    throw new DrillRuntimeException("Error when evaluate a ValueVectorReadExpression: " + ex);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:InterpreterEvaluator.java

示例5: interpreterNullableStrExpr

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterNullableStrExpr() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.VARCHAR)};
  final String expressionStr =  "substr(col1, 1, 3)";
  final String[] expectedFirstTwoValues = {"aaa", "null"};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:ExpressionInterpreterTest.java

示例6: interpreterNullableIntegerExpr

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterNullableIntegerExpr() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.INT)};
  final String expressionStr = "col1 + 100 - 1 * 2 + 2";
  final String[] expectedFirstTwoValues = {"-2147483548", "null"};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:ExpressionInterpreterTest.java

示例7: resolveHash

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public void resolveHash(DrillConfig config, LogicalExpression arg, TypeProtos.MajorType expectedArg,
                                  TypeProtos.MajorType expectedOut, TypeProtos.DataMode expectedBestInputMode,
                                  FunctionImplementationRegistry registry) throws JClassAlreadyExistsException, IOException {
  final List<LogicalExpression> args = new ArrayList<>();
  args.add(arg);
  final String[] registeredNames = { "hash" };
  FunctionCall call = new FunctionCall(
      "hash",
      args,
      ExpressionPosition.UNKNOWN
  );
  final FunctionResolver resolver = FunctionResolverFactory.getResolver(call);
  final DrillFuncHolder matchedFuncHolder = registry.findDrillFunction(resolver, call);
  assertEquals( expectedBestInputMode, matchedFuncHolder.getParmMajorType(0).getMode());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:TestSimpleFunctions.java

示例8: BaselineQueryTestBuilder

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
BaselineQueryTestBuilder(String baselineQuery, UserBitShared.QueryType baselineQueryType, BufferAllocator allocator,
                         String query, UserBitShared.QueryType queryType, Boolean ordered,
                         boolean approximateEquality, Map<SchemaPath, TypeProtos.MajorType> baselineTypeMap,
                         String baselineOptionSettingQueries, String testOptionSettingQueries, boolean highPerformanceComparison,
                         int expectedNumBatches) {
  super(allocator, query, queryType, ordered, approximateEquality, baselineTypeMap, baselineOptionSettingQueries, testOptionSettingQueries,
      highPerformanceComparison, expectedNumBatches);
  this.baselineQuery = baselineQuery;
  this.baselineQueryType = baselineQueryType;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:TestBuilder.java

示例9: interpreterCaseExpr

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterCaseExpr() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.VARCHAR)};
  final String expressionStr =  "case when substr(col1, 1, 3)='aaa' then 'ABC' else 'XYZ' end";
  final String[] expectedFirstTwoValues = {"ABC", "XYZ"};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:ExpressionInterpreterTest.java

示例10: addTypeInfoIfMissing

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
private void addTypeInfoIfMissing(QueryDataBatch batch, TestBuilder testBuilder) {
  if (! testBuilder.typeInfoSet()) {
    Map<SchemaPath, TypeProtos.MajorType> typeMap = getTypeMapFromBatch(batch);
    testBuilder.baselineTypes(typeMap);
  }

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:DrillTestWrapper.java

示例11: toMajorType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length,
                                        TypeProtos.DataMode mode, SchemaElement schemaElement,
                                        OptionManager options) {
  MinorType minorType = getMinorType(primitiveTypeName, length, schemaElement, options);
  TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode);

  if (CoreDecimalUtility.isDecimalType(minorType)) {
    typeBuilder.setPrecision(schemaElement.getPrecision()).setScale(schemaElement.getScale());
  }
  return typeBuilder.build();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:ParquetToDrillTypeConverter.java

示例12: interpreterLikeExpr

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterLikeExpr() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.VARCHAR)};
  final String expressionStr =  "like(col1, 'aaa%')";
  final String[] expectedFirstTwoValues = {"true", "null"};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:ExpressionInterpreterTest.java

示例13: interpreterNullableBooleanExpr

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void interpreterNullableBooleanExpr() throws Exception {
  final String[] colNames = {"col1"};
  final TypeProtos.MajorType[] colTypes = {Types.optional(TypeProtos.MinorType.VARCHAR)};
  final String expressionStr =  "col1 < 'abc' and col1 > 'abc'";
  final String[] expectedFirstTwoValues = {"false", "null"};

  doTest(expressionStr, colNames, colTypes, expectedFirstTwoValues);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:ExpressionInterpreterTest.java

示例14: testCSVVerificationTypeMap

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void testCSVVerificationTypeMap() throws Throwable {
  Map<SchemaPath, TypeProtos.MajorType> typeMap = new HashMap<>();
  typeMap.put(TestBuilder.parsePath("first_name"), Types.optional(TypeProtos.MinorType.VARCHAR));
  typeMap.put(TestBuilder.parsePath("employee_id"), Types.optional(TypeProtos.MinorType.INT));
  typeMap.put(TestBuilder.parsePath("last_name"), Types.optional(TypeProtos.MinorType.VARCHAR));
  testBuilder()
      .sqlQuery("select cast(columns[0] as int) employee_id, columns[1] as first_name, columns[2] as last_name from cp.`testframework/small_test_data_reordered.tsv`")
      .unOrdered()
      .csvBaselineFile("testframework/small_test_data.tsv")
      .baselineColumns("employee_id", "first_name", "last_name")
      // This should work without this line because of the default type casts added based on the types that come out of the test query.
      // To write a test that enforces strict typing you must pass type information using a CSV with a list of types,
      // or any format with a Map of types like is constructed above and include the call to pass it into the test, which is commented out below
      //.baselineTypes(typeMap)
      .build().run();

  typeMap.clear();
  typeMap.put(TestBuilder.parsePath("first_name"), Types.optional(TypeProtos.MinorType.VARCHAR));
  // This is the wrong type intentionally to ensure failures happen when expected
  typeMap.put(TestBuilder.parsePath("employee_id"), Types.optional(TypeProtos.MinorType.VARCHAR));
  typeMap.put(TestBuilder.parsePath("last_name"), Types.optional(TypeProtos.MinorType.VARCHAR));

  try {
  testBuilder()
      .sqlQuery("select cast(columns[0] as int) employee_id, columns[1] as first_name, columns[2] as last_name from cp.`testframework/small_test_data_reordered.tsv`")
      .unOrdered()
      .csvBaselineFile("testframework/small_test_data.tsv")
      .baselineColumns("employee_id", "first_name", "last_name")
      .baselineTypes(typeMap)
      .build().run();
  } catch (Exception ex) {
    // this indicates successful completion of the test
    return;
  }
  throw new Exception("Test framework verification failed, expected failure on type check.");
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:38,代码来源:TestFrameworkTest.java

示例15: getVectorType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Override
public TypeProtos.MajorType getVectorType(SchemaPath column, PlannerSettings plannerSettings) {
  return ((ParquetGroupScan) scanRel.getGroupScan()).getTypeForColumn(column);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:5,代码来源:ParquetPartitionDescriptor.java


注:本文中的org.apache.drill.common.types.TypeProtos.MajorType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。