Package com.foundationdb.server.types.service

Examples of com.foundationdb.server.types.service.TypesRegistryService


            vstring.putString(column.getDefaultValue(), null);
            value.getType().typeClass().fromObject(te, vstring, value);
            values[ci] = value;
        }
        this.expressions = new TEvaluatableExpression[evalColumns.length];
        TypesRegistryService registry = null;
        if (evalColumns.length > 0) {
            registry = queryContext.getServiceManager().getServiceByClass(TypesRegistryService.class);
        }
        for (int fi = 0; fi < evalColumns.length; fi++) {
            int ci = evalColumns[fi];
            Column column = functionColumns.get(fi);
            TInstance columnType = column.getType();
            String functionName;
            List<TPreptimeValue> input;
            List<TPreparedExpression> arguments;
            if (column.getIdentityGenerator() != null) {
                Sequence sequence = column.getIdentityGenerator();
                TableName sequenceName = sequence.getSequenceName();
                functionName = "NEXTVAL";
                input = new ArrayList<>(2);
                input.add(ValueSources.fromObject(sequenceName.getSchemaName(), typesTranslator.typeForString(sequenceName.getSchemaName())));
                input.add(ValueSources.fromObject(sequenceName.getTableName(), typesTranslator.typeForString(sequenceName.getTableName())));
                arguments = new ArrayList<>(input.size());
                for (TPreptimeValue tpv : input) {
                    arguments.add(new TPreparedLiteral(tpv.type(), tpv.value()));
                }
            }
            else {
                functionName = column.getDefaultFunction();
                assert (functionName != null) : column;
                input = Collections.<TPreptimeValue>emptyList();
                arguments = Collections.<TPreparedExpression>emptyList();
            }
            TValidatedScalar overload = registry.getScalarsResolver().get(functionName, input).getOverload();
            TInstance functionType = overload.resultStrategy().fixed(column.getNullable());
            TPreparedExpression expr = new TPreparedFunction(overload, functionType, arguments);
            if (!functionType.equals(columnType)) {
                TCast tcast = registry.getCastsResolver().cast(functionType.typeClass(), columnType.typeClass());
                expr = new TCastExpression(expr, tcast, columnType);
            }
            TEvaluatableExpression eval = expr.build();
            eval.with(queryContext);
            expressions[fi] = eval;
View Full Code Here


                TInstance type = column.getType();
                int pos = column.getPosition();
                row[pos] = insertsP.get(i);
               
                if (!type.equals(row[pos].resultType())) {
                    TypesRegistryService registry = rulesContext.getTypesRegistry();
                    TCast tcast = registry.getCastsResolver().cast(type.typeClass(), row[pos].resultType().typeClass());
                    row[pos] = new TCastExpression(row[pos], tcast, type);
                }
            }
            // Fill in column default values
            for (int i = 0, len = targetRowType.nFields(); i < len; ++i) {
View Full Code Here

            RowType outputRowType = outputScan.rowType;
            int nFieldsToCompare = index.getComparisonFields();
            List<TComparison> comparisons = new ArrayList<>(nFieldsToCompare);
            TypesRegistryService reg = rulesContext.getTypesRegistry();

            // Intersect can use raw value compare if the comparisons list is null (i.e. all types the same)
            boolean anySet = false;
            for (int n = 0; n < nFieldsToCompare; ++n)
            {
                TClass left = selectorRowType.typeAt(index.getSelectorIndexScan().getPeggedCount() + n).typeClass();
                TClass right = outputRowType.typeAt(index.getOutputIndexScan().getPeggedCount() + n).typeClass();
                if (left != right) {
                    anySet = true;
                    comparisons.add(n, reg.getKeyComparable(left, right).getComparison());
                } else {
                    comparisons.add(n, null);
                }
            }
           
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.service.TypesRegistryService

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.