Package com.foundationdb.sql.types

Examples of com.foundationdb.sql.types.CharacterTypeAttributes


        ValueNode operand = node.getOperand();
        DataTypeDescriptor origType = operand.getType();
        if (origType != null) {
            if (!origType.getTypeId().isStringTypeId())
                throw new StandardException("Collation not allowed for " + origType);
            CharacterTypeAttributes characterAttributes =
                CharacterTypeAttributes.forCollation(origType.getCharacterAttributes(),
                                                     node.getCollation());
            operand.setType(new DataTypeDescriptor(origType, characterAttributes));
        }
        return operand;
View Full Code Here


    }

    @Override
    public AkCollator getCollator() {
        if (sqlType != null) {
            CharacterTypeAttributes att = sqlType.getCharacterAttributes();
            if (att != null) {
                String coll = att.getCollation();
                if (coll != null)
                    return AkCollatorFactory.getAkCollator(coll);
            }
        }
        return null;
View Full Code Here

    public void finishPreptimePhase(TPreptimeContext context)
    {
        LikeType likeType = this.likeType;
        if (likeType == LikeType.LIKE)
        {
            CharacterTypeAttributes strAttrs = StringAttribute.characterTypeAttributes(context.inputTypeAt(0));
            CharacterTypeAttributes keyAttrs = StringAttribute.characterTypeAttributes(context.inputTypeAt(1));
            AkCollator collator = TString.mergeAkCollators(strAttrs, keyAttrs);
            if (collator != null)
            {
                likeType = collator.isCaseSensitive() ? LikeType.BLIKE : LikeType.ILIKE;
            }
View Full Code Here

                        result.hashColumns.add(hashColumn);
                        result.tKeyComparables.add(ccond.getKeyComparable());
                        AkCollator collator = null;
                        if (left.getType().hasAttributes(StringAttribute.class) &&
                            right.getType().hasAttributes(StringAttribute.class)) {
                            CharacterTypeAttributes leftAttributes = StringAttribute.characterTypeAttributes(left.getType());
                            CharacterTypeAttributes rightAttributes = StringAttribute.characterTypeAttributes(right.getType());
                            collator = TString.mergeAkCollators(leftAttributes, rightAttributes);

                        }
                        result.collators.add(collator);
                    }
View Full Code Here

        TClass tClass = leftInstance.typeClass();
        assert tClass.compatibleForCompare(rightInstance.typeClass())
                : tClass + " != " + rightInstance.typeClass();
        if (tClass.underlyingType() != UnderlyingType.STRING)
            return null;
        CharacterTypeAttributes leftAttributes = StringAttribute.characterTypeAttributes(leftInstance);
        CharacterTypeAttributes rightAttributes = StringAttribute.characterTypeAttributes(rightInstance);
        return TString.mergeAkCollators(leftAttributes, rightAttributes);
    }
View Full Code Here

    protected TInstance typeForStringType(TClass tclass, DataTypeDescriptor type,
                                          int defaultCharsetId, int defaultCollationId,
                                          String schemaName, String tableName, String columnName) {
        int charsetId, collationId;
        CharacterTypeAttributes typeAttributes = type.getCharacterAttributes();
        if ((typeAttributes == null) || (typeAttributes.getCharacterSet() == null)) {
            charsetId = defaultCharsetId;
        }
        else {
            charsetId = StringFactory.charsetNameToId(typeAttributes.getCharacterSet());
        }
        if ((typeAttributes == null) || (typeAttributes.getCollation() == null)) {
            collationId = defaultCollationId;
        }
        else {
            collationId = StringFactory.collationNameToId(typeAttributes.getCollation());
        }
        return tclass.instance(type.getMaximumWidth(),
                               charsetId, collationId,
                               type.isNullable());
    }
View Full Code Here

            return obj;
        }
    }

    public static AkCollator mergeAkCollators(CharacterTypeAttributes type1Atts, CharacterTypeAttributes type2Atts) {
        CharacterTypeAttributes att;
        try {
            att = CharacterTypeAttributes.mergeCollations(type1Atts, type2Atts);
        }
        catch (StandardException ex) {
            throw new SQLParserInternalException(ex);
        }
        if (att != null) {
            String coll = att.getCollation();
            if (coll != null)
                return AkCollatorFactory.getAkCollator(coll);
        }
        return null;
    }
View Full Code Here

        return null;
    }

    @Override
    protected int doCompare(TInstance typeA, ValueSource sourceA, TInstance typeB, ValueSource sourceB) {
        CharacterTypeAttributes aAttrs = StringAttribute.characterTypeAttributes(typeA);
        CharacterTypeAttributes bAttrs = StringAttribute.characterTypeAttributes(typeB);
        AkCollator collator = mergeAkCollators(aAttrs, bAttrs);
        if (collator == null)
            // TODO in the future, we may want to use some default collator. For now, just use native comparison
            return sourceA.getString().compareTo(sourceB.getString());
        return collator.compare(sourceA, sourceB);
View Full Code Here

        int bCollation = right.attribute(StringAttribute.COLLATION);
        if (aCollation == bCollation) {
            pickCollation = aCollation;
        }
        else {
            CharacterTypeAttributes aAttrs = StringAttribute.characterTypeAttributes(left);
            CharacterTypeAttributes bAttrs = StringAttribute.characterTypeAttributes(right);
            AkCollator collator = mergeAkCollators(aAttrs, bAttrs);
            pickCollation = (collator == null) ? StringFactory.NULL_COLLATION_ID : collator.getCollationId();
        }
        int leftLen = left.attribute(StringAttribute.MAX_LENGTH);
        int rightLen = right.attribute(StringAttribute.MAX_LENGTH);
View Full Code Here

TOP

Related Classes of com.foundationdb.sql.types.CharacterTypeAttributes

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.