Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.SortSpec


  public static SortSpec[] convertSortSpecs(Collection<CatalogProtos.SortSpecProto> sortSpecProtos) {
    SortSpec[] sortSpecs = new SortSpec[sortSpecProtos.size()];
    int i = 0;
    for (CatalogProtos.SortSpecProto proto : sortSpecProtos) {
      sortSpecs[i++] = new SortSpec(proto);
    }
    return sortSpecs;
  }
View Full Code Here


    Context newContext = new Context(context);

    final int sortKeyNum = node.getSortKeys().length;
    String [] keyNames = new String[sortKeyNum];
    for (int i = 0; i < sortKeyNum; i++) {
      SortSpec sortSpec = node.getSortKeys()[i];
      keyNames[i] = newContext.addExpr(new FieldEval(sortSpec.getSortKey()));
    }

    LogicalNode child = super.visitSort(newContext, plan, block, node, stack);

    // it rewrite sortkeys. This rewrite sets right column names and eliminates duplicated sort keys.
    List<SortSpec> sortSpecs = new ArrayList<SortSpec>();
    for (int i = 0; i < keyNames.length; i++) {
      String sortKey = keyNames[i];
      Target target = context.targetListMgr.getTarget(sortKey);
      if (context.targetListMgr.isEvaluated(sortKey)) {
        Column c = target.getNamedColumn();
        SortSpec sortSpec = new SortSpec(c, node.getSortKeys()[i].isAscending(), node.getSortKeys()[i].isNullFirst());
        if (!sortSpecs.contains(sortSpec)) {
          sortSpecs.add(sortSpec);
        }
      } else {
        if (target.getEvalTree().getType() == EvalType.FIELD) {
          Column c = ((FieldEval)target.getEvalTree()).getColumnRef();
          SortSpec sortSpec = new SortSpec(c, node.getSortKeys()[i].isAscending(), node.getSortKeys()[i].isNullFirst());
          if (!sortSpecs.contains(sortSpec)) {
            sortSpecs.add(sortSpec);
          }
        }
      }
View Full Code Here

      SortSpec [] sortSpecs = null;
      if (sortExec != null) {
        sortSpecs = sortExec.getSortSpecs();
      } else {
        Column[] columns = ctx.getDataChannel().getShuffleKeys();
        SortSpec specs[] = new SortSpec[columns.length];
        for (int i = 0; i < columns.length; i++) {
          specs[i] = new SortSpec(columns[i]);
        }
      }
      return new RangeShuffleFileWriteExec(ctx, sm, subOp, plan.getInSchema(), plan.getInSchema(), sortSpecs);

    case NONE_SHUFFLE:
View Full Code Here

    if (storeTableNode.getType() == NodeType.INSERT) {
      InsertNode insertNode = (InsertNode) storeTableNode;
      for (int i = 0; i < partitionKeyColumns.length; i++) {
        for (Column column : partitionKeyColumns) {
          int id = insertNode.getTableSchema().getColumnId(column.getQualifiedName());
          sortSpecs[i++] = new SortSpec(insertNode.getProjectedSchema().getColumn(id), true, false);
        }
      }
    } else {
      for (int i = 0; i < partitionKeyColumns.length; i++) {
        sortSpecs[i] = new SortSpec(partitionKeyColumns[i], true, false);
      }
    }

    SortNode sortNode = LogicalPlan.createNodeWithoutPID(SortNode.class);
    sortNode.setSortSpecs(sortSpecs);
View Full Code Here

                                             PhysicalExec subOp) throws IOException {

    Column[] grpColumns = groupbyNode.getGroupingColumns();
    SortSpec[] sortSpecs = new SortSpec[grpColumns.length];
    for (int i = 0; i < grpColumns.length; i++) {
      sortSpecs[i] = new SortSpec(grpColumns[i], true, false);
    }

    if (property != null) {
      List<CatalogProtos.SortSpecProto> sortSpecProtos = property.getGroupby().getSortSpecsList();

      List<SortSpec> enforcedSortSpecList = Lists.newArrayList();
      int i = 0;
      outer:
      for (int j = 0; j < sortSpecProtos.size(); j++) {
        SortSpec enforcedSortSpecs = new SortSpec(sortSpecProtos.get(j));

        for (Column grpKey : grpColumns) { // if this sort key is included in grouping columns, skip it.
          if (enforcedSortSpecs.getSortKey().equals(grpKey)) {
            continue outer;
          }
        }

        enforcedSortSpecList.add(enforcedSortSpecs);
View Full Code Here

        DatumFactory.createInt4(25),
        DatumFactory.createInt4(109),
        DatumFactory.createInt4(4),
        DatumFactory.createText("abd")});

    SortSpec sortKey1 = new SortSpec(schema.getColumn("col4"), true, false);
    SortSpec sortKey2 = new SortSpec(schema.getColumn("col5"), true, false);

    TupleComparator tc = new TupleComparator(schema,
        new SortSpec[] {sortKey1, sortKey2});
    assertEquals(-1, tc.compare(tuple1, tuple2));
    assertEquals(1, tc.compare(tuple2, tuple1));
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.SortSpec

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.