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


Java Column类代码示例

本文整理汇总了Java中org.apache.tajo.catalog.Column的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: resolveFromCurrentAndChildNode

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
/**
 * Try to find the column from the current node and child node. It can find subexprs generated from the optimizer.
 *
 * @param block The current query block
 * @param columnRef The column reference to be found
 * @return The found column
 */
static Column resolveFromCurrentAndChildNode(LogicalPlan.QueryBlock block, ColumnReferenceExpr columnRef)
    throws UndefinedColumnException {

  if (block.getCurrentNode() != null && block.getCurrentNode().getInSchema() != null) {
    Column found = block.getCurrentNode().getInSchema().getColumn(columnRef.getCanonicalName());
    if (found != null) {
      return found;
    } else if (block.getLatestNode() != null) {
      found = block.getLatestNode().getOutSchema().getColumn(columnRef.getName());
      if (found != null) {
        return found;
      }
    }
  }
  return null;
}
 
开发者ID:apache,项目名称:tajo,代码行数:24,代码来源:NameResolver.java

示例2: clone

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
@Override
public Object clone() throws CloneNotSupportedException {
  GroupbyNode grp = (GroupbyNode) super.clone();
  if (groupingColumns != null) {
    grp.groupingColumns = new Column[groupingColumns.length];
    for (int i = 0; i < groupingColumns.length; i++) {
      grp.groupingColumns[i] = groupingColumns[i];
    }
  }

  if (aggrFunctions != null) {
    grp.aggrFunctions = new AggregationFunctionCallEval[aggrFunctions.length];
    for (int i = 0; i < aggrFunctions.length; i++) {
      grp.aggrFunctions[i] = (AggregationFunctionCallEval) aggrFunctions[i].clone();
    }
  }

  if (targets != null) {
    grp.targets = new Target[targets.length];
    for (int i = 0; i < targets.length; i++) {
      grp.targets[i] = (Target) targets[i].clone();
    }
  }

  return grp;
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:27,代码来源:GroupbyNode.java

示例3: resolve

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
@Override
public Column resolve(LogicalPlan plan,
                      LogicalPlan.QueryBlock block,
                      ColumnReferenceExpr columnRef,
                      boolean includeSeflDescTable)
    throws AmbiguousColumnException, AmbiguousTableException, UndefinedColumnException, UndefinedTableException {

  Column column = resolveFromRelsWithinBlock(plan, block, columnRef, includeSeflDescTable);
  if (column != null) {
    return column;
  }

  column = resolveFromCurrentAndChildNode(block, columnRef);
  if (column != null) {
    return column;
  }

  throw new UndefinedColumnException(columnRef.getCanonicalName());
}
 
开发者ID:apache,项目名称:tajo,代码行数:20,代码来源:ResolverByRelsAndSubExprs.java

示例4: getGeneratedPrefixFromExpr

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
/**
 * It generates a column reference prefix name. It is usually used for an expression or predicate without
 * a specified name (i.e., alias). For example, a predicate in WHERE does not have any alias name.
 * It just returns a prefix name. In other words, it always returns the same prefix for the same type of expressions.
 * So, you must add some suffix to the returned name in order to distinguish reference names.
 */
private static String getGeneratedPrefixFromExpr(Expr expr) {
  String prefix;

  switch (expr.getType()) {
  case Column:
    prefix = ((ColumnReferenceExpr) expr).getCanonicalName();
    break;
  case CountRowsFunction:
    prefix = "count";
    break;
  case GeneralSetFunction:
    GeneralSetFunctionExpr setFunction = (GeneralSetFunctionExpr) expr;
    prefix = setFunction.getSignature();
    break;
  case Function:
    FunctionExpr function = (FunctionExpr) expr;
    prefix = function.getSignature();
    break;
  default:
    prefix = expr.getType().name();
  }
  return prefix;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:30,代码来源:LogicalPlan.java

示例5: SortAggregateExec

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public SortAggregateExec(TaskAttemptContext context, GroupbyNode plan, PhysicalExec child) throws IOException {
  super(context, plan, child);
  contexts = new FunctionContext[plan.getAggFunctions() == null ? 0 : plan.getAggFunctions().size()];

  final Column [] keyColumns = plan.getGroupingColumns();
  groupingKeyIds = new int[groupingKeyNum];
  Column col;
  for (int idx = 0; idx < plan.getGroupingColumns().length; idx++) {
    col = keyColumns[idx];
    if (col.hasQualifier()) {
      groupingKeyIds[idx] = inSchema.getColumnId(col.getQualifiedName());
    } else {
      groupingKeyIds[idx] = inSchema.getColumnIdByName(col.getSimpleName());
    }
  }
  currentKey = new VTuple(groupingKeyNum);
  outTuple = new VTuple(outSchema.size());
}
 
开发者ID:apache,项目名称:tajo,代码行数:19,代码来源:SortAggregateExec.java

示例6: ColumnStats

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public ColumnStats(CatalogProtos.ColumnStatsProto proto) {
  this.column = new Column(proto.getColumn());

  if (proto.hasNumDistVal()) {
    this.numDistVals = proto.getNumDistVal();
  }
  if (proto.hasNumNulls()) {
    this.numNulls = proto.getNumNulls();
  }
  if (proto.hasMinValue()) {
    this.minValue = DatumFactory.createFromBytes(getColumn().getDataType(), proto.getMinValue().toByteArray());
  }
  if (proto.hasMaxValue()) {
    this.maxValue = DatumFactory.createFromBytes(getColumn().getDataType(), proto.getMaxValue().toByteArray());
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:17,代码来源:ColumnStats.java

示例7: createWindowAgg

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public PhysicalExec createWindowAgg(TaskAttemptContext context,WindowAggNode windowAggNode, PhysicalExec subOp)
    throws IOException {
  PhysicalExec child = subOp;
  if (windowAggNode.hasPartitionKeys()) {
    Column[] grpColumns = windowAggNode.getPartitionKeys();
    SortSpec[] sortSpecs = new SortSpec[grpColumns.length];
    for (int i = 0; i < grpColumns.length; i++) {
      sortSpecs[i] = new SortSpec(grpColumns[i], true, false);
    }

    SortNode sortNode = LogicalPlan.createNodeWithoutPID(SortNode.class);
    sortNode.setSortSpecs(sortSpecs);
    sortNode.setInSchema(subOp.getSchema());
    sortNode.setOutSchema(subOp.getSchema());
    child = new ExternalSortExec(context, sortNode, subOp);
    LOG.info("The planner chooses [Sort Aggregation] in (" + StringUtils.join(sortSpecs) + ")");
  }

  return new WindowAggExec(context, windowAggNode, child);
}
 
开发者ID:apache,项目名称:tajo,代码行数:21,代码来源:PhysicalPlannerImpl.java

示例8: testEquals

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
@Test
public void testEquals() {
  TajoConf conf = new TajoConf();

  Schema schema = SchemaBuilder.builder()
      .add("id", Type.INT4)
      .add("name", Type.TEXT)
      .add("age", Type.INT2)
      .build();
  GroupbyNode groupbyNode = new GroupbyNode(0);
  groupbyNode.setGroupingColumns(new Column[]{schema.getColumn(1), schema.getColumn(2)});
  ScanNode scanNode = new ScanNode(0);
  scanNode.init(CatalogUtil.newTableDesc("in", schema,
      CatalogUtil.newTableMeta(BuiltinStorages.TEXT, conf), new Path("in")));

  GroupbyNode groupbyNode2 = new GroupbyNode(0);
  groupbyNode2.setGroupingColumns(new Column[]{schema.getColumn(1), schema.getColumn(2)});
  JoinNode joinNode = new JoinNode(0);
  ScanNode scanNode2 = new ScanNode(0);
  scanNode2.init(CatalogUtil.newTableDesc("in2", schema,
      CatalogUtil.newTableMeta(BuiltinStorages.TEXT, conf), new Path("in2")));

  groupbyNode.setChild(scanNode);
  groupbyNode2.setChild(joinNode);
  joinNode.setLeftChild(scanNode);
  joinNode.setRightChild(scanNode2);

  assertTrue(groupbyNode.equals(groupbyNode2));
  assertFalse(groupbyNode.deepEquals(groupbyNode2));

  ScanNode scanNode3 = new ScanNode(0);
  scanNode3.init(CatalogUtil.newTableDesc("in", schema,
      CatalogUtil.newTableMeta(BuiltinStorages.TEXT, conf), new Path("in")));
  groupbyNode2.setChild(scanNode3);

  assertTrue(groupbyNode.equals(groupbyNode2));
  assertTrue(groupbyNode.deepEquals(groupbyNode2));
}
 
开发者ID:apache,项目名称:tajo,代码行数:39,代码来源:TestLogicalNode.java

示例9: MergeScanner

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public MergeScanner(Configuration conf, Schema schema, TableMeta meta, List<FileFragment> rawFragmentList,
                    Schema target)
    throws IOException {
  this.conf = conf;
  this.schema = schema;
  this.meta = meta;
  this.target = target;

  // it should keep the input order. Otherwise, it causes wrong result of sort queries.
  this.fragments = ImmutableList.copyOf(rawFragmentList);
  this.reset();

  if (currentScanner != null) {
    this.projectable = currentScanner.isProjectable();
    this.selectable = currentScanner.isSelectable();
  }

  tableStats = new TableStats();
  long numBytes = 0;

  for (FileFragment eachFileFragment: rawFragmentList) {
    numBytes += (eachFileFragment.getEndKey() - eachFileFragment.getStartKey());
  }
  tableStats.setNumBytes(numBytes);
  tableStats.setNumBlocks(rawFragmentList.size());

  for(Column eachColumn: schema.getColumns()) {
    ColumnStats columnStats = new ColumnStats(eachColumn);
    tableStats.addColumnStat(columnStats);
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:32,代码来源:MergeScanner.java

示例10: testColumnStat

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
@Test
public final void testColumnStat() {
  ColumnStats stat = new ColumnStats(new Column("test", Type.INT8));
  stat.setNumDistVals(1000);
  stat.setNumNulls(999);
  
  assertTrue(1000 == stat.getNumDistValues());
  assertTrue(999 == stat.getNumNulls());
  
  ColumnStats stat2 = new ColumnStats(stat.getProto());
  assertTrue(1000 == stat2.getNumDistValues());
  assertTrue(999 == stat2.getNumNulls());
}
 
开发者ID:apache,项目名称:tajo,代码行数:14,代码来源:TestColumnStat.java

示例11: createTreeReader

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public static DatumTreeReader createTreeReader(TimeZone timeZone,
                                                 int columnId,
                                                 Column column,
                                                 boolean skipCorrupt
  ) throws IOException {
    TypeDesc typeDesc = column.getTypeDesc();
    int orcColumnId = columnId + 1; // root record column is considered
    switch (typeDesc.getDataType().getType()) {
      case BOOLEAN:
        return new BooleanTreeReader(orcColumnId);
      case BIT:
        return new ByteTreeReader(orcColumnId);
      case FLOAT8:
        return new DoubleTreeReader(orcColumnId);
      case FLOAT4:
        return new FloatTreeReader(orcColumnId);
      case INT2:
        return new ShortTreeReader(orcColumnId);
      case INT4:
        return new IntTreeReader(orcColumnId);
      case INT8:
        return new LongTreeReader(orcColumnId, skipCorrupt);
      case TEXT:
        return new StringTreeReader(orcColumnId);
      case CHAR:
        return new CharTreeReader(orcColumnId, typeDesc.getDataType().getLength());
      case BLOB:
        return new BinaryTreeReader(orcColumnId);
      case TIMESTAMP:
        return new TimestampTreeReader(timeZone, orcColumnId, skipCorrupt);
      case DATE:
        return new DateTreeReader(orcColumnId);
//      case STRUCT:
//        return new StructTreeReader(columnId, treeReaderSchema, included, skipCorrupt);
      default:
        throw new TajoRuntimeException(new UnsupportedException("Unsupported type " +
            typeDesc.getDataType().getType().name()));
    }
  }
 
开发者ID:apache,项目名称:tajo,代码行数:40,代码来源:TreeReaderFactory.java

示例12: Locate

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public Locate() {
  super(new Column[] {
      new Column("string", TajoDataTypes.Type.TEXT),
      new Column("substr", TajoDataTypes.Type.TEXT),
      new Column("pos", TajoDataTypes.Type.INT4)
  });
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:8,代码来源:Locate.java

示例13: testDatabaseMetaDataGetColumns

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
@Test
public void testDatabaseMetaDataGetColumns() throws Exception {
  DatabaseMetaData dbmd = conn.getMetaData();

  ResultSet rs = null;

  try {
    String tableName = "lineitem";
    rs = dbmd.getColumns(null, null, tableName, null);

    ResultSetMetaData rsmd = rs.getMetaData();
    int numCols = rsmd.getColumnCount();

    assertEquals(22, numCols);
    int numColumns = 0;

    TableDesc tableDesc = tpch.getTestingCluster().getMaster().getCatalog().getTableDesc(tableName);
    assertNotNull(tableDesc);

    List<Column> columns = tableDesc.getSchema().getColumns();

    while(rs.next()) {
      assertEquals(tableName, rs.getString("TABLE_NAME"));
      assertEquals(columns.get(numColumns).getSimpleName(), rs.getString("COLUMN_NAME"));
      //TODO assert type
      numColumns++;
    }

    assertEquals(16, numColumns);
  } finally {
    if(rs != null) {
      rs.close();
    }
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:36,代码来源:TestTajoJdbc.java

示例14: getNaturalJoinColumns

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
/**
 * Get common columns to be used as join keys of natural joins.
 */
public static Schema getNaturalJoinColumns(Schema left, Schema right) {
  Schema common = new Schema();
  for (Column outer : left.getColumns()) {
    if (!common.containsByName(outer.getSimpleName()) && right.containsByName(outer.getSimpleName())) {
      common.addColumn(new Column(outer.getSimpleName(), outer.getDataType()));
    }
  }
  
  return common;
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:14,代码来源:SchemaUtil.java

示例15: convertSchema

import org.apache.tajo.catalog.Column; //导入依赖的package包/类
public static TypeDescription convertSchema(Schema schema) {
  TypeDescription description = TypeDescription.createStruct();

  for (Column eachColumn : schema.getRootColumns()) {
    description.addField(eachColumn.getQualifiedName(),
        convertTypeInfo(eachColumn.getTypeDesc()));
  }
  return description;
}
 
开发者ID:apache,项目名称:tajo,代码行数:10,代码来源:OrcUtils.java


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