Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Column


    }

    @Override
    protected void postCheckAIS(AkibanInformationSchema ais) {
        Table table = ais.getTable(SCHEMA, TABLE);
        Column column = table.getColumn(COLUMN);
        assertEquals("column nullable", expectedNullable, column.getNullable());
    }
View Full Code Here


    }

    @Override
    protected void postCheckAIS(AkibanInformationSchema ais) {
        Table table = ais.getTable(tID);
        Column column = table.getColumn(COLUMN_NAME);
        assertNotNull("new column present", column);
    }
View Full Code Here

        this.tableId = table.getTableId();
        this.rowDef = table.rowDef();
        this.fieldColumns = new int[columns.size()];
        this.nullable = new boolean[fieldColumns.length];
        for (int i = 0; i < fieldColumns.length; i++) {
            Column column = columns.get(i);
            fieldColumns[i] = column.getPosition();
            nullable[i] = column.getNullable();
        }
        List<Column> defaultColumns = new ArrayList<>();
        List<Column> functionColumns = new ArrayList<>();
        for (Column column : table.getColumnsIncludingInternal()) {
            if (columns.contains(column)) continue;
            if (column.getIdentityGenerator() != null) {
                functionColumns.add(column);
            }
            else if (column.getDefaultValue() != null) {
                defaultColumns.add(column);
            }
            else if (column.getDefaultFunction() != null) {
                functionColumns.add(column);
            }
        }
        this.constColumns = new int[defaultColumns.size()];
        for (int i = 0; i < constColumns.length; i++) {
            constColumns[i] = defaultColumns.get(i).getPosition();
        }
        this.evalColumns = new int[functionColumns.size()];
        for (int i = 0; i < evalColumns.length; i++) {
            evalColumns[i] = functionColumns.get(i).getPosition();
        }
        this.vstring = new Value(typesTranslator.typeForString());
        this.values = new Value[rowDef.getFieldCount()];
        this.executionContexts = new TExecutionContext[values.length];
        List<TInstance> inputs = Collections.singletonList(vstring.getType());
        for (int fi = 0; fi < fieldColumns.length; fi++) {
            int ci = fieldColumns[fi];
            TInstance output = columns.get(fi).getType();
            values[ci] = new Value(output);
            // TODO: Only needed until every place gets type from
            // ValueTarget, when there can just be one
            // TExecutionContext wrapping the QueryContext.
            executionContexts[ci] = new TExecutionContext(null,
                                                          inputs, output, queryContext,
                                                          ErrorHandlingMode.WARN,
                                                          ErrorHandlingMode.WARN,
                                                          ErrorHandlingMode.WARN);
        }
        for (int fi = 0; fi < constColumns.length; fi++) {
            int ci = constColumns[fi];
            Column column = defaultColumns.get(fi);
            TInstance output = column.getType();
            Value value = new Value(output);
            TExecutionContext te = new TExecutionContext(null,
                                                         inputs, output, queryContext,
                                                         ErrorHandlingMode.WARN,
                                                         ErrorHandlingMode.WARN,
                                                         ErrorHandlingMode.WARN);
            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);
            }
View Full Code Here

        this.schemaManager = schemaManager;
        this.registryService = typesRegistryService;
    }

    protected Column getColumn (Table table, String field) {
        Column column = table.getColumn(field);
        if (column == null) {
            throw new NoSuchColumnException(field);
        }
        return column;
    }
View Full Code Here

            columnar = ais.getView(parts[0], parts[1]);
            if(columnar == null) {
                throw new NoSuchTableException(parts[0], parts[1]);
            }
        }
        Column column = columnar.getColumn(parts[2]);
        if(column == null) {
            throw new NoSuchColumnException(String.format("%s.%s.%s", parts[0], parts[1], parts[2]));
        }
        output.putString(column.getType().toStringConcise(false), null);
    }
View Full Code Here

                        hKeyAppender.appendNull();
                    }
                    ++i2hPosition;
                } else {
                    // HKey column from rowData
                    Column column = hKeyColumn.column();
                    hKeyAppender.append(column.getFieldDef(), rowData);
                }
            }
        }
        if(parentStoreData != null) {
            releaseStoreData(session, parentStoreData);
View Full Code Here

            List<Column> pkColumns = table.getPrimaryKeyIncludingInternal().getColumns();
            for(HKeySegment segment : table.hKey().segments()) {
                RowDef segmentRowDef = segment.table().rowDef();
                hKey.append(segmentRowDef.table().getOrdinal());
                for(HKeyColumn hKeyColumn : segment.columns()) {
                    Column column = hKeyColumn.column();
                    if(pkColumns.contains(column)) {
                        RowDef columnTableRowDef = column.getTable().rowDef();
                        hKeyAppender.append(columnTableRowDef.getFieldDef(column.getPosition()), rowData);
                    } else {
                        hKey.append(null);
                    }
                }
            }
View Full Code Here

        Cursor cursor = API.cursor(plan, queryContext, queryBindings);

        List<Column> lookupCols = table.getPrimaryKeyIncludingInternal().getColumns();
        RowDataValueSource pSource = new RowDataValueSource();
        for(int i = 0; i < lookupCols.size(); ++i) {
            Column col = lookupCols.get(i);
            pSource.bind(col.getFieldDef(), rowData);
            queryBindings.setValue(i, pSource);
        }
        try {
            Row row;
            cursor.openTopLevel();
View Full Code Here

        return table.rowDef();
    }

    protected void fillIdentityColumn(Session session, NewRow row) {
        Table table = row.getRowDef().table();
        Column idColumn = table.getIdentityColumn();
        if (idColumn != null) {
            FieldDef fieldDef = idColumn.getFieldDef();
            Boolean defaultIdentity = idColumn.getDefaultIdentity();
            if (defaultIdentity == false ||
                    (defaultIdentity == true && row.isColumnNull(fieldDef.getFieldIndex()))) {
                Sequence sequence = idColumn.getIdentityGenerator();
                Long value = this.nextSequenceValue(session, sequence);
                row.put(fieldDef.getFieldIndex(), value);
            }
        }
    }
View Full Code Here

            else {
                int offset = i;
                if (i > firstSpatialColumn) {
                    offset += index.dimensions() - 1;
                }
                Column column = index.getKeyColumns().get(firstColumn + offset).getColumn();
                type = column.getType();
                column.getCollator();
            }
            // For example, for DECIMAL, value will be a
            // String, pvalue will be a its VARCHAR, and pvalue2
            // will be a BigDecimalWrapper, which only
            // TBigDecimal.writeCollating knows how to unwrap into
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Column

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.