Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TClass


        }

        @Override
        public void evaluate() {
            if (!value.hasAnyValue()) { // only need to compute this once
                TClass tClass = type.typeClass();
                ValueSource inSource = bindings.getValue(position);
                // TODO need a better execution context thinger
                TExecutionContext executionContext = new TExecutionContext(
                        null,
                        null,
                        type,
                        context,
                        ErrorHandlingMode.WARN,
                        ErrorHandlingMode.WARN,
                        ErrorHandlingMode.WARN
                );
                tClass.fromObject(executionContext, inSource, value);
            }
        }
View Full Code Here


    }

    public TValidatedScalar createCommuted() {
        if (!coversExactlyNArgs(2))
            throw new IllegalStateException("commuted overloads must take exactly two arguments: " + this);
        TClass origArg1 = inputSetAt(1).targetType();
        TClass origArg0 = inputSetAt(0).targetType();
        if (origArg0 == origArg1)
            throw new IllegalStateException("two-arg overload has same target class for both operands, so commuting "
                    + "it makes no sense: " + this);

        TInputSetBuilder builder = new TInputSetBuilder();
View Full Code Here

        if (comparable == null)
            overload = noKey;
        else {
            TInstance lhsInstance = lhs.resultType();
            boolean reverse;
            TClass leftIn = lhsInstance.typeClass();
            TClass rightIn = rhsInstance.typeClass();
            TClass leftCmp = comparable.getLeftTClass();
            TClass rightCmp = comparable.getRightTClass();
            if (leftIn == leftCmp && rightIn == rightCmp) {
                reverse = false;
            }
            else if (rightIn == leftCmp && leftIn == rightCmp) {
                reverse = true;
View Full Code Here

    @Override
    protected int compare(TInstance leftInstance, ValueSource leftSource,
                          TInstance rightInstance, ValueSource rightSource)
    {
        TClass tClass = leftInstance.typeClass();
        assert rightInstance.typeClass().compatibleForCompare(tClass)
                : "type class mismatch: " + leftInstance + " != " + rightInstance;
        if (collator != null) {
            assert tClass.underlyingType() == UnderlyingType.STRING : tClass + ": " + tClass.underlyingType();
            String leftString = leftSource.getString();
            String rightString = rightSource.getString();
            return collator.compare(leftString, rightString);
        }
        else {
View Full Code Here

    }

    public TComparisonExpression(TPreparedExpression left, Comparison comparison, TPreparedExpression right,
                                 AkCollator collator) {
        super(left, comparison, right);
        TClass oneClass = left.resultType().typeClass();
        TClass twoClass = right.resultType().typeClass();
        if (!oneClass.compatibleForCompare(twoClass))
            throw new IllegalArgumentException("can't compare expressions of different types: " + left + " != " + right);
        if (collator != null && oneClass.underlyingType() != UnderlyingType.STRING) {
            throw new IllegalArgumentException("collator provided, but " + oneClass + " is not a string type");
        }
View Full Code Here

                anyVarargs = true;
        }

        List<TClass> finitesList = new ArrayList<>(nFinites);
        for (int pos = 0; pos < nFinites; ++pos) {
            TClass result = foldBy(overloads, new FoldByPositionalArity(pos));
            finitesList.add(result);
        }

        TClass infiniteArityElement;
        boolean hasInfiniteArityElement;
        if (anyVarargs) {
            infiniteArityElement = foldBy(overloads, foldByVarags);
            hasInfiniteArityElement = true;
        }
View Full Code Here

        }
        return new Result<>(finitesList, infiniteArityElement, hasInfiniteArityElement);
    }

    private TClass foldBy(Collection<? extends TValidatedOverload> overloads, Function<TValidatedOverload, TInputSet> f) {
        TClass result = null;
        boolean seenOne = false;
        for (TValidatedOverload overload : overloads) {
            TInputSet inputSet = f.apply(overload);
            if (inputSet != null) {
                TClass attribute = inputSet.targetType();
                if (seenOne) {
                    if (attribute != null) {
                        result = (result == null) ? attribute : foldOne(result, attribute);
                    }
                }
View Full Code Here

            TInputSet inputSet = overload.inputSetAt(i);
            if ((!requireExact) && inputSet.targetType() == null) {
                continue;
            }
            // ... input can be strongly cast to input set
            TClass inputTypeClass;
            if (requireExact) {
                inputTypeClass = (inputInstance == null) ? null : inputInstance.typeClass();
            }
            else if (inputInstance == null) {
                // If input type is unknown (NULL literal or parameter), assume common type at this position among
                // all overloads in this group.
                inputTypeClass = scalarGroups.commonTypeAt(i);
                if (inputTypeClass == null) { // We couldn't resolve it in this group
                    if (hasNext)              // , but we might find a match in the subsequent ones
                        return false;
                    else
                        throw new OverloadException("couldn't resolve overload because of unknown input at position " + i);
                }
            }
            else {
                inputTypeClass = inputInstance.typeClass();
            }

            if (requireExact) {
                if (inputSet.targetType() == null) {
                    // We're in an ANY-exact input set. The semantics are:
                    // - unknown types are always allowed
                    // - the first known type defines the type of the input set
                    // - subsequent known types must equal this known type
                    if (inputTypeClass == null) {
                        continue;
                    }
                    if (pickSameType == null)
                        pickSameType = new TClass[overload.inputSetIndexCount()];
                    int inputSetIndex = overload.inputSetIndexAtPos(i);
                    TClass definedType = pickSameType[inputSetIndex];
                    if (definedType == null) {
                        pickSameType[inputSetIndex] = inputTypeClass;
                        continue;
                    }
                    else if (definedType == inputTypeClass) {
View Full Code Here

            this.overload = overload;
            List<TInputSet> inputSets = overload.inputSets();
            int nInputs = inputs.size();
            AdjusterImpl adjuster = null;
            for (TInputSet inputSet : inputSets) {
                TClass targetTClass = inputSet.targetType();
                if (targetTClass == null) {
                    TInstance type = findCommon(overload, inputSet, inputs, resolver);
                    fillInstances(overload, inputSet, type, nInputs);
                }
                else {
View Full Code Here

        private void findInstance(V overload, TInputSet inputSet,
                                       List<? extends TPreptimeValue> inputs,
                                       TCastResolver resolver)
        {
            final TClass targetTClass = inputSet.targetType();
            assert targetTClass != null;

            int lastPositionalInput = overload.positionalInputs();
            boolean notVararg = ! overload.isVararg();
            for (int i = 0, size = inputs.size(); i < size; ++i) {
                if (overload.inputSetAt(i) != inputSet)
                    continue;
                if (notVararg && (i >= lastPositionalInput))
                    break;
                TPreptimeValue inputTpv = inputs.get(i);
                TInstance inputInstance = inputTpv.type();
                TInstance resultInstance;
                if (inputInstance != null) {
                    TClass inputTClass = inputInstance.typeClass();
                    if (inputTClass == targetTClass) {
                        resultInstance = inputInstance;
                    }
                    else {
                        TCast requiredCast = resolver.cast(inputTClass, targetTClass);
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.TClass

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.