private String getSortSpecString() { StringBuilder sb = new StringBuilder("Column [key= "); SortSpec[] sortSpecs = indexMeta.getKeySortSpecs(); for (int i = 0; i < sortSpecs.length; i++) { sb.append(sortSpecs[i].getSortKey().getQualifiedName()).append(" ") .append(sortSpecs[i].isAscending() ? "asc" : "desc"); if(i < sortSpecs.length - 1) { sb.append(","); } } sb.append("]"); return sb.toString(); }
private String getSortSpecString() { StringBuilder sb = new StringBuilder("Column [key= "); SortSpec[] sortSpecs = indexMeta.getKeySortSpecs(); for (int i = 0; i < sortSpecs.length; i++) { sb.append(sortSpecs[i].getSortKey().getQualifiedName()).append(" ") .append(sortSpecs[i].isAscending() ? "asc" : "desc"); if(i < sortSpecs.length - 1) { sb.append(","); } } sb.append("]"); return sb.toString(); }
public static String buildDDLForIndex(IndexDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())).append("; Type: INDEX;") .append(" Index Method: ").append(desc.getIndexMethod()); sb.append("\n--\n"); sb.append("CREATE INDEX ").append(IdentifierUtil.denormalizeIdentifier(desc.getName())); sb.append(" on ").append(IdentifierUtil.denormalizeIdentifier(desc.getTableName())).append(" ( "); for (SortSpec sortSpec : desc.getKeySortSpecs()) { sb.append(sortSpec.getSortKey().getQualifiedName()).append(" "); sb.append(sortSpec.isAscending() ? "asc" : "desc").append(" "); sb.append(sortSpec.isNullsFirst() ? "null first" : "null last").append(", "); } sb.replace(sb.length() - 2, sb.length() - 1, " )"); sb.append(" location '").append(desc.getIndexPath()).append("';"); return sb.toString(); }
public static String buildDDLForIndex(IndexDesc desc) { StringBuilder sb = new StringBuilder(); sb.append("--\n") .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append("; Type: INDEX;") .append(" Index Method: ").append(desc.getIndexMethod()); sb.append("\n--\n"); sb.append("CREATE INDEX ").append(CatalogUtil.denormalizeIdentifier(desc.getName())); sb.append(" on ").append(CatalogUtil.denormalizeIdentifier(desc.getTableName())).append(" ( "); for (SortSpec sortSpec : desc.getKeySortSpecs()) { sb.append(sortSpec.getSortKey().getQualifiedName()).append(" "); sb.append(sortSpec.isAscending() ? "asc" : "desc").append(" "); sb.append(sortSpec.isNullsFirst() ? "null first" : "null last").append(", "); } sb.replace(sb.length() - 2, sb.length() - 1, " )"); sb.append(" location '").append(desc.getIndexPath()).append("';"); return sb.toString(); }
/** * It computes the value cardinality of a tuple range. * @return */ public static BigInteger computeCardinalityForAllColumns(SortSpec[] sortSpecs, TupleRange range, boolean inclusive) { BigInteger cardinality = BigInteger.ONE; BigInteger columnCard; for (int i = 0; i < sortSpecs.length; i++) { columnCard = computeCardinality(sortSpecs[i].getSortKey().getDataType(), range, i, inclusive, sortSpecs[i].isAscending()); if (BigInteger.ZERO.compareTo(columnCard) < 0) { cardinality = cardinality.multiply(columnCard); } } return cardinality; }
/** * It computes the value cardinality of a tuple range. * @return */ public static BigInteger computeCardinalityForAllColumns(SortSpec[] sortSpecs, TupleRange range, boolean inclusive) { BigInteger cardinality = BigInteger.ONE; BigInteger columnCard; for (int i = 0; i < sortSpecs.length; i++) { columnCard = computeCardinality(sortSpecs[i].getSortKey().getDataType(), range, i, inclusive, sortSpecs[i].isAscending()); if (BigInteger.ZERO.compareTo(columnCard) < 0) { cardinality = cardinality.multiply(columnCard); } } return cardinality; }
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 ComparableVector(int length, SortSpec[] sortKeys, int[] keyIndex) { tuples = new Tuple[length]; vectors = new TupleVector[sortKeys.length]; for (int i = 0; i < vectors.length; i++) { TajoDataTypes.Type type = sortKeys[i].getSortKey().getDataType().getType(); vectors[i] = new TupleVector(vectorType(type), tuples.length, sortKeys[i].isNullsFirst(), sortKeys[i].isAscending()); } this.keyIndex = keyIndex; }
public ComparableVector(int length, SortSpec[] sortKeys, int[] keyIndex) { tuples = new Tuple[length]; vectors = new TupleVector[sortKeys.length]; for (int i = 0; i < vectors.length; i++) { TajoDataTypes.Type type = sortKeys[i].getSortKey().getDataType().getType(); vectors[i] = new TupleVector(vectorType(type), tuples.length, sortKeys[i].isNullsFirst(), sortKeys[i].isAscending()); } this.keyIndex = keyIndex; }
/** * @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(); } }
/** * @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 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 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 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(); } }
inclusive, sortSpecs[i].isAscending());
inclusive, sortSpecs[i].isAscending());
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; }