public int getIndex(Column column) { if (!contains(column)) { return -1; } if (column.hasQualifier()) { return fieldsByQualifiedName.get(column.getQualifiedName()); } else { return fieldsByName.get(column.getSimpleName()).get(0); } }
public int getIndex(Column column) { if (!contains(column)) { return -1; } if (column.hasQualifier()) { return fieldsByQualifiedName.get(column.getQualifiedName()); } else { return fieldsByName.get(column.getSimpleName()).get(0); } }
/** * It removes all table names from FieldEvals in targets * * @param sourceTargets The targets to be stripped * @return The stripped targets */ public static List<Target> stripTarget(List<Target> sourceTargets) { List<Target> copy = new ArrayList<>(); for (int i = 0; i < sourceTargets.size(); i++) { try { copy.add((Target) sourceTargets.get(i).clone()); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } if (copy.get(i).getEvalTree().getType().equals(EvalType.FIELD)) { FieldEval fieldEval = copy.get(i).getEvalTree(); if (fieldEval.getColumnRef().hasQualifier()) { fieldEval.replaceColumnRef(fieldEval.getColumnName()); } } } return copy; }
public boolean contains(Column column) { // TODO - It's a hack if (NestedPathUtil.isPath(column.getQualifiedName())) { return (getColumn(column.getQualifiedName()) != null); } if (column.hasQualifier()) { return fieldsByQualifiedName.containsKey(column.getQualifiedName()); } else { if (fieldsByName.containsKey(column.getSimpleName())) { int num = fieldsByName.get(column.getSimpleName()).size(); if (num == 0) { throw new IllegalStateException("No such column name: " + column.getSimpleName()); } if (num > 1) { throw new RuntimeException("Ambiguous column name: " + column.getSimpleName()); } return true; } return false; } }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); // TODO - column namespace should be improved to simplify name handling and resolving. if (column.hasQualifier()) { fieldId = schema.getColumnId(column.getQualifiedName()); } else { fieldId = schema.getColumnIdByName(column.getSimpleName()); } if (fieldId == -1) { throw new IllegalStateException("No Such Column Reference: " + column + ", schema: " + schema); } return this; }
@Override public boolean contains(Column column) { // TODO - It's a hack if (NestedPathUtil.isPath(column.getQualifiedName())) { return (getColumn(column.getQualifiedName()) != null); } if (column.hasQualifier()) { return fieldsByQualifiedName.containsKey(column.getQualifiedName()); } else { if (fieldsByName.containsKey(column.getSimpleName())) { int num = fieldsByName.get(column.getSimpleName()).size(); if (num == 0) { throw new IllegalStateException("No such column name: " + column.getSimpleName()); } if (num > 1) { throw new RuntimeException("Ambiguous column name: " + column.getSimpleName()); } return true; } return false; } }
/** * It removes all table names from FieldEvals in targets * * @param sourceTargets The targets to be stripped * @return The stripped targets */ public static Target[] stripTarget(Target[] sourceTargets) { Target[] copy = new Target[sourceTargets.length]; for (int i = 0; i < sourceTargets.length; i++) { try { copy[i] = (Target) sourceTargets[i].clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } if (copy[i].getEvalTree().getType() == EvalType.FIELD) { FieldEval fieldEval = copy[i].getEvalTree(); if (fieldEval.getColumnRef().hasQualifier()) { fieldEval.replaceColumnRef(fieldEval.getColumnName()); } } } return copy; }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public BaseTupleComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.schema = schema; this.sortSpecs = sortKeys; this.sortKeyIds = new int[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i]= sortKeys[i].isNullsFirst(); } }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public TupleComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.sortKeyIds = new int[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i]= sortKeys[i].isNullFirst(); } }
for (Column col: plan.getGroupingColumns()) { int keyIndex; if (col.hasQualifier()) { keyIndex = inSchema.getColumnId(col.getQualifiedName()); } else { for (Column col : distinctGroupingColumns) { int keyIndex; if (col.hasQualifier()) { keyIndex = inSchema.getColumnId(col.getQualifiedName()); } else {
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public BaseTupleComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.schema = schema; this.sortSpecs = sortKeys; this.sortKeyIds = new int[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i]= sortKeys[i].isNullsFirst(); } }
for (Column col: plan.getGroupingColumns()) { int keyIndex; if (col.hasQualifier()) { keyIndex = inSchema.getColumnId(col.getQualifiedName()); } else { Column col = distinctGroupingColumns[idx]; int keyIndex; if (col.hasQualifier()) { keyIndex = inSchema.getColumnId(col.getQualifiedName()); } else {
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()); }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public UnSafeComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.sortKeyIds = new int[sortKeys.length]; this.sortKeyTypes = new TajoDataTypes.Type[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i] = sortKeys[i].isNullsFirst(); this.sortKeyTypes[i] = sortKeys[i].getSortKey().getDataType().getType(); } }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public UnSafeComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.sortKeyIds = new int[sortKeys.length]; this.sortKeyTypes = new TajoDataTypes.Type[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i] = sortKeys[i].isNullsFirst(); this.sortKeyTypes[i] = sortKeys[i].getSortKey().getDataType().getType(); } }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public PrimitiveComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.sortKeyIds = new int[sortKeys.length]; this.sortKeyTypes = new TajoDataTypes.Type[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i] = sortKeys[i].isNullsFirst(); this.sortKeyTypes[i] = sortKeys[i].getSortKey().getDataType().getType(); } }
/** * @param schema The schema of input tuples * @param sortKeys The description of sort keys */ public PrimitiveComparator(Schema schema, SortSpec[] sortKeys) { Preconditions.checkArgument(sortKeys.length > 0, "At least one sort key must be specified."); this.sortKeyIds = new int[sortKeys.length]; this.sortKeyTypes = new TajoDataTypes.Type[sortKeys.length]; this.asc = new boolean[sortKeys.length]; this.nullFirsts = new boolean[sortKeys.length]; for (int i = 0; i < sortKeys.length; i++) { if (sortKeys[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortKeys[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortKeys[i].getSortKey().getSimpleName()); } this.asc[i] = sortKeys[i].isAscending(); this.nullFirsts[i] = sortKeys[i].isNullsFirst(); this.sortKeyTypes[i] = sortKeys[i].getSortKey().getDataType().getType(); } }
public SortAggregateExec(TaskAttemptContext context, GroupbyNode plan, PhysicalExec child) throws IOException { super(context, plan, child); contexts = new FunctionContext[plan.getAggFunctions() == null ? 0 : plan.getAggFunctions().length]; 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()); }
public RadixSortContext(UnSafeTuple[] in, Schema schema, SortSpec[] sortSpecs, Comparator<UnSafeTuple> comparator, int timSortThreshold) { this.in = in; this.out = new UnSafeTuple[in.length]; this.keys = new int[in.length]; this.maxSortKeyId = sortSpecs.length - 1; this.sortKeyIds = new int[sortSpecs.length]; sortKeyTypes = new Type[sortSpecs.length]; asc = new boolean[sortSpecs.length]; nullFirst = new boolean[sortSpecs.length]; for (int i = 0; i < sortSpecs.length; i++) { if (sortSpecs[i].getSortKey().hasQualifier()) { this.sortKeyIds[i] = schema.getColumnId(sortSpecs[i].getSortKey().getQualifiedName()); } else { this.sortKeyIds[i] = schema.getColumnIdByName(sortSpecs[i].getSortKey().getSimpleName()); } this.asc[i] = sortSpecs[i].isAscending(); this.nullFirst[i] = sortSpecs[i].isNullsFirst(); this.sortKeyTypes[i] = sortSpecs[i].getSortKey().getDataType().getType(); } this.comparator = comparator; this.timSortThreshold = timSortThreshold; }
if (targetInputColumn.hasQualifier()) { index = node.getInSchema().getColumnId(targetInputColumn.getQualifiedName()); } else {