Examples of TCast


Examples of com.foundationdb.server.types.TCast

            private TPreparedExpression castTo(TPreparedExpression expression, TInstance target, TCastResolver casts) {
                TClass inputTClass = expression.resultType().typeClass();
                TClass targetTClass = target.typeClass();
                if (targetTClass.equals(inputTClass))
                    return expression;
                TCast cast = casts.cast(inputTClass, targetTClass);
                return new TCastExpression(expression, cast, target);
            }
        };
    }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

            }
            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

Examples of com.foundationdb.server.types.TCast

            }
            catch (IOException ex) {
                throw new AkibanInternalException("IO error reading from byte array", ex);
            }
        }
        TCast cast = typesRegistryService.getCastsResolver().cast(source.getType(), targetType);
        TExecutionContext context =
                new TExecutionContext(Collections.singletonList(source.getType()),
                        targetType,
                        queryContext);
        Value target = new Value(targetType);
        cast.evaluate(context, source, target);
        bindings.setValue(index, target);
    }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

            Column column = colIt.next();
            TInstance type = column.getType();
            int pos = column.getPosition();
            row[pos] = insertExprs.get(i);
            if(!type.equals(row[pos].resultType())) {
                TCast tcast = registryService().getCastsResolver().cast(row[pos].resultType().typeClass(),
                                                                        type.typeClass());
                row[pos] = new TCastExpression(row[pos], tcast, type);
            }
        }
        // Fill in column defaults
View Full Code Here

Examples of com.foundationdb.server.types.TCast

        for (Column column : table.getColumns()) {
            if (!pkList.contains(column) && upColumns.contains(column)) {
                updates[index] new TPreparedParameter(paramIndex, varchar);
               
                if (!column.getType().equals(varchar)) {
                    TCast cast = registryService().getCastsResolver().cast(varchar.typeClass(),
                            column.getType().typeClass());
                    updates[index] = new TCastExpression(updates[index], cast, column.getType());
                }
                paramIndex++;
            }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

                        return new BooleanConstantExpression(null);
                    }
                    if (casts.isIndexFriendly(tclass(leftTInst), tclass(rightTInst))) {
                        TInstance columnType = type(left);
                        TInstance constType = type(right);
                        TCast constToCol = casts.cast(constType, columnType);
                        if (constToCol != null) {
                            TCast colToConst = casts.cast(columnType, constType);
                            if (colToConst != null) {
                                TPreptimeValue constValue = right.getPreptimeValue();
                                ValueSource asColType = castValue(constToCol, constValue, columnType);
                                TPreptimeValue asColTypeTpv = (asColType == null)
                                        ? null
View Full Code Here

Examples of com.foundationdb.server.types.TCast

                TInstance dinst = overload.resultStrategy().fixed(false);
                TPreparedExpression defExpr = new TPreparedFunction(overload,
                                                                    dinst,
                                                                    Collections.<TPreparedExpression>emptyList());
                if (!dinst.equals(type)) {
                    TCast tcast = typesService.getCastsResolver().cast(dinst.typeClass(), type.typeClass());
                    defExpr = new TCastExpression(defExpr, tcast, type);
                }
                expression = defExpr;
            }
            else {
                final String defaultValue = column.getDefaultValue();
                final Value defaultValueSource;
                if(defaultValue == null) {
                    defaultValueSource = new Value(type);
                    defaultValueSource.putNull();
                } else {
                    TCast cast = type.typeClass().castFromVarchar();
                    if (cast != null) {
                        defaultValueSource = new Value(type);
                        TInstance valInst = typesTranslator.typeForString(defaultValue);
                        TExecutionContext executionContext = new TExecutionContext(Collections.singletonList(valInst),
                                                                                   type,
                                                                                   queryContext);
                        cast.evaluate(executionContext,
                                      new Value(valInst, defaultValue),
                                      defaultValueSource);
                    } else {
                        defaultValueSource = new Value(type, defaultValue);
                    }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

            return new TNullExpression(toType);
        }
        else if (!toType.equals(sourceInstance))
        {
            // Do type conversion.
            TCast tcast = registryService.getCastsResolver().cast(sourceInstance, toType);
            if (tcast == null) {
                throw new NoSuchCastException(sourceInstance, toType);
            }
            expr = new TCastExpression(expr, tcast, toType);
        }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

    }

    // private

    private static TCast cast(Map<TClass, Map<TClass, TCast>> castsBySource, TClass source, TClass target) {
        TCast result = null;
        Map<TClass,TCast> castsByTarget = castsBySource.get(source);
        if (castsByTarget != null)
            result = castsByTarget.get(target);
        return result;
    }
View Full Code Here

Examples of com.foundationdb.server.types.TCast

    {
        Collection<? extends TStrongCasts> strongCastIds = finder.find(TStrongCasts.class);
        Set<TCastIdentifier> strongCasts = new HashSet<>(strongCastIds.size()); // rough guess
        for (TStrongCasts strongCastGenerator : strongCastIds) {
            for (TCastIdentifier castId : strongCastGenerator.get()) {
                TCast cast = cast(castsBySource, castId.getSource(), castId.getTarget());
                if (cast == null)
                    throw new AkibanInternalException("no cast defined for " + castId +", which is marked as strong");
                if (!strongCasts.add(castId)) {
                    logger.warn("multiple sources have listed cast {} as strong", castId);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.