Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TInputSet


    TValidatedOverload(TOverload overload) {
        this(overload, overload.inputSets());
    }

    TValidatedOverload(TOverload overload, List<TInputSet> inputSets) {
        TInputSet localVarargInputs = null;
        TInputSet localPickingInputs = null;
        SparseArray<TInputSet> inputSetsArray = new SparseArray<>();
        this.inputSetsCached = new ArrayList<>(inputSets);
        for (TInputSet inputSet : inputSetsCached) {
            if (inputSet.coversRemaining()) {
                if (localVarargInputs != null)
View Full Code Here


            ++positions;
        int[] results = new int[positions];
        Map<TInputSet, Integer> inputSetsToIndex = new HashMap<>(positions);
        int indexCounter = 0;
        for (int i = 0; i < positions; ++i) {
            TInputSet inputSet = (i < naturalPositions) ? inputSetsByPos.get(i) : varargs;
            Integer inputSetIndex = inputSetsToIndex.get(inputSet);
            if (inputSetIndex == null) {
                inputSetIndex = indexCounter++;
                inputSetsToIndex.put(inputSet, inputSetIndex);
            }
View Full Code Here

        if (pickingSet != null && pickingSet.targetType() == null) {
            map.put(pickingSet, "T");
            ++anyCount;
        }
        for (int i = 0; i < nInputsExtended; i++) {
            TInputSet inputSet = (i == nInputsRaw) ? varargInputSet : inputSetsByPos.get(i);
            String description = map.get(inputSet);
            if (description == null) {
                TClass inputTClass = inputSet == null ? null : inputSet.targetType();
                if (inputTClass == null) {
                    description = "T";
                    if (anyCount > 0)
                        description += ('#' + anyCount);
                    ++anyCount;
View Full Code Here

        List<TInputSet> origInputSets = inputSets();
        if (!origInputSets.isEmpty()) {
            List<TInputSet> inputSets = new ArrayList<>(origInputSets);
            Collections.sort(inputSets, INPUT_SET_COMPARATOR);
            for (Iterator<TInputSet> iter = inputSets.iterator(); iter.hasNext(); ) {
                TInputSet inputSet = iter.next();
                sb.append(inputSet);
                if (iter.hasNext())
                    sb.append(", ");
            }
        }
View Full Code Here

    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

            TPreptimeValue inputTpv = inputs.get(i);
            TInstance inputInstance = (inputTpv == null) ? null : inputTpv.type();
            // allow this input if...
            // ... input set takes ANY, and it isn't marked as an exact. If it's marked as an exact, we'll figure it
            // out later
            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) {
                        continue;
                    }
                }
                else if (inputTypeClass == null && scalarGroups.hasSameTypeAt(i)) {
                    continue;
                }
                else if (inputTypeClass == inputSet.targetType()) {
                    continue;
                }
            }
            else {
                if (castsResolver.strongCastExists(inputTypeClass, inputSet.targetType()))
                    continue;
            }
            // This input precludes the use of the overload
            return false;
        }
View Full Code Here

                while(it.hasNext()) {
                    V A = it.next();
                    boolean AtoB = true;
                    boolean BtoA = true;
                    for(int i = 0; i < nInputSets; ++i) {
                        TInputSet Ai = A.inputSetAt(i);
                        TInputSet Bi = B.inputSetAt(i);
                        AtoB &= castsResolver.strongCastExists(Ai.targetType(), Bi.targetType());
                        BtoA &= castsResolver.strongCastExists(Bi.targetType(), Ai.targetType());
                    }
                    if(AtoB) {
                        // current more specific
                        B = null;
                        break;
View Full Code Here

            }
            pickedInstance = findPickedInstance(overload, inputs);
        }

        private TInstance findPickedInstance(V overload, List<? extends TPreptimeValue> inputs) {
            TInputSet pickingSet = overload.pickingInputSet();
            TInstance result = null;
            if (pickingSet != null) {
                for (int i = overload.firstInput(pickingSet), max = inputs.size();
                     i >= 0;
                     i = overload.nextInput(pickingSet, i+1, max))
View Full Code Here

import java.util.List;

public final class TInputSetBuilder {

    public TInputSetBuilder covers(TClass targetType, int... covering) {
        inputSets.add(new TInputSet(targetType, BitSets.of(covering), false, false, nextNormalizer));
        nextNormalizer = null;
        setExacts(covering);
        return this;
    }
View Full Code Here

        setExacts(covering);
        return this;
    }

    public TInputSetBuilder pickingCovers(TClass targetType, int... covering) {
        inputSets.add(new TInputSet(targetType, BitSets.of(covering), false, true, nextNormalizer));
        nextNormalizer = null;
        return this;
    }
View Full Code Here

TOP

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

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.