當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMode類代碼示例

本文整理匯總了Java中org.apache.drill.common.types.TypeProtos.DataMode的典型用法代碼示例。如果您正苦於以下問題:Java DataMode類的具體用法?Java DataMode怎麽用?Java DataMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataMode類屬於org.apache.drill.common.types.TypeProtos包,在下文中一共展示了DataMode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLeastRestrictiveDataMode

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
public static DataMode getLeastRestrictiveDataMode(List<DataMode> dataModes) {
  boolean hasOptional = false;
  for(DataMode dataMode : dataModes) {
    switch (dataMode) {
      case REPEATED:
        return dataMode;
      case OPTIONAL:
        hasOptional = true;
    }
  }

  if(hasOptional) {
    return DataMode.OPTIONAL;
  } else {
    return DataMode.REQUIRED;
  }
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:18,代碼來源:TypeCastRules.java

示例2: declareWorkspaceVectors

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
private JVar[] declareWorkspaceVectors(ClassGenerator<?> g) {
  JVar[] workspaceJVars = new JVar[workspaceVars.length];

  for(int i =0 ; i < workspaceVars.length; i++){
    if (workspaceVars[i].isInject() == true) {
      workspaceJVars[i] = g.declareClassField("work", g.getModel()._ref(workspaceVars[i].type));
      g.getBlock(BlockType.SETUP).assign(workspaceJVars[i], g.getMappingSet().getIncoming().invoke("getContext").invoke("getManagedBuffer"));
    } else {
      Preconditions.checkState(Types.isFixedWidthType(workspaceVars[i].majorType), String.format("Workspace variable '%s' in aggregation function '%s' is not allowed to have variable length type.", workspaceVars[i].name, registeredNames[0]));
      Preconditions.checkState(workspaceVars[i].majorType.getMode()==DataMode.REQUIRED, String.format("Workspace variable '%s' in aggregation function '%s' is not allowed to have null or repeated type.", workspaceVars[i].name, registeredNames[0]));

      //workspaceJVars[i] = g.declareClassField("work", g.getHolderType(workspaceVars[i].majorType), JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
      workspaceJVars[i] = g.declareClassField("work", g.getHolderType(workspaceVars[i].majorType));

      //Declare a workspace vector for the workspace var.
      TypedFieldId typedFieldId = new TypedFieldId(workspaceVars[i].majorType, g.getWorkspaceTypes().size());
      JVar vv  = g.declareVectorValueSetupAndMember(g.getMappingSet().getWorkspace(), typedFieldId);

      g.getWorkspaceTypes().add(typedFieldId);
      g.getWorkspaceVectors().put(workspaceVars[i], vv);
    }
  }
  return workspaceJVars;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:25,代碼來源:DrillAggFuncHolder.java

示例3: getType

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
private parquet.schema.Type getType(MaterializedField field) {
  MinorType minorType = field.getType().getMinorType();
  DataMode dataMode = field.getType().getMode();
  switch(minorType) {
    case MAP:
      List<parquet.schema.Type> types = Lists.newArrayList();
      for (MaterializedField childField : field.getChildren()) {
        types.add(getType(childField));
      }
      return new GroupType(dataMode == DataMode.REPEATED ? Repetition.REPEATED : Repetition.OPTIONAL, field.getLastName(), types);
    case LIST:
      throw new UnsupportedOperationException("Unsupported type " + minorType);
    default:
      return getPrimitiveType(field);
  }
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:17,代碼來源:ParquetRecordWriter.java

示例4: getHolderReaderImpl

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
public static Class<?> getHolderReaderImpl( MinorType type, DataMode mode){
    switch (type) {      
<#list vv.types as type>
  <#list type.minor as minor>
      case ${minor.class?upper_case}:
        switch (mode) {
          case REQUIRED:
            return ${minor.class}HolderReaderImpl.class;
          case OPTIONAL:
            return Nullable${minor.class}HolderReaderImpl.class;
          case REPEATED:
            return Repeated${minor.class}HolderReaderImpl.class;
        }
  </#list>
</#list>
      default:
        break;
      }
      throw new UnsupportedOperationException(buildErrorMessage("get holder reader implementation", type, mode));
  }
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:21,代碼來源:TypeHelper.java

示例5: getHolderType

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
public static JType getHolderType(JCodeModel model, MinorType type, DataMode mode){
    switch (type) {
    case MAP:
    case LIST:
      return model._ref(ComplexHolder.class);
      
<#list vv.types as type>
  <#list type.minor as minor>
      case ${minor.class?upper_case}:
        switch (mode) {
          case REQUIRED:
            return model._ref(${minor.class}Holder.class);
          case OPTIONAL:
            return model._ref(Nullable${minor.class}Holder.class);
          case REPEATED:
            return model._ref(Repeated${minor.class}Holder.class);
        }
  </#list>
</#list>
      case GENERIC_OBJECT:
        return model._ref(ObjectHolder.class);
      default:
        break;
      }
      throw new UnsupportedOperationException(buildErrorMessage("get holder type", type, mode));
  }
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:27,代碼來源:TypeHelper.java

示例6: getDrillObjectInspector

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
public static ObjectInspector getDrillObjectInspector(DataMode mode, MinorType minorType) {
  try {
    if (mode == DataMode.REQUIRED) {
      if (OIMAP_REQUIRED.containsKey(minorType)) {
        return (ObjectInspector) OIMAP_REQUIRED.get(minorType).newInstance();
      }
    } else if (mode == DataMode.OPTIONAL) {
      if (OIMAP_OPTIONAL.containsKey(minorType)) {
        return (ObjectInspector) OIMAP_OPTIONAL.get(minorType).newInstance();
      }
    } else {
      throw new UnsupportedOperationException("Repeated types are not supported as arguement to Hive UDFs");
    }
  } catch(InstantiationException | IllegalAccessException e) {
    throw new RuntimeException("Failed to instantiate ObjectInspector", e);
  }

  throw new UnsupportedOperationException(
      String.format("Type %s[%s] not supported as arguement to Hive UDFs", minorType.toString(), mode.toString()));
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:21,代碼來源:ObjectInspectorHelper.java

示例7: apply

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
protected R apply(ValueVector vector, A arg) {
  MaterializedField schema = vector.getField();
  MajorType majorType = schema.getType();
  MinorType type = majorType.getMinorType();
  DataMode mode = majorType.getMode();
  switch (type) {
  case MAP:
    if (mode == DataMode.REPEATED) {
      return visitRepeatedMap((RepeatedMapVector) vector, arg);
    } else {
      return visitMap((AbstractMapVector) vector, arg);
    }
  case LIST:
    if (mode == DataMode.REPEATED) {
      return visitRepeatedList((RepeatedListVector) vector, arg);
    } else {
      return visitList((ListVector) vector, arg);
    }
  default:
    if (mode == DataMode.REPEATED) {
      return visitRepeatedPrimitive((BaseRepeatedValueVector) vector, arg);
    } else {
      return visitPrimitive(vector, arg);
    }
  }
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:27,代碼來源:ContainerVisitor.java

示例8: declare

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
/**
 * Adds local variable declaration based on given name and type.
 *
 * @param t major type
 * @param name variable name
 * @param includeNewInstance whether to create new instance
 * @return holder instance
 */
public HoldingContainer declare(MajorType t, String name, boolean includeNewInstance) {
  JType holderType = getHolderType(t);
  JVar var;
  if (includeNewInstance) {
    var = getEvalBlock().decl(holderType, name + index, JExpr._new(holderType));
  } else {
    var = getEvalBlock().decl(holderType, name + index);
  }
  JFieldRef outputSet = null;
  if (t.getMode() == DataMode.OPTIONAL) {
    outputSet = var.ref("isSet");
  }
  index++;
  return new HoldingContainer(t, var, var.ref("value"), outputSet);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:24,代碼來源:ClassGenerator.java

示例9: declareWorkspaceVectors

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
private JVar[] declareWorkspaceVectors(ClassGenerator<?> g) {
  JVar[] workspaceJVars = new JVar[getWorkspaceVars().length];

  for(int i =0 ; i < getWorkspaceVars().length; i++){
    if (getWorkspaceVars()[i].isInject()) {
      workspaceJVars[i] = g.declareClassField("work", g.getModel()._ref(getWorkspaceVars()[i].getType()));
      g.getBlock(BlockType.SETUP).assign(workspaceJVars[i], g.getMappingSet().getIncoming().invoke("getContext").invoke("getManagedBuffer"));
    } else {
      Preconditions.checkState(Types.isFixedWidthType(getWorkspaceVars()[i].getMajorType()), String.format("Workspace variable '%s' in aggregation function '%s' is not allowed to " +
          "have variable length type.", getWorkspaceVars()[i].getName(), getRegisteredNames()[0]));
      Preconditions.checkState(getWorkspaceVars()[i].getMajorType().getMode()==DataMode.REQUIRED, String.format("Workspace variable '%s' in aggregation function '%s' is not allowed" +
          " to have null or repeated type.", getWorkspaceVars()[i].getName(), getRegisteredNames()[0]));

      //workspaceJVars[i] = g.declareClassField("work", g.getHolderType(workspaceVars[i].majorType), JExpr._new(g.getHolderType(workspaceVars[i].majorType)));
      workspaceJVars[i] = g.declareClassField("work", g.getHolderType(getWorkspaceVars()[i].getMajorType()));

      //Declare a workspace vector for the workspace var.
      TypedFieldId typedFieldId = new TypedFieldId(getWorkspaceVars()[i].getMajorType(), g.getWorkspaceTypes().size());
      JVar vv  = g.declareVectorValueSetupAndMember(g.getMappingSet().getWorkspace(), typedFieldId);

      g.getWorkspaceTypes().add(typedFieldId);
      g.getWorkspaceVectors().put(getWorkspaceVars()[i], vv);
    }
  }
  return workspaceJVars;
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:27,代碼來源:DrillAggFuncHolder.java

示例10: MockColumn

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
@JsonCreator
public MockColumn(@JsonProperty("name") String name,
                  @JsonProperty("type") MinorType minorType,
                  @JsonProperty("mode") DataMode mode,
                  @JsonProperty("width") Integer width,
                  @JsonProperty("precision") Integer precision,
                  @JsonProperty("scale") Integer scale,
                  @JsonProperty("generator") String generator,
                  @JsonProperty("repeat") Integer repeat,
                  @JsonProperty("properties") Map<String,Object> properties) {
  this.name = name;
  this.minorType = minorType;
  this.mode = mode;
  this.width = width;
  this.precision = precision;
  this.scale = scale;
  this.generator = generator;
  this.repeat = repeat;
  this.properties = properties;
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:21,代碼來源:MockTableDef.java

示例11: testNullableFixedWidthColumn

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
@Test
public void testNullableFixedWidthColumn() {

  MaterializedField field = SchemaBuilder.columnSchema("c", MinorType.INT, DataMode.OPTIONAL );
  ColumnMetadata col = TupleSchema.fromField(field);

  assertEquals(ColumnMetadata.StructureType.PRIMITIVE, col.structureType());
  assertTrue(col.isNullable());
  assertFalse(col.isArray());
  assertFalse(col.isVariableWidth());
  assertFalse(col.isMap());
  assertFalse(col.isList());

  assertEquals(4, col.expectedWidth());
  col.setExpectedWidth(10);
  assertEquals(4, col.expectedWidth());

  assertEquals(1, col.expectedElementCount());
  col.setExpectedElementCount(2);
  assertEquals(1, col.expectedElementCount());
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:22,代碼來源:TestTupleSchema.java

示例12: testNullableVariableWidthColumn

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
@Test
public void testNullableVariableWidthColumn() {

  MaterializedField field = SchemaBuilder.columnSchema("c", MinorType.VARCHAR, DataMode.OPTIONAL );
  ColumnMetadata col = TupleSchema.fromField(field);

  assertTrue(col.isNullable());
  assertFalse(col.isArray());
  assertTrue(col.isVariableWidth());
  assertFalse(col.isMap());
  assertFalse(col.isList());

  assertEquals(50, col.expectedWidth());
  col.setExpectedWidth(10);
  assertEquals(10, col.expectedWidth());

  assertEquals(1, col.expectedElementCount());
  col.setExpectedElementCount(2);
  assertEquals(1, col.expectedElementCount());
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:21,代碼來源:TestTupleSchema.java

示例13: testRepeatedVariableWidthColumn

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
@Test
public void testRepeatedVariableWidthColumn() {

  MaterializedField field = SchemaBuilder.columnSchema("c", MinorType.VARCHAR, DataMode.REPEATED );
  ColumnMetadata col = TupleSchema.fromField(field);

  assertFalse(col.isNullable());
  assertTrue(col.isArray());
  assertTrue(col.isVariableWidth());
  assertFalse(col.isMap());
  assertFalse(col.isList());

  assertEquals(50, col.expectedWidth());
  col.setExpectedWidth(10);
  assertEquals(10, col.expectedWidth());

  assertEquals(ColumnMetadata.DEFAULT_ARRAY_SIZE, col.expectedElementCount());

  col.setExpectedElementCount(2);
  assertEquals(2, col.expectedElementCount());
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:22,代碼來源:TestTupleSchema.java

示例14: testLargeArray

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
/**
 * Create an array that contains more than 64K values. Drill has no numeric
 * limit on array lengths. (Well, it does, but the limit is about 2 billion
 * which, even for bytes, is too large to fit into a vector...)
 */

@Test
public void testLargeArray() {
  ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator());
  RowSetLoader rootWriter = rsLoader.writer();
  MaterializedField field = SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.REPEATED);
  rootWriter.addColumn(field);

  // Create a single array as the column value in the first row. When
  // this overflows, an exception is thrown since overflow is not possible.

  rsLoader.startBatch();
  rootWriter.start();
  ScalarWriter array = rootWriter.array(0).scalar();
  try {
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
      array.setInt(i+1);
    }
    fail();
  } catch (UserException e) {
    // Expected
  }
  rsLoader.close();
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:30,代碼來源:TestResultSetLoaderOverflow.java

示例15: testProjectionDynamic

import org.apache.drill.common.types.TypeProtos.DataMode; //導入依賴的package包/類
@Test
public void testProjectionDynamic() {
  List<SchemaPath> selection = Lists.newArrayList(
      SchemaPath.getSimplePath("c"),
      SchemaPath.getSimplePath("b"),
      SchemaPath.getSimplePath("e"));
  ResultSetOptions options = new OptionBuilder()
      .setProjection(selection)
      .build();
  ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
  RowSetLoader rootWriter = rsLoader.writer();
  rootWriter.addColumn(SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.REQUIRED));
  rootWriter.addColumn(SchemaBuilder.columnSchema("b", MinorType.INT, DataMode.REQUIRED));
  rootWriter.addColumn(SchemaBuilder.columnSchema("c", MinorType.INT, DataMode.REQUIRED));
  rootWriter.addColumn(SchemaBuilder.columnSchema("d", MinorType.INT, DataMode.REQUIRED));

  doProjectionTest(rsLoader);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:19,代碼來源:TestResultSetLoaderProjection.java


注:本文中的org.apache.drill.common.types.TypeProtos.DataMode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。