public static SortSpec[] columnsToSortSpecs(Column[] columns) { SortSpec[] specs = new SortSpec[columns.length]; for (int i = 0; i < columns.length; i++) { specs[i] = new SortSpec(columns[i], true, false); } return specs; }
public static SortSpec[] columnsToSortSpecs(Column[] columns) { SortSpec[] specs = new SortSpec[columns.length]; for (int i = 0; i < columns.length; i++) { specs[i] = new SortSpec(columns[i], true, false); } return specs; }
public static SortSpec[] convertSortSpecs(List<CatalogProtos.SortSpecProto> sortSpecProtos) { SortSpec[] sortSpecs = new SortSpec[sortSpecProtos.size()]; int i = 0; for (CatalogProtos.SortSpecProto proto : sortSpecProtos) { sortSpecs[i++] = new SortSpec(proto); } return sortSpecs; }
public static SortSpec[] convertSortSpecs(List<CatalogProtos.SortSpecProto> sortSpecProtos) { SortSpec[] sortSpecs = new SortSpec[sortSpecProtos.size()]; int i = 0; for (CatalogProtos.SortSpecProto proto : sortSpecProtos) { sortSpecs[i++] = new SortSpec(proto); } return sortSpecs; }
public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { // It is used for the merge join executor. The merge join only considers the equi-join. // So, theta-join flag must be false. List<Column[]> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner, false); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][]{outerSortSpec, innerSortSpec}; }
public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { // It is used for the merge join executor. The merge join only considers the equi-join. // So, theta-join flag must be false. List<Column[]> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner, false); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][]{outerSortSpec, innerSortSpec}; }
@Override public Object clone() throws CloneNotSupportedException { IndexMeta clone = (IndexMeta) super.clone(); clone.indexName = indexName; clone.indexPath = indexPath; clone.indexMethod = indexMethod; clone.keySortSpecs = new SortSpec[keySortSpecs.length]; for (int i = 0; i < keySortSpecs.length; i++) { clone.keySortSpecs[i] = new SortSpec(this.keySortSpecs[i].getProto()); } clone.isUnique = this.isUnique; clone.isClustered = this.isClustered; clone.targetRelationSchema = this.targetRelationSchema; return clone; }
@Override public Object clone() throws CloneNotSupportedException { IndexMeta clone = (IndexMeta) super.clone(); clone.indexName = indexName; clone.indexPath = indexPath; clone.indexMethod = indexMethod; clone.keySortSpecs = new SortSpec[keySortSpecs.length]; for (int i = 0; i < keySortSpecs.length; i++) { clone.keySortSpecs[i] = new SortSpec(this.keySortSpecs[i].getProto()); } clone.isUnique = this.isUnique; clone.isClustered = this.isClustered; clone.targetRelationSchema = this.targetRelationSchema; return clone; }
private void initKeySortSpecs(final Schema targetRelationSchema, final SortSpec[] keySortSpecs) { this.targetRelationSchema = targetRelationSchema; this.keySortSpecs = new SortSpec[keySortSpecs.length]; for (int i = 0; i < keySortSpecs.length; i++) { this.keySortSpecs[i] = new SortSpec(keySortSpecs[i].getSortKey(), keySortSpecs[i].isAscending(), keySortSpecs[i].isNullsFirst()); } Arrays.sort(this.keySortSpecs, new Comparator<SortSpec>() { @Override public int compare(SortSpec o1, SortSpec o2) { return targetRelationSchema.getColumnId(o1.getSortKey().getSimpleName()) - targetRelationSchema.getColumnId(o2.getSortKey().getSimpleName()); } }); }
private void initKeySortSpecs(final Schema targetRelationSchema, final SortSpec[] keySortSpecs) { this.targetRelationSchema = targetRelationSchema; this.keySortSpecs = new SortSpec[keySortSpecs.length]; for (int i = 0; i < keySortSpecs.length; i++) { this.keySortSpecs[i] = new SortSpec(keySortSpecs[i].getSortKey(), keySortSpecs[i].isAscending(), keySortSpecs[i].isNullsFirst()); } Arrays.sort(this.keySortSpecs, new Comparator<SortSpec>() { @Override public int compare(SortSpec o1, SortSpec o2) { return targetRelationSchema.getColumnId(o1.getSortKey().getSimpleName()) - targetRelationSchema.getColumnId(o2.getSortKey().getSimpleName()); } }); }
public SimplePredicate(SimplePredicateProto proto) { keySortSpec = new SortSpec(proto.getKeySortSpec()); value = EvalNodeDeserializer.deserialize(proto.getValue()); }
public SimplePredicate(SimplePredicateProto proto) { keySortSpec = new SortSpec(proto.getKeySortSpec()); value = EvalNodeDeserializer.deserialize(proto.getValue()); }
private static SortSpec[] annotateSortSpecs(QueryBlock block, String [] referNames, Sort.SortSpec[] rawSortSpecs) { int sortKeyNum = rawSortSpecs.length; Column column; List<SortSpec> annotatedSortSpecs = Lists.newArrayList(); for (int i = 0; i < sortKeyNum; i++) { String refName = referNames[i]; if (block.isConstReference(refName)) { continue; } else if (block.namedExprsMgr.isEvaluated(refName)) { column = block.namedExprsMgr.getTarget(refName).getNamedColumn(); } else { throw new IllegalStateException("Unexpected State: " + StringUtils.join(rawSortSpecs)); } annotatedSortSpecs.add(new SortSpec(column, rawSortSpecs[i].isAscending(), rawSortSpecs[i].isNullsFirst())); } return annotatedSortSpecs.toArray(new SortSpec[annotatedSortSpecs.size()]); }
private static SortSpec[] annotateSortSpecs(QueryBlock block, String [] referNames, Sort.SortSpec[] rawSortSpecs) { int sortKeyNum = rawSortSpecs.length; Column column; List<SortSpec> annotatedSortSpecs = Lists.newArrayList(); for (int i = 0; i < sortKeyNum; i++) { String refName = referNames[i]; if (block.isConstReference(refName)) { continue; } else if (block.namedExprsMgr.isEvaluated(refName)) { column = block.namedExprsMgr.getTarget(refName).getNamedColumn(); } else { throw new IllegalStateException("Unexpected State: " + StringUtils.join(rawSortSpecs)); } annotatedSortSpecs.add(new SortSpec(column, rawSortSpecs[i].isAscending(), rawSortSpecs[i].isNullsFirst())); } return annotatedSortSpecs.toArray(new SortSpec[annotatedSortSpecs.size()]); }
public IndexDesc(IndexDescProto proto) { this(); SortSpec[] keySortSpecs = new SortSpec[proto.getKeySortSpecsCount()]; for (int i = 0; i < keySortSpecs.length; i++) { keySortSpecs[i] = new SortSpec(proto.getKeySortSpecs(i)); } try { this.set(proto.getTableIdentifier().getDatabaseName(), proto.getTableIdentifier().getTableName(), proto.getIndexName(), new URI(proto.getIndexPath()), keySortSpecs, proto.getIndexMethod(), proto.getIsUnique(), proto.getIsClustered(), SchemaFactory.newV1(proto.getTargetRelationSchema())); } catch (URISyntaxException e) { e.printStackTrace(); } }
public IndexDesc(IndexDescProto proto) { this(); SortSpec[] keySortSpecs = new SortSpec[proto.getKeySortSpecsCount()]; for (int i = 0; i < keySortSpecs.length; i++) { keySortSpecs[i] = new SortSpec(proto.getKeySortSpecs(i)); } try { this.set(proto.getTableIdentifier().getDatabaseName(), proto.getTableIdentifier().getTableName(), proto.getIndexName(), new URI(proto.getIndexPath()), keySortSpecs, proto.getIndexMethod(), proto.getIsUnique(), proto.getIsClustered(), new Schema(proto.getTargetRelationSchema())); } catch (URISyntaxException e) { e.printStackTrace(); } }
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); }
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); }
public BaseTupleComparator(TupleComparatorProto proto) { this.schema = new Schema(proto.getSchema()); this.sortSpecs = new SortSpec[proto.getSortSpecsCount()]; for (int i = 0; i < proto.getSortSpecsCount(); i++) { sortSpecs[i] = new SortSpec(proto.getSortSpecs(i)); } this.sortKeyIds = new int[proto.getCompSpecsCount()]; this.asc = new boolean[proto.getCompSpecsCount()]; this.nullFirsts = new boolean[proto.getCompSpecsCount()]; for (int i = 0; i < proto.getCompSpecsCount(); i++) { TupleComparatorSpecProto sortSepcProto = proto.getCompSpecs(i); sortKeyIds[i] = sortSepcProto.getColumnId(); asc[i] = sortSepcProto.getAscending(); nullFirsts[i] = sortSepcProto.getNullFirst(); } }
public BaseTupleComparator(TupleComparatorProto proto) { this.schema = SchemaFactory.newV1(proto.getSchema()); this.sortSpecs = new SortSpec[proto.getSortSpecsCount()]; for (int i = 0; i < proto.getSortSpecsCount(); i++) { sortSpecs[i] = new SortSpec(proto.getSortSpecs(i)); } this.sortKeyIds = new int[proto.getCompSpecsCount()]; this.asc = new boolean[proto.getCompSpecsCount()]; this.nullFirsts = new boolean[proto.getCompSpecsCount()]; for (int i = 0; i < proto.getCompSpecsCount(); i++) { TupleComparatorSpecProto sortSepcProto = proto.getCompSpecs(i); sortKeyIds[i] = sortSepcProto.getColumnId(); asc[i] = sortSepcProto.getAscending(); nullFirsts[i] = sortSepcProto.getNullFirst(); } }